diff --git a/.ic3_history b/.ic3_history
index d5d4136..9cae032 100644
--- a/.ic3_history
+++ b/.ic3_history
@@ -29,3 +29,5 @@ to_list(%{a: 1, b: 2})
to_list = fn (map) { Map.map(map, fn (k, v) { {k, v} }) }
to_list(%{a: 1, b: 2})
Map.to_list(%{a: 1, b: 2})
+"\libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/flaps.png b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/flaps.png
+ "\U+1FAB0"
diff --git a/libc3/array.c b/libc3/array.c
index ef6d8f1..1079a2d 100644
--- a/libc3/array.c
+++ b/libc3/array.c
@@ -60,8 +60,8 @@ void array_clean (s_array *a)
free(a->dimensions);
if (a->data) {
data = a->data;
- size = array_type_size(a->type);
- tag.type = array_type_to_tag_type(a->type);
+ size = sym_type_size(a->type);
+ sym_to_tag_type(a->type, &tag.type);
i = 0;
while (i < a->count) {
data_tag = tag_to_pointer(&tag, a->type);
@@ -101,6 +101,23 @@ void * array_data (const s_array *a, const uw *address)
return (s8 *) a->data + offset;
}
+s_array * array_data_set (s_array *a, const uw *address,
+ const void *data)
+{
+ void *a_data;
+ f_init_copy init_copy;
+ assert(a);
+ assert(address);
+ assert(data);
+ if ((a_data = array_data(a, address))) {
+ init_copy = sym_to_init_copy(a->type);
+ if (init_copy(a_data, data) != a_data)
+ return NULL;
+ return a;
+ }
+ return NULL;
+}
+
s_tag * array_data_tag (s_tag *a, const s_tag *address, s_tag *dest)
{
void *a_data;
@@ -111,7 +128,7 @@ s_tag * array_data_tag (s_tag *a, const s_tag *address, s_tag *dest)
if ((a_data = array_data(&a->data.array,
address->data.array.data))) {
tag_init(dest);
- init_copy = array_type_to_init_copy(a->data.array.type);
+ init_copy = sym_to_init_copy(a->data.array.type);
sym_to_tag_type(a->data.array.type, &dest->type);
dest_data = tag_to_pointer(dest, a->data.array.type);
if (init_copy(dest_data, a_data) != dest_data)
@@ -151,7 +168,7 @@ s_array * array_init (s_array *a, const s_sym *type, uw dimension,
}
i--;
a->type = type;
- item_size = array_type_size(type);
+ item_size = sym_type_size(type);
a->dimensions[i].item_size = item_size;
while (i > 0) {
i--;
@@ -228,7 +245,7 @@ s_array * array_init_copy (s_array *a, const s_array *src)
if (src->data) {
if (! (tmp.data = calloc(1, src->size)))
errx(1, "array_init_copy: out of memory");
- init_copy = array_type_to_init_copy(src->type);
+ init_copy = sym_to_init_copy(src->type);
data_a = tmp.data;
data_src = src->data;
i = 0;
@@ -278,308 +295,3 @@ s_str * array_inspect (const s_array *array, s_str *dest)
}
return buf_to_str(&tmp, dest);
}
-
-uw array_type_size (const s_sym *type)
-{
- if (type == sym_1("Bool"))
- return sizeof(bool);
- if (type == sym_1("Call"))
- return sizeof(s_call);
- if (type == sym_1("Cfn"))
- return sizeof(s_cfn);
- if (type == sym_1("Character"))
- return sizeof(character);
- if (type == sym_1("F32"))
- return sizeof(f32);
- if (type == sym_1("F64"))
- return sizeof(f64);
- if (type == sym_1("Fact"))
- return sizeof(s_fact);
- if (type == sym_1("Fn"))
- return sizeof(s_fn);
- if (type == sym_1("Ident"))
- return sizeof(s_ident);
- if (type == sym_1("Integer"))
- return sizeof(s_integer);
- if (type == sym_1("Sw"))
- return sizeof(sw);
- if (type == sym_1("S64"))
- return sizeof(s64);
- if (type == sym_1("S32"))
- return sizeof(s32);
- if (type == sym_1("S16"))
- return sizeof(s16);
- if (type == sym_1("S8"))
- return sizeof(s8);
- if (type == sym_1("U8"))
- return sizeof(u8);
- if (type == sym_1("U16"))
- return sizeof(u16);
- if (type == sym_1("U32"))
- return sizeof(u32);
- if (type == sym_1("U64"))
- return sizeof(u64);
- if (type == sym_1("Uw"))
- return sizeof(uw);
- if (type == sym_1("List"))
- return sizeof(s_list *);
- if (type == sym_1("Ptag"))
- return sizeof(p_tag);
- if (type == sym_1("Quote"))
- return sizeof(s_quote);
- if (type == sym_1("Str"))
- return sizeof(s_str);
- if (type == sym_1("Sym"))
- return sizeof(s_sym *);
- if (type == sym_1("Tuple"))
- return sizeof(s_tuple);
- if (type == sym_1("Var"))
- return sizeof(s_tag);
- assert(! "array_type_size: unknown type");
- errx(1, "array_type_size: unknown type: %s", type->str.ptr.ps8);
- return 0;
-}
-
-f_buf_inspect array_type_to_buf_inspect (const s_sym *type)
-{
- if (type == sym_1("Bool"))
- return (f_buf_inspect) buf_inspect_bool;
- if (type == sym_1("Call"))
- return (f_buf_inspect) buf_inspect_call;
- if (type == sym_1("Cfn"))
- return (f_buf_inspect) buf_inspect_cfn;
- if (type == sym_1("Character"))
- return (f_buf_inspect) buf_inspect_character;
- if (type == sym_1("F32"))
- return (f_buf_inspect) buf_inspect_f32;
- if (type == sym_1("F64"))
- return (f_buf_inspect) buf_inspect_f64;
- if (type == sym_1("Fact"))
- return (f_buf_inspect) buf_inspect_fact;
- if (type == sym_1("Fn"))
- return (f_buf_inspect) buf_inspect_fn;
- if (type == sym_1("Ident"))
- return (f_buf_inspect) buf_inspect_ident;
- if (type == sym_1("Integer"))
- return (f_buf_inspect) buf_inspect_integer;
- if (type == sym_1("Sw"))
- return (f_buf_inspect) buf_inspect_sw;
- if (type == sym_1("S64"))
- return (f_buf_inspect) buf_inspect_s64;
- if (type == sym_1("S32"))
- return (f_buf_inspect) buf_inspect_s32;
- if (type == sym_1("S16"))
- return (f_buf_inspect) buf_inspect_s16;
- if (type == sym_1("S8"))
- return (f_buf_inspect) buf_inspect_s8;
- if (type == sym_1("U8"))
- return (f_buf_inspect) buf_inspect_u8;
- if (type == sym_1("U16"))
- return (f_buf_inspect) buf_inspect_u16;
- if (type == sym_1("U32"))
- return (f_buf_inspect) buf_inspect_u32;
- if (type == sym_1("U64"))
- return (f_buf_inspect) buf_inspect_u64;
- if (type == sym_1("Uw"))
- return (f_buf_inspect) buf_inspect_uw;
- if (type == sym_1("List"))
- return (f_buf_inspect) buf_inspect_list;
- if (type == sym_1("Ptag"))
- return (f_buf_inspect) buf_inspect_ptag;
- if (type == sym_1("Quote"))
- return (f_buf_inspect) buf_inspect_quote;
- if (type == sym_1("Str"))
- return (f_buf_inspect) buf_inspect_str;
- if (type == sym_1("Sym"))
- return (f_buf_inspect) buf_inspect_sym;
- if (type == sym_1("Tuple"))
- return (f_buf_inspect) buf_inspect_tuple;
- if (type == sym_1("Var"))
- return (f_buf_inspect) buf_inspect_var;
- assert(! "array_type_to_buf_inspect: unknown type");
- errx(1, "array_type_to_buf_inspect: unknown type");
- return NULL;
-}
-
-f_buf_inspect_size array_type_to_buf_inspect_size (const s_sym *type)
-{
- if (type == sym_1("Bool"))
- return (f_buf_inspect_size) buf_inspect_bool_size;
- if (type == sym_1("Call"))
- return (f_buf_inspect_size) buf_inspect_call_size;
- if (type == sym_1("Cfn"))
- return (f_buf_inspect_size) buf_inspect_cfn_size;
- if (type == sym_1("Character"))
- return (f_buf_inspect_size) buf_inspect_character_size;
- if (type == sym_1("F32"))
- return (f_buf_inspect_size) buf_inspect_f32_size;
- if (type == sym_1("F64"))
- return (f_buf_inspect_size) buf_inspect_f64_size;
- if (type == sym_1("Fact"))
- return (f_buf_inspect_size) buf_inspect_fact_size;
- if (type == sym_1("Fn"))
- return (f_buf_inspect_size) buf_inspect_fn_size;
- if (type == sym_1("Ident"))
- return (f_buf_inspect_size) buf_inspect_ident_size;
- if (type == sym_1("Integer"))
- return (f_buf_inspect_size) buf_inspect_integer_size;
- if (type == sym_1("Sw"))
- return (f_buf_inspect_size) buf_inspect_sw_size;
- if (type == sym_1("S64"))
- return (f_buf_inspect_size) buf_inspect_s64_size;
- if (type == sym_1("S32"))
- return (f_buf_inspect_size) buf_inspect_s32_size;
- if (type == sym_1("S16"))
- return (f_buf_inspect_size) buf_inspect_s16_size;
- if (type == sym_1("S8"))
- return (f_buf_inspect_size) buf_inspect_s8_size;
- if (type == sym_1("U8"))
- return (f_buf_inspect_size) buf_inspect_u8_size;
- if (type == sym_1("U16"))
- return (f_buf_inspect_size) buf_inspect_u16_size;
- if (type == sym_1("U32"))
- return (f_buf_inspect_size) buf_inspect_u32_size;
- if (type == sym_1("U64"))
- return (f_buf_inspect_size) buf_inspect_u64_size;
- if (type == sym_1("Uw"))
- return (f_buf_inspect_size) buf_inspect_uw_size;
- if (type == sym_1("List"))
- return (f_buf_inspect_size) buf_inspect_list_size;
- if (type == sym_1("Ptag"))
- return (f_buf_inspect_size) buf_inspect_ptag_size;
- if (type == sym_1("Quote"))
- return (f_buf_inspect_size) buf_inspect_quote_size;
- if (type == sym_1("Str"))
- return (f_buf_inspect_size) buf_inspect_str_size;
- if (type == sym_1("Sym"))
- return (f_buf_inspect_size) buf_inspect_sym_size;
- if (type == sym_1("Tuple"))
- return (f_buf_inspect_size) buf_inspect_tuple_size;
- if (type == sym_1("Var"))
- return (f_buf_inspect_size) buf_inspect_var_size;
- assert(! "array_type_to_buf_inspect: unknown type");
- errx(1, "array_type_to_buf_inspect: unknown type");
- return NULL;
-}
-
-f_init_copy array_type_to_init_copy (const s_sym *type)
-{
- if (type == sym_1("Bool"))
- return (f_init_copy) bool_init_copy;
- if (type == sym_1("Call"))
- return (f_init_copy) call_init_copy;
- if (type == sym_1("Cfn"))
- return (f_init_copy) cfn_init_copy;
- if (type == sym_1("Character"))
- return (f_init_copy) character_init_copy;
- if (type == sym_1("F32"))
- return (f_init_copy) f32_init_copy;
- if (type == sym_1("F64"))
- return (f_init_copy) f64_init_copy;
- if (type == sym_1("Fact"))
- return (f_init_copy) fact_init_copy;
- if (type == sym_1("Fn"))
- return (f_init_copy) fn_init_copy;
- if (type == sym_1("Ident"))
- return (f_init_copy) ident_init_copy;
- if (type == sym_1("Integer"))
- return (f_init_copy) integer_init_copy;
- if (type == sym_1("List"))
- return (f_init_copy) list_init_copy;
- if (type == sym_1("Sw"))
- return (f_init_copy) sw_init_copy;
- if (type == sym_1("S64"))
- return (f_init_copy) s64_init_copy;
- if (type == sym_1("S32"))
- return (f_init_copy) s32_init_copy;
- if (type == sym_1("S16"))
- return (f_init_copy) s16_init_copy;
- if (type == sym_1("S8"))
- return (f_init_copy) s8_init_copy;
- if (type == sym_1("U8"))
- return (f_init_copy) u8_init_copy;
- if (type == sym_1("U16"))
- return (f_init_copy) u16_init_copy;
- if (type == sym_1("U32"))
- return (f_init_copy) u32_init_copy;
- if (type == sym_1("U64"))
- return (f_init_copy) u64_init_copy;
- if (type == sym_1("Uw"))
- return (f_init_copy) uw_init_copy;
- if (type == sym_1("Ptag"))
- return (f_init_copy) ptag_init_copy;
- if (type == sym_1("Quote"))
- return (f_init_copy) quote_init_copy;
- if (type == sym_1("Str"))
- return (f_init_copy) str_init_copy;
- if (type == sym_1("Sym"))
- return (f_init_copy) sym_init_copy;
- if (type == sym_1("Tuple"))
- return (f_init_copy) tuple_init_copy;
- if (type == sym_1("Var"))
- return (f_init_copy) var_init_copy;
- assert(! "array_type_to_init_copy: unknown type");
- errx(1, "array_type_to_init_copy: unknown type");
- return NULL;
-}
-
-e_tag_type array_type_to_tag_type (const s_sym *type)
-{
- if (type == sym_1("Bool"))
- return TAG_BOOL;
- if (type == sym_1("Call"))
- return TAG_CALL;
- if (type == sym_1("Cfn"))
- return TAG_CFN;
- if (type == sym_1("Character"))
- return TAG_CHARACTER;
- if (type == sym_1("F32"))
- return TAG_F32;
- if (type == sym_1("F64"))
- return TAG_F64;
- if (type == sym_1("Fact"))
- return TAG_FACT;
- if (type == sym_1("Fn"))
- return TAG_FN;
- if (type == sym_1("Ident"))
- return TAG_IDENT;
- if (type == sym_1("Integer"))
- return TAG_INTEGER;
- if (type == sym_1("Sw"))
- return TAG_SW;
- if (type == sym_1("S64"))
- return TAG_S64;
- if (type == sym_1("S32"))
- return TAG_S32;
- if (type == sym_1("S16"))
- return TAG_S16;
- if (type == sym_1("S8"))
- return TAG_S8;
- if (type == sym_1("U8"))
- return TAG_U8;
- if (type == sym_1("U16"))
- return TAG_U16;
- if (type == sym_1("U32"))
- return TAG_U32;
- if (type == sym_1("U64"))
- return TAG_U64;
- if (type == sym_1("Uw"))
- return TAG_UW;
- if (type == sym_1("List"))
- return TAG_LIST;
- if (type == sym_1("Ptag"))
- return TAG_PTAG;
- if (type == sym_1("Quote"))
- return TAG_QUOTE;
- if (type == sym_1("Str"))
- return TAG_STR;
- if (type == sym_1("Sym"))
- return TAG_SYM;
- if (type == sym_1("Tuple"))
- return TAG_TUPLE;
- if (type == sym_1("Var"))
- return TAG_VAR;
- assert(! "array_type_to_tag_type: invalid type");
- errx(1, "array_type_to_tag_type: invalid type: %s", type->str.ptr.ps8);
- return TAG_VOID;
-}
diff --git a/libc3/array.h b/libc3/array.h
index 6466790..e7c7756 100644
--- a/libc3/array.h
+++ b/libc3/array.h
@@ -27,10 +27,9 @@ s_str * array_inspect (const s_array *array, s_str *dest);
void * array_data (const s_array *a, const uw *address);
s_tag * array_data_tag (s_tag *a, const s_tag *address,
s_tag *dest);
-uw array_type_size (const s_sym *type);
-f_buf_inspect array_type_to_buf_inspect (const s_sym *type);
-f_buf_inspect_size array_type_to_buf_inspect_size (const s_sym *type);
-f_init_copy array_type_to_init_copy (const s_sym *type);
-e_tag_type array_type_to_tag_type (const s_sym *type);
+
+/* Operators */
+s_array * array_data_set (s_array *a, const uw *address,
+ const void *data);
#endif /* LIBC3_ARRAY_H */
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index cb18d76..b5bd0d2 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -67,15 +67,13 @@ sw buf_inspect_array_data (s_buf *buf, const s_array *array)
u8 *data = NULL;
f_buf_inspect inspect = NULL;
s_tag *tag = NULL;
- e_tag_type tag_type;
sw r;
assert(buf);
assert(array);
address = calloc(array->dimension, sizeof(uw));
if (array->data) {
data = array->data;
- tag_type = array_type_to_tag_type(array->type);
- inspect = tag_type_to_buf_inspect(tag_type);
+ inspect = sym_to_buf_inspect(array->type);
}
else
tag = array->tags;
@@ -140,14 +138,12 @@ sw buf_inspect_array_data_size (const s_array *array)
u8 *data = NULL;
f_buf_inspect_size inspect_size = NULL;
s_tag *tag = NULL;
- e_tag_type tag_type;
sw r;
assert(array);
address = calloc(array->dimension, sizeof(uw));
if (array->data) {
data = array->data;
- tag_type = array_type_to_tag_type(array->type);
- inspect_size = tag_type_to_buf_inspect_size(tag_type);
+ inspect_size = sym_to_buf_inspect_size(array->type);
}
else
tag = array->tags;
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 7c4d029..25f1471 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -256,7 +256,7 @@ sw buf_parse_array_dimensions (s_buf *buf, s_array *dest)
assert(dest);
tmp = *dest;
address = calloc(tmp.dimension, sizeof(sw));
- size = array_type_size(tmp.type);
+ size = sym_type_size(tmp.type);
tmp.dimensions[tmp.dimension - 1].item_size = size;
if ((r = buf_parse_array_dimensions_rec(buf, &tmp, address,
0)) <= 0) {
diff --git a/libc3/c3.h b/libc3/c3.h
index 43916c9..679f17b 100644
--- a/libc3/c3.h
+++ b/libc3/c3.h
@@ -66,15 +66,27 @@
#include "integer.h"
#include "io.h"
#include "list.h"
+#include "ptag.h"
#include "module.h"
#include "operator.h"
#include "quote.h"
+#include "s8.h"
+#include "s16.h"
+#include "s32.h"
+#include "s64.h"
#include "sequence.h"
#include "str.h"
+#include "sw.h"
#include "tag.h"
#include "time.h"
#include "tuple.h"
#include "type.h"
+#include "u8.h"
+#include "u16.h"
+#include "u32.h"
+#include "u64.h"
+#include "uw.h"
#include "ucd.h"
+#include "var.h"
#endif /* LIBC3_C3_H */
diff --git a/libc3/file.c b/libc3/file.c
index 1f53266..75795d4 100644
--- a/libc3/file.c
+++ b/libc3/file.c
@@ -132,7 +132,7 @@ s_str * file_search (const s_str *suffix, const s_sym *mode,
(r = buf_write_str(&buf, suffix)) < 0)
return NULL;
buf_read_to_str(&buf, &tmp);
- io_inspect_str(&tmp);
+ /* io_inspect_str(&tmp); */
file_access(&tmp, mode, &access);
if (access) {
*dest = tmp;
diff --git a/libc3/io.h b/libc3/io.h
index f2b1ed5..5e7db1b 100644
--- a/libc3/io.h
+++ b/libc3/io.h
@@ -33,9 +33,11 @@ sw err_puts (const s8 *x);
sw io_inspect (const s_tag *x);
sw io_puts (const s8 *x);
+PROTOTYPES_ERR_IO_INSPECT(array, s_array);
PROTOTYPES_ERR_IO_INSPECT(fact, s_fact);
PROTOTYPES_ERR_IO_INSPECT(fn_pattern, s_list);
PROTOTYPES_ERR_IO_INSPECT(list, s_list *);
+PROTOTYPES_ERR_IO_INSPECT(map, s_map);
PROTOTYPES_ERR_IO_INSPECT(str, s_str);
PROTOTYPES_ERR_IO_INSPECT(tag, s_tag);
diff --git a/libc3/list.c b/libc3/list.c
index b707981..3545044 100644
--- a/libc3/list.c
+++ b/libc3/list.c
@@ -18,6 +18,7 @@
#include "buf_inspect.h"
#include "buf_parse.h"
#include "list.h"
+#include "sym.h"
#include "tag.h"
#include "tuple.h"
@@ -244,7 +245,7 @@ s_array * list_to_array (s_list *list, const s_sym *type,
assert(list);
assert(dest);
len = list_length(list);
- size = array_type_size(type);
+ size = sym_type_size(type);
dest->dimension = 1;
dest->type = type;
if (! (dest->dimensions = calloc(1, sizeof(s_array_dimension))))
@@ -255,7 +256,7 @@ s_array * list_to_array (s_list *list, const s_sym *type,
dest->size = len * size;
if (! (data = dest->data = calloc(len, size)))
errx(1, "list_to_array: out of memory: 2");
- init_copy = array_type_to_init_copy(type);
+ init_copy = sym_to_init_copy(type);
l = list;
while (l) {
data_list = tag_to_pointer(&l->tag, type);
diff --git a/libc3/sources.mk b/libc3/sources.mk
index dd058b8..7c58cba 100644
--- a/libc3/sources.mk
+++ b/libc3/sources.mk
@@ -266,6 +266,11 @@ SOURCES = \
tag_band.c \
tag_bor.c \
tag_bxor.c \
+ tag_mod.c \
+ tag_mul.c \
+ tag_shift_left.c \
+ tag_shift_right.c \
+ tag_sub.c \
time.c \
tuple.c \
type.c \
@@ -405,6 +410,11 @@ LO_SOURCES = \
tag_band.c \
tag_bor.c \
tag_bxor.c \
+ tag_mod.c \
+ tag_mul.c \
+ tag_shift_left.c \
+ tag_shift_right.c \
+ tag_sub.c \
time.c \
tuple.c \
type.c \
diff --git a/libc3/sources.sh b/libc3/sources.sh
index 530f61e..d45a6fe 100644
--- a/libc3/sources.sh
+++ b/libc3/sources.sh
@@ -1,4 +1,4 @@
# sources.sh generated by update_sources
HEADERS='abs.h arg.h array.h binding.h bool.h buf.h buf_file.h buf_inspect.h buf_inspect_s16.h buf_inspect_s16_binary.h buf_inspect_s16_decimal.h buf_inspect_s16_hexadecimal.h buf_inspect_s16_octal.h buf_inspect_s32.h buf_inspect_s32_binary.h buf_inspect_s32_decimal.h buf_inspect_s32_hexadecimal.h buf_inspect_s32_octal.h buf_inspect_s64.h buf_inspect_s64_binary.h buf_inspect_s64_decimal.h buf_inspect_s64_hexadecimal.h buf_inspect_s64_octal.h buf_inspect_s8.h buf_inspect_s8_binary.h buf_inspect_s8_decimal.h buf_inspect_s8_hexadecimal.h buf_inspect_s8_octal.h buf_inspect_sw.h buf_inspect_sw_binary.h buf_inspect_sw_decimal.h buf_inspect_sw_hexadecimal.h buf_inspect_sw_octal.h buf_inspect_u16.h buf_inspect_u16_binary.h buf_inspect_u16_decimal.h buf_inspect_u16_hexadecimal.h buf_inspect_u16_octal.h buf_inspect_u32.h buf_inspect_u32_binary.h buf_inspect_u32_decimal.h buf_inspect_u32_hexadecimal.h buf_inspect_u32_octal.h buf_inspect_u64.h buf_inspect_u64_binary.h buf_inspect_u64_decimal.h buf_inspect_u64_hexadecimal.h buf_inspect_u64_octal.h buf_inspect_u8.h buf_inspect_u8_binary.h buf_inspect_u8_decimal.h buf_inspect_u8_hexadecimal.h buf_inspect_u8_octal.h buf_inspect_uw.h buf_inspect_uw_binary.h buf_inspect_uw_decimal.h buf_inspect_uw_hexadecimal.h buf_inspect_uw_octal.h buf_parse.h buf_parse_s16.h buf_parse_s32.h buf_parse_s64.h buf_parse_s8.h buf_parse_sw.h buf_parse_u16.h buf_parse_u32.h buf_parse_u64.h buf_parse_u8.h buf_parse_uw.h buf_save.h c3.h c3_main.h call.h ceiling.h cfn.h character.h compare.h config.h env.h error.h error_handler.h eval.h f32.h f64.h fact.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_with.h facts_with_cursor.h file.h float.h fn.h fn_clause.h frame.h hash.h ident.h integer.h io.h list.h log.h map.h module.h operator.h ptag.h quote.h s16.h s32.h s64.h s8.h sequence.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h sha1.h sign.h skiplist__fact.h skiplist_node__fact.h str.h sw.h sym.h tag.h time.h tuple.h type.h types.h u16.h u32.h u64.h u8.h ucd.h uw.h var.h '
-SOURCES='abs.c arg.c array.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_save.c c3.c call.c ceiling.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c file.c fn.c fn_clause.c frame.c hash.c ident.c integer.c io.c license.c list.c log.c map.c module.c operator.c ptag.c quote.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sign.c skiplist__fact.c skiplist_node__fact.c str.c sw.c sym.c tag.c tag_add.c tag_band.c tag_bor.c tag_bxor.c time.c tuple.c type.c u16.c u32.c u64.c u8.c ucd.c uw.c var.c '
-LO_SOURCES='abs.c arg.c array.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_save.c c3.c call.c ceiling.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c file.c fn.c fn_clause.c frame.c hash.c ident.c integer.c io.c license.c list.c log.c map.c module.c operator.c ptag.c quote.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sign.c skiplist__fact.c skiplist_node__fact.c str.c sw.c sym.c tag.c tag_add.c tag_band.c tag_bor.c tag_bxor.c time.c tuple.c type.c u16.c u32.c u64.c u8.c ucd.c uw.c var.c ../libtommath/bn_cutoffs.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_double.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_rand_platform.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
+SOURCES='abs.c arg.c array.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_save.c c3.c call.c ceiling.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c file.c fn.c fn_clause.c frame.c hash.c ident.c integer.c io.c license.c list.c log.c map.c module.c operator.c ptag.c quote.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sign.c skiplist__fact.c skiplist_node__fact.c str.c sw.c sym.c tag.c tag_add.c tag_band.c tag_bor.c tag_bxor.c tag_mod.c tag_mul.c tag_shift_left.c tag_shift_right.c tag_sub.c time.c tuple.c type.c u16.c u32.c u64.c u8.c ucd.c uw.c var.c '
+LO_SOURCES='abs.c arg.c array.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_inspect_s16.c buf_inspect_s16_binary.c buf_inspect_s16_decimal.c buf_inspect_s16_hexadecimal.c buf_inspect_s16_octal.c buf_inspect_s32.c buf_inspect_s32_binary.c buf_inspect_s32_decimal.c buf_inspect_s32_hexadecimal.c buf_inspect_s32_octal.c buf_inspect_s64.c buf_inspect_s64_binary.c buf_inspect_s64_decimal.c buf_inspect_s64_hexadecimal.c buf_inspect_s64_octal.c buf_inspect_s8.c buf_inspect_s8_binary.c buf_inspect_s8_decimal.c buf_inspect_s8_hexadecimal.c buf_inspect_s8_octal.c buf_inspect_sw.c buf_inspect_sw_binary.c buf_inspect_sw_decimal.c buf_inspect_sw_hexadecimal.c buf_inspect_sw_octal.c buf_inspect_u16.c buf_inspect_u16_binary.c buf_inspect_u16_decimal.c buf_inspect_u16_hexadecimal.c buf_inspect_u16_octal.c buf_inspect_u32.c buf_inspect_u32_binary.c buf_inspect_u32_decimal.c buf_inspect_u32_hexadecimal.c buf_inspect_u32_octal.c buf_inspect_u64.c buf_inspect_u64_binary.c buf_inspect_u64_decimal.c buf_inspect_u64_hexadecimal.c buf_inspect_u64_octal.c buf_inspect_u8.c buf_inspect_u8_binary.c buf_inspect_u8_decimal.c buf_inspect_u8_hexadecimal.c buf_inspect_u8_octal.c buf_inspect_uw.c buf_inspect_uw_binary.c buf_inspect_uw_decimal.c buf_inspect_uw_hexadecimal.c buf_inspect_uw_octal.c buf_parse.c buf_parse_s16.c buf_parse_s32.c buf_parse_s64.c buf_parse_s8.c buf_parse_sw.c buf_parse_u16.c buf_parse_u32.c buf_parse_u64.c buf_parse_u8.c buf_parse_uw.c buf_save.c c3.c call.c ceiling.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c f32.c f64.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c file.c fn.c fn_clause.c frame.c hash.c ident.c integer.c io.c license.c list.c log.c map.c module.c operator.c ptag.c quote.c s16.c s32.c s64.c s8.c sequence.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c sign.c skiplist__fact.c skiplist_node__fact.c str.c sw.c sym.c tag.c tag_add.c tag_band.c tag_bor.c tag_bxor.c tag_mod.c tag_mul.c tag_shift_left.c tag_shift_right.c tag_sub.c time.c tuple.c type.c u16.c u32.c u64.c u8.c ucd.c uw.c var.c ../libtommath/bn_cutoffs.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_double.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_rand_platform.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
diff --git a/libc3/sym.c b/libc3/sym.c
index 447b0f2..8d457db 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -14,12 +14,7 @@
#include <err.h>
#include <stdlib.h>
#include <string.h>
-#include "buf.h"
-#include "buf_inspect.h"
-#include "character.h"
-#include "compare.h"
-#include "str.h"
-#include "sym.h"
+#include "c3.h"
void sym_delete (s_sym *sym);
s_str * sym_inspect_reserved (const s_sym *sym, s_str *dest);
@@ -153,6 +148,128 @@ const s_sym * sym_new (const s_str *src)
return sym;
}
+f_buf_inspect sym_to_buf_inspect (const s_sym *type)
+{
+ if (type == sym_1("Bool"))
+ return (f_buf_inspect) buf_inspect_bool;
+ if (type == sym_1("Call"))
+ return (f_buf_inspect) buf_inspect_call;
+ if (type == sym_1("Cfn"))
+ return (f_buf_inspect) buf_inspect_cfn;
+ if (type == sym_1("Character"))
+ return (f_buf_inspect) buf_inspect_character;
+ if (type == sym_1("F32"))
+ return (f_buf_inspect) buf_inspect_f32;
+ if (type == sym_1("F64"))
+ return (f_buf_inspect) buf_inspect_f64;
+ if (type == sym_1("Fact"))
+ return (f_buf_inspect) buf_inspect_fact;
+ if (type == sym_1("Fn"))
+ return (f_buf_inspect) buf_inspect_fn;
+ if (type == sym_1("Ident"))
+ return (f_buf_inspect) buf_inspect_ident;
+ if (type == sym_1("Integer"))
+ return (f_buf_inspect) buf_inspect_integer;
+ if (type == sym_1("Sw"))
+ return (f_buf_inspect) buf_inspect_sw;
+ if (type == sym_1("S64"))
+ return (f_buf_inspect) buf_inspect_s64;
+ if (type == sym_1("S32"))
+ return (f_buf_inspect) buf_inspect_s32;
+ if (type == sym_1("S16"))
+ return (f_buf_inspect) buf_inspect_s16;
+ if (type == sym_1("S8"))
+ return (f_buf_inspect) buf_inspect_s8;
+ if (type == sym_1("U8"))
+ return (f_buf_inspect) buf_inspect_u8;
+ if (type == sym_1("U16"))
+ return (f_buf_inspect) buf_inspect_u16;
+ if (type == sym_1("U32"))
+ return (f_buf_inspect) buf_inspect_u32;
+ if (type == sym_1("U64"))
+ return (f_buf_inspect) buf_inspect_u64;
+ if (type == sym_1("Uw"))
+ return (f_buf_inspect) buf_inspect_uw;
+ if (type == sym_1("List"))
+ return (f_buf_inspect) buf_inspect_list;
+ if (type == sym_1("Ptag"))
+ return (f_buf_inspect) buf_inspect_ptag;
+ if (type == sym_1("Quote"))
+ return (f_buf_inspect) buf_inspect_quote;
+ if (type == sym_1("Str"))
+ return (f_buf_inspect) buf_inspect_str;
+ if (type == sym_1("Sym"))
+ return (f_buf_inspect) buf_inspect_sym;
+ if (type == sym_1("Tuple"))
+ return (f_buf_inspect) buf_inspect_tuple;
+ if (type == sym_1("Var"))
+ return (f_buf_inspect) buf_inspect_var;
+ assert(! "sym_to_buf_inspect: unknown type");
+ errx(1, "sym_to_buf_inspect: unknown type");
+ return NULL;
+}
+
+f_buf_inspect_size sym_to_buf_inspect_size (const s_sym *type)
+{
+ if (type == sym_1("Bool"))
+ return (f_buf_inspect_size) buf_inspect_bool_size;
+ if (type == sym_1("Call"))
+ return (f_buf_inspect_size) buf_inspect_call_size;
+ if (type == sym_1("Cfn"))
+ return (f_buf_inspect_size) buf_inspect_cfn_size;
+ if (type == sym_1("Character"))
+ return (f_buf_inspect_size) buf_inspect_character_size;
+ if (type == sym_1("F32"))
+ return (f_buf_inspect_size) buf_inspect_f32_size;
+ if (type == sym_1("F64"))
+ return (f_buf_inspect_size) buf_inspect_f64_size;
+ if (type == sym_1("Fact"))
+ return (f_buf_inspect_size) buf_inspect_fact_size;
+ if (type == sym_1("Fn"))
+ return (f_buf_inspect_size) buf_inspect_fn_size;
+ if (type == sym_1("Ident"))
+ return (f_buf_inspect_size) buf_inspect_ident_size;
+ if (type == sym_1("Integer"))
+ return (f_buf_inspect_size) buf_inspect_integer_size;
+ if (type == sym_1("Sw"))
+ return (f_buf_inspect_size) buf_inspect_sw_size;
+ if (type == sym_1("S64"))
+ return (f_buf_inspect_size) buf_inspect_s64_size;
+ if (type == sym_1("S32"))
+ return (f_buf_inspect_size) buf_inspect_s32_size;
+ if (type == sym_1("S16"))
+ return (f_buf_inspect_size) buf_inspect_s16_size;
+ if (type == sym_1("S8"))
+ return (f_buf_inspect_size) buf_inspect_s8_size;
+ if (type == sym_1("U8"))
+ return (f_buf_inspect_size) buf_inspect_u8_size;
+ if (type == sym_1("U16"))
+ return (f_buf_inspect_size) buf_inspect_u16_size;
+ if (type == sym_1("U32"))
+ return (f_buf_inspect_size) buf_inspect_u32_size;
+ if (type == sym_1("U64"))
+ return (f_buf_inspect_size) buf_inspect_u64_size;
+ if (type == sym_1("Uw"))
+ return (f_buf_inspect_size) buf_inspect_uw_size;
+ if (type == sym_1("List"))
+ return (f_buf_inspect_size) buf_inspect_list_size;
+ if (type == sym_1("Ptag"))
+ return (f_buf_inspect_size) buf_inspect_ptag_size;
+ if (type == sym_1("Quote"))
+ return (f_buf_inspect_size) buf_inspect_quote_size;
+ if (type == sym_1("Str"))
+ return (f_buf_inspect_size) buf_inspect_str_size;
+ if (type == sym_1("Sym"))
+ return (f_buf_inspect_size) buf_inspect_sym_size;
+ if (type == sym_1("Tuple"))
+ return (f_buf_inspect_size) buf_inspect_tuple_size;
+ if (type == sym_1("Var"))
+ return (f_buf_inspect_size) buf_inspect_var_size;
+ assert(! "sym_to_buf_inspect: unknown type");
+ errx(1, "sym_to_buf_inspect: unknown type");
+ return NULL;
+}
+
ffi_type * sym_to_ffi_type (const s_sym *sym, ffi_type *result_type)
{
assert(sym);
@@ -224,6 +341,67 @@ ffi_type * sym_to_ffi_type (const s_sym *sym, ffi_type *result_type)
return NULL;
}
+f_init_copy sym_to_init_copy (const s_sym *type)
+{
+ if (type == sym_1("Bool"))
+ return (f_init_copy) bool_init_copy;
+ if (type == sym_1("Call"))
+ return (f_init_copy) call_init_copy;
+ if (type == sym_1("Cfn"))
+ return (f_init_copy) cfn_init_copy;
+ if (type == sym_1("Character"))
+ return (f_init_copy) character_init_copy;
+ if (type == sym_1("F32"))
+ return (f_init_copy) f32_init_copy;
+ if (type == sym_1("F64"))
+ return (f_init_copy) f64_init_copy;
+ if (type == sym_1("Fact"))
+ return (f_init_copy) fact_init_copy;
+ if (type == sym_1("Fn"))
+ return (f_init_copy) fn_init_copy;
+ if (type == sym_1("Ident"))
+ return (f_init_copy) ident_init_copy;
+ if (type == sym_1("Integer"))
+ return (f_init_copy) integer_init_copy;
+ if (type == sym_1("List"))
+ return (f_init_copy) list_init_copy;
+ if (type == sym_1("Sw"))
+ return (f_init_copy) sw_init_copy;
+ if (type == sym_1("S64"))
+ return (f_init_copy) s64_init_copy;
+ if (type == sym_1("S32"))
+ return (f_init_copy) s32_init_copy;
+ if (type == sym_1("S16"))
+ return (f_init_copy) s16_init_copy;
+ if (type == sym_1("S8"))
+ return (f_init_copy) s8_init_copy;
+ if (type == sym_1("U8"))
+ return (f_init_copy) u8_init_copy;
+ if (type == sym_1("U16"))
+ return (f_init_copy) u16_init_copy;
+ if (type == sym_1("U32"))
+ return (f_init_copy) u32_init_copy;
+ if (type == sym_1("U64"))
+ return (f_init_copy) u64_init_copy;
+ if (type == sym_1("Uw"))
+ return (f_init_copy) uw_init_copy;
+ if (type == sym_1("Ptag"))
+ return (f_init_copy) ptag_init_copy;
+ if (type == sym_1("Quote"))
+ return (f_init_copy) quote_init_copy;
+ if (type == sym_1("Str"))
+ return (f_init_copy) str_init_copy;
+ if (type == sym_1("Sym"))
+ return (f_init_copy) sym_init_copy;
+ if (type == sym_1("Tuple"))
+ return (f_init_copy) tuple_init_copy;
+ if (type == sym_1("Var"))
+ return (f_init_copy) var_init_copy;
+ assert(! "sym_to_init_copy: unknown type");
+ errx(1, "sym_to_init_copy: unknown type");
+ return NULL;
+}
+
bool sym_to_tag_type (const s_sym *sym, e_tag_type *dest)
{
if (sym->str.ptr.ps8[sym->str.size - 2] == '*') {
@@ -369,3 +547,64 @@ bool sym_to_tag_type (const s_sym *sym, e_tag_type *dest)
assert(! "sym_to_tag_type: unknown type");
return false;
}
+
+uw sym_type_size (const s_sym *type)
+{
+ if (type == sym_1("Bool"))
+ return sizeof(bool);
+ if (type == sym_1("Call"))
+ return sizeof(s_call);
+ if (type == sym_1("Cfn"))
+ return sizeof(s_cfn);
+ if (type == sym_1("Character"))
+ return sizeof(character);
+ if (type == sym_1("F32"))
+ return sizeof(f32);
+ if (type == sym_1("F64"))
+ return sizeof(f64);
+ if (type == sym_1("Fact"))
+ return sizeof(s_fact);
+ if (type == sym_1("Fn"))
+ return sizeof(s_fn);
+ if (type == sym_1("Ident"))
+ return sizeof(s_ident);
+ if (type == sym_1("Integer"))
+ return sizeof(s_integer);
+ if (type == sym_1("Sw"))
+ return sizeof(sw);
+ if (type == sym_1("S64"))
+ return sizeof(s64);
+ if (type == sym_1("S32"))
+ return sizeof(s32);
+ if (type == sym_1("S16"))
+ return sizeof(s16);
+ if (type == sym_1("S8"))
+ return sizeof(s8);
+ if (type == sym_1("U8"))
+ return sizeof(u8);
+ if (type == sym_1("U16"))
+ return sizeof(u16);
+ if (type == sym_1("U32"))
+ return sizeof(u32);
+ if (type == sym_1("U64"))
+ return sizeof(u64);
+ if (type == sym_1("Uw"))
+ return sizeof(uw);
+ if (type == sym_1("List"))
+ return sizeof(s_list *);
+ if (type == sym_1("Ptag"))
+ return sizeof(p_tag);
+ if (type == sym_1("Quote"))
+ return sizeof(s_quote);
+ if (type == sym_1("Str"))
+ return sizeof(s_str);
+ if (type == sym_1("Sym"))
+ return sizeof(s_sym *);
+ if (type == sym_1("Tuple"))
+ return sizeof(s_tuple);
+ if (type == sym_1("Var"))
+ return sizeof(s_tag);
+ assert(! "sym_type_size: unknown type");
+ errx(1, "sym_type_size: unknown type: %s", type->str.ptr.ps8);
+ return 0;
+}
diff --git a/libc3/sym.h b/libc3/sym.h
index 348d88c..47e8e70 100644
--- a/libc3/sym.h
+++ b/libc3/sym.h
@@ -26,33 +26,27 @@
#define SYM_MAX 1024
-/** @brief Make symbol from C string.
- * @sa str_to_sym
- */
-const s_sym * sym_1 (const s8 *p);
-
-bool sym_character_is_reserved (character c);
-
+const s_sym * sym_1 (const s8 *p);
const s_sym ** sym_init_copy (const s_sym **sym,
const s_sym * const *src);
-/** @brief Call when exiting program. */
-void sym_delete_all (void);
-
-/** @brief Find an existing symbol. */
-const s_sym * sym_find (const s_str *src);
-
-bool sym_has_reserved_characters (const s_sym *sym);
-
-s_str * sym_inspect (const s_sym *sym, s_str *dest);
-
-/** @brief True iff sym is a module name (starts with a capital). */
-bool sym_is_module (const s_sym *sym);
+/* Heap-allocation functions, call sym_delete_all at exit. */
+void sym_delete_all (void);
const s_sym * sym_new (const s_str *src);
-ffi_type * sym_to_ffi_type (const s_sym *sym, ffi_type *result_type);
-
-bool sym_to_tag_type (const s_sym *sym, e_tag_type *dest);
+/* Observers */
+bool sym_character_is_reserved (character c);
+const s_sym * sym_find (const s_str *src);
+bool sym_has_reserved_characters (const s_sym *sym);
+s_str * sym_inspect (const s_sym *sym, s_str *dest);
+bool sym_is_module (const s_sym *sym);
+f_buf_inspect sym_to_buf_inspect (const s_sym *type);
+f_buf_inspect_size sym_to_buf_inspect_size (const s_sym *type);
+ffi_type * sym_to_ffi_type (const s_sym *sym,
+ ffi_type *result_type);
+f_init_copy sym_to_init_copy (const s_sym *type);
+bool sym_to_tag_type (const s_sym *sym, e_tag_type *dest);
+uw sym_type_size (const s_sym *type);
#endif /* LIBC3_SYM_H */
diff --git a/libc3/tag.c b/libc3/tag.c
index 6be160a..98a19a2 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -58,12 +58,12 @@ bool * tag_and (const s_tag *a, const s_tag *b, bool *dest)
return dest;
}
-s_tag * tag_array (s_tag *tag, const s_array *a)
+s_tag * tag_array (s_tag *tag, const s_sym *type, uw dimension,
+ const uw *dimensions)
{
assert(tag);
- assert(a);
tag_clean(tag);
- return tag_init_array(tag, a);
+ return tag_init_array(tag, type, dimension, dimensions);
}
s_tag * tag_bnot (const s_tag *tag, s_tag *result)
@@ -879,12 +879,12 @@ s_tag * tag_init_1 (s_tag *tag, const s8 *p)
return tag;
}
-s_tag * tag_init_array (s_tag *tag, const s_array *a)
+s_tag * tag_init_array (s_tag *tag, const s_sym *type,
+ uw dimension, const uw *dimensions)
{
assert(tag);
- assert(a);
tag->type = TAG_ARRAY;
- array_init_copy(&tag->data.array, a);
+ array_init(&tag->data.array, type, dimension, dimensions);
return tag;
}
@@ -1338,3136 +1338,211 @@ bool * tag_lte (const s_tag *a, const s_tag *b, bool *dest)
*dest = compare_tag(a, b) <= 0 ? 1 : 0;
return dest;
}
+s_tag * tag_map (s_tag *tag, uw count)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_map(tag, count);
+}
+
+s_tag * tag_map_1 (s_tag *tag, const s8 *p)
+{
+ assert(tag);
+ assert(p);
+ tag_clean(tag);
+ return tag_init_map_1(tag, p);
+}
-s_tag * tag_mod (const s_tag *a, const s_tag *b, s_tag *dest)
+
+s_tag * tag_neg (const s_tag *tag, s_tag *result)
{
s_integer tmp;
- s_integer tmp2;
- assert(a);
- assert(b);
- assert(dest);
- switch (a->type) {
- case TAG_F32:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, fmodf(a->data.f32, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.f32, b->data.f64));
- case TAG_INTEGER:
- return tag_init_f64(dest, fmod((f64) a->data.f32,
- integer_to_f64(&b->data.integer)));
- case TAG_S8:
- return tag_init_f32(dest, fmodf(a->data.f32, (f32) b->data.s8));
- case TAG_S16:
- return tag_init_f32(dest, fmodf(a->data.f32, (f32) b->data.s16));
- case TAG_S32:
- return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.s32));
- case TAG_S64:
- return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.s64));
- case TAG_SW:
- return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.sw));
- case TAG_U8:
- return tag_init_f32(dest, fmodf(a->data.f32, (f32) b->data.u8));
- case TAG_U16:
- return tag_init_f32(dest, fmodf(a->data.f32, (f32) b->data.u16));
- case TAG_U32:
- return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.u32));
- case TAG_U64:
- return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.u64));
- case TAG_UW:
- return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.uw));
- default:
- goto ko;
- }
- case TAG_F64:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod(a->data.f64, b->data.f64));
- case TAG_INTEGER:
- return tag_init_f64(dest, fmod(a->data.f64,
- integer_to_f64(&b->data.integer)));
- case TAG_S8:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.s8));
- case TAG_S16:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.s16));
- case TAG_S32:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.s32));
- case TAG_S64:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.s64));
- case TAG_SW:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.sw));
- case TAG_U8:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.u8));
- case TAG_U16:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.u16));
- case TAG_U32:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.u32));
- case TAG_U64:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.u64));
- case TAG_UW:
- return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.uw));
- default:
- goto ko;
- }
+ switch (tag->type) {
+ case TAG_BOOL:
+ return tag_init_s8(result, -(tag->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_s64(result, -tag->data.character);
case TAG_INTEGER:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, fmod(integer_to_f64(&a->data.integer),
- (f64) b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod(integer_to_f64(&a->data.integer),
- b->data.f64));
- case TAG_INTEGER:
- dest->type = TAG_INTEGER;
- integer_mod(&a->data.integer, &b->data.integer,
- &dest->data.integer);
- return dest;
- case TAG_S8:
- integer_init_s8(&tmp, b->data.s8);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_s8(dest, integer_to_s8(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S16:
- integer_init_s16(&tmp, b->data.s16);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_s16(dest, integer_to_s16(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S32:
- integer_init_s32(&tmp, b->data.s32);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_s32(dest, integer_to_s32(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S64:
- integer_init_s64(&tmp, b->data.s64);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_s64(dest, integer_to_s64(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_SW:
- integer_init_sw(&tmp, b->data.sw);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_sw(dest, integer_to_sw(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- integer_init_u8(&tmp, b->data.u8);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_u8(dest, integer_to_u8(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U16:
- integer_init_u16(&tmp, b->data.u16);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_u16(dest, integer_to_u16(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U32:
- integer_init_u32(&tmp, b->data.u32);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_u32(dest, integer_to_u32(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U64:
- integer_init_u64(&tmp, b->data.u64);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_u64(dest, integer_to_u64(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_UW:
- integer_init_uw(&tmp, b->data.uw);
- integer_mod(&a->data.integer, &tmp, &tmp2);
- tag_init_uw(dest, integer_to_uw(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S8:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, fmodf((f32) a->data.s8, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.s8, b->data.f64));
- case TAG_INTEGER:
- integer_init_s8(&tmp, a->data.s8);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s8(dest, a->data.s8 % b->data.s8);
- case TAG_S16:
- return tag_init_s8(dest, a->data.s8 % b->data.s16);
- case TAG_S32:
- return tag_init_s8(dest, a->data.s8 % b->data.s32);
- case TAG_S64:
- return tag_init_s8(dest, a->data.s8 % b->data.s64);
- case TAG_SW:
- return tag_init_s8(dest, a->data.s8 % b->data.sw);
- case TAG_U8: {
- s16 i = a->data.s8 % (s16) b->data.u8;
- if (i < 0)
- i += b->data.u8;
- return tag_init_u8(dest, i);
- }
- case TAG_U16: {
- s32 i = a->data.s8 % (s32) b->data.u16;
- if (i < 0)
- i += b->data.u16;
- return tag_init_u16(dest, i);
- }
- case TAG_U32: {
- s64 i = a->data.s8 % (s64) b->data.u32;
- if (i < 0)
- i += b->data.u32;
- return tag_init_u32(dest, i);
- }
- case TAG_U64:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_UW:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S16:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, fmodf((f32) a->data.s16, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.s16, b->data.f64));
- case TAG_INTEGER:
- integer_init_s16(&tmp, a->data.s16);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s8(dest, a->data.s16 % b->data.s8);
- case TAG_S16:
- return tag_init_s16(dest, a->data.s16 % b->data.s16);
- case TAG_S32:
- return tag_init_s16(dest, a->data.s16 % b->data.s32);
- case TAG_S64:
- return tag_init_s16(dest, a->data.s16 % b->data.s64);
- case TAG_SW:
- return tag_init_s16(dest, a->data.s16 % b->data.sw);
- case TAG_U8: {
- s16 i = a->data.s16 % (s16) b->data.u8;
- if (i < 0)
- i += b->data.u8;
- return tag_init_u8(dest, i);
- }
- case TAG_U16: {
- s32 i = a->data.s16 % (s32) b->data.u16;
- if (i < 0)
- i += b->data.u16;
- return tag_init_u16(dest, i);
- }
- case TAG_U32: {
- s64 i = a->data.s16 % (s64) b->data.u32;
- if (i < 0)
- i += b->data.u32;
- return tag_init_u32(dest, i);
- }
- case TAG_U64:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_UW:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S32:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, fmod((f64) a->data.s32, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.s32, b->data.f64));
- case TAG_INTEGER:
- integer_init_s32(&tmp, a->data.s32);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s8(dest, a->data.s32 % b->data.s8);
- case TAG_S16:
- return tag_init_s16(dest, a->data.s32 % b->data.s16);
- case TAG_S32:
- return tag_init_s32(dest, a->data.s32 % b->data.s32);
- case TAG_S64:
- return tag_init_s64(dest, a->data.s32 % b->data.s64);
- case TAG_SW:
- return tag_init_sw(dest, a->data.s32 % b->data.sw);
- case TAG_U8: {
- s16 i = a->data.s32 % (s16) b->data.u8;
- if (i < 0)
- i += b->data.u8;
- return tag_init_u8(dest, i);
- }
- case TAG_U16: {
- s32 i = a->data.s32 % (s32) b->data.u16;
- if (i < 0)
- i += b->data.u16;
- return tag_init_u16(dest, i);
- }
- case TAG_U32: {
- s64 i = a->data.s32 % (s64) b->data.u32;
- if (i < 0)
- i += b->data.u32;
- return tag_init_u32(dest, i);
- }
- case TAG_U64:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_UW:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S64:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, fmod((f64) a->data.s64, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.s64, b->data.f64));
- case TAG_INTEGER:
- integer_init_s64(&tmp, a->data.s64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s8(dest, a->data.s64 % b->data.s8);
- case TAG_S16:
- return tag_init_s16(dest, a->data.s64 % b->data.s16);
- case TAG_S32:
- return tag_init_s32(dest, a->data.s64 % b->data.s32);
- case TAG_S64:
- return tag_init_s64(dest, a->data.s64 % b->data.s64);
- case TAG_SW:
- return tag_init_sw(dest, a->data.s64 % b->data.sw);
- case TAG_U8: {
- s16 i = a->data.s64 % b->data.u8;
- if (i < 0)
- i += b->data.u8;
- return tag_init_u8(dest, i);
- }
- case TAG_U16: {
- s32 i = a->data.s64 % b->data.u16;
- if (i < 0)
- i += b->data.u16;
- return tag_init_u16(dest, i);
- }
- case TAG_U32: {
- s64 i = a->data.s64 % b->data.u32;
- if (i < 0)
- i += b->data.u32;
- return tag_init_u32(dest, i);
- }
- case TAG_U64:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_UW:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
+ result->type = TAG_INTEGER;
+ integer_neg(&tag->data.integer, &result->data.integer);
+ return result;
case TAG_SW:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, fmod((f64) a->data.sw, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.sw, b->data.f64));
- case TAG_INTEGER:
- integer_init_sw(&tmp, a->data.sw);
- integer_mod(&tmp, &b->data.integer, &tmp2);
- tag_init_sw(dest, integer_to_sw(&tmp2));
+ if (tag->data.sw == SW_MIN) {
+ integer_init_sw(&tmp, tag->data.sw);
+ result->type = TAG_INTEGER;
+ integer_neg(&tmp, &result->data.integer);
integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S8:
- return tag_init_s8(dest, a->data.sw % b->data.s8);
- case TAG_S16:
- return tag_init_s16(dest, a->data.sw % b->data.s16);
- case TAG_S32:
- return tag_init_s32(dest, a->data.sw % b->data.s32);
- case TAG_S64:
- return tag_init_sw(dest, a->data.sw % b->data.s64);
- case TAG_SW:
- return tag_init_sw(dest, a->data.sw % b->data.sw);
- case TAG_U8: {
- s16 i = a->data.sw % b->data.u8;
- if (i < 0)
- i += b->data.u8;
- return tag_init_u8(dest, i);
- }
- case TAG_U16: {
- s32 i = a->data.sw % b->data.u16;
- if (i < 0)
- i += b->data.u16;
- return tag_init_u16(dest, i);
- }
- case TAG_U32: {
- s64 i = a->data.sw % b->data.u32;
- if (i < 0)
- i += b->data.u32;
- return tag_init_u32(dest, i);
+ return result;
}
- case TAG_U64:
- integer_init_sw(&tmp, a->data.sw);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_UW:
- integer_init_sw(&tmp, a->data.sw);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
+ return tag_init_sw(result, -tag->data.sw);
+ case TAG_S64:
+ if (tag->data.s64 == S64_MIN) {
+ integer_init_s64(&tmp, tag->data.s64);
+ result->type = TAG_INTEGER;
+ integer_neg(&tmp, &result->data.integer);
integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
+ return result;
}
+ return tag_init_s64(result, -tag->data.s64);
+ case TAG_S32:
+ return tag_init_s64(result, - (s64) tag->data.s32);
+ case TAG_S16:
+ return tag_init_s32(result, - (s32) tag->data.s16);
+ case TAG_S8:
+ return tag_init_s16(result, - (s16) tag->data.s8);
case TAG_U8:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, fmodf((f32) a->data.u8, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.u8, b->data.f64));
- case TAG_INTEGER:
- integer_init_u8(&tmp, a->data.u8);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8: {
- s16 i = a->data.u8 % b->data.s8;
- if (b->data.s8 < 0 && i > 0)
- i += b->data.s8;
- return tag_init_s8(dest, i);
- }
- case TAG_S16: {
- s32 i = a->data.u8 % b->data.s16;
- if (b->data.s16 < 0 && i > 0)
- i += b->data.s16;
- return tag_init_s16(dest, i);
- }
- case TAG_S32: {
- s64 i = a->data.u8 % b->data.s32;
- if (b->data.s32 < 0 && i > 0)
- i += b->data.s32;
- return tag_init_s32(dest, i);
- }
- case TAG_S64:
- integer_init_u8(&tmp, a->data.u8);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_SW:
- integer_init_u8(&tmp, a->data.u8);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_u8(dest, a->data.u8 % b->data.u8);
- case TAG_U16:
- return tag_init_u8(dest, a->data.u8 % b->data.u16);
- case TAG_U32:
- return tag_init_u8(dest, a->data.u8 % b->data.u32);
- case TAG_U64:
- return tag_init_u8(dest, a->data.u8 % b->data.u64);
- case TAG_UW:
- return tag_init_u8(dest, a->data.u8 % b->data.uw);
- default:
- goto ko;
- }
- case TAG_U16:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, fmodf((f32) a->data.u16, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.u16, b->data.f64));
- case TAG_INTEGER:
- integer_init_u16(&tmp, a->data.u16);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8: {
- s16 i = a->data.u16 % b->data.s8;
- if (b->data.s8 < 0 && i > 0)
- i += b->data.s8;
- return tag_init_s8(dest, i);
- }
- case TAG_S16: {
- s32 i = a->data.u16 % b->data.s16;
- if (b->data.s16 < 0 && i > 0)
- i += b->data.s16;
- return tag_init_s16(dest, i);
- }
- case TAG_S32: {
- s64 i = a->data.u16 % b->data.s32;
- if (b->data.s32 < 0 && i > 0)
- i += b->data.s32;
- return tag_init_s32(dest, i);
- }
- case TAG_S64:
- integer_init_u16(&tmp, a->data.u16);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_SW:
- integer_init_u16(&tmp, a->data.u16);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_u8(dest, a->data.u16 % b->data.u8);
- case TAG_U16:
- return tag_init_u16(dest, a->data.u16 % b->data.u16);
- case TAG_U32:
- return tag_init_u16(dest, a->data.u16 % b->data.u32);
- case TAG_U64:
- return tag_init_u16(dest, a->data.u16 % b->data.u64);
- case TAG_UW:
- return tag_init_u16(dest, a->data.u16 % b->data.uw);
- default:
- goto ko;
- }
- case TAG_U32:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, fmod((f64) a->data.u32, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.u32, b->data.f64));
- case TAG_INTEGER:
- integer_init_u32(&tmp, a->data.u32);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8: {
- s64 i = a->data.u32 % (s64) b->data.s8;
- if (b->data.s8 < 0 && i > 0)
- i += b->data.s8;
- return tag_init_s8(dest, i);
- }
- case TAG_S16: {
- s64 i = a->data.u32 % (s64) b->data.s16;
- if (b->data.s16 < 0 && i > 0)
- i += b->data.s16;
- return tag_init_s16(dest, i);
- }
- case TAG_S32: {
- s64 i = a->data.u32 % (s64) b->data.s32;
- if (b->data.s32 < 0 && i > 0)
- i += b->data.s32;
- return tag_init_s32(dest, i);
- }
- case TAG_S64:
- integer_init_u32(&tmp, a->data.u32);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_SW:
- integer_init_u32(&tmp, a->data.u32);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_u8(dest, a->data.u32 % b->data.u8);
- case TAG_U16:
- return tag_init_u16(dest, a->data.u32 % b->data.u16);
- case TAG_U32:
- return tag_init_u32(dest, a->data.u32 % b->data.u32);
- case TAG_U64:
- return tag_init_u32(dest, a->data.u32 % b->data.u64);
- case TAG_UW:
- return tag_init_u32(dest, a->data.u32 % b->data.uw);
- default:
- goto ko;
- }
- case TAG_U64:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, fmod((f64) a->data.u64, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.u64, b->data.f64));
- case TAG_INTEGER:
- integer_init_u64(&tmp, a->data.u64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s8(&tmp2, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S16:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s16(&tmp2, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S32:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s32(&tmp2, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S64:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_SW:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_u8(dest, a->data.u64 % b->data.u8);
- case TAG_U16:
- return tag_init_u16(dest, a->data.u64 % b->data.u16);
- case TAG_U32:
- return tag_init_u32(dest, a->data.u64 % b->data.u32);
- case TAG_U64:
- return tag_init_u64(dest, a->data.u64 % b->data.u64);
- case TAG_UW:
- return tag_init_uw(dest, a->data.u64 % b->data.uw);
- default:
- goto ko;
- }
- case TAG_UW:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, fmod((f64) a->data.uw, b->data.f32));
- case TAG_F64:
- return tag_init_f64(dest, fmod((f64) a->data.uw, b->data.f64));
- case TAG_INTEGER:
- integer_init_uw(&tmp, a->data.uw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- integer_init_uw(&tmp, a->data.uw);
- integer_init_s8(&tmp2, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S16:
- integer_init_uw(&tmp, a->data.uw);
- integer_init_s16(&tmp2, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S32:
- integer_init_uw(&tmp, a->data.uw);
- integer_init_s32(&tmp2, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S64:
- integer_init_uw(&tmp, a->data.uw);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_SW:
- integer_init_uw(&tmp, a->data.uw);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_mod(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_u8(dest, a->data.uw % b->data.u8);
- case TAG_U16:
- return tag_init_u16(dest, a->data.uw % b->data.u16);
- case TAG_U32:
- return tag_init_u32(dest, a->data.uw % b->data.u32);
- case TAG_U64:
- return tag_init_uw(dest, a->data.uw % b->data.u64);
- case TAG_UW:
- return tag_init_uw(dest, a->data.uw % b->data.uw);
- default:
- goto ko;
- }
- default:
- goto ko;
- }
- ko:
- errx(1, "cannot divide %s by %s",
- tag_type_to_string(a->type),
- tag_type_to_string(b->type));
-}
-
-s_tag * tag_mul (const s_tag *a, const s_tag *b, s_tag *dest)
-{
- s_integer tmp;
- s_integer tmp2;
- assert(a);
- assert(b);
- assert(dest);
- switch (a->type) {
- case TAG_F32:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.f32 * b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.f32 * b->data.f64);
- case TAG_INTEGER:
- return tag_init_f32(dest, a->data.f32 *
- integer_to_f32(&b->data.integer));
- case TAG_S8:
- return tag_init_f32(dest, a->data.f32 * (f32) b->data.s8);
- case TAG_S16:
- return tag_init_f32(dest, a->data.f32 * (f32) b->data.s16);
- case TAG_S32:
- return tag_init_f32(dest, a->data.f32 * (f32) b->data.s32);
- case TAG_S64:
- return tag_init_f32(dest, a->data.f32 * (f32) b->data.s64);
- case TAG_U8:
- return tag_init_f32(dest, a->data.f32 * (f32) b->data.u8);
- case TAG_U16:
- return tag_init_f32(dest, a->data.f32 * (f32) b->data.u16);
- case TAG_U32:
- return tag_init_f32(dest, a->data.f32 * (f32) b->data.u32);
- case TAG_U64:
- return tag_init_f32(dest, a->data.f32 * (f32) b->data.u64);
- default:
- goto ko;
- }
- case TAG_F64:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, a->data.f64 * (f64) b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.f64 * b->data.f64);
- case TAG_INTEGER:
- return tag_init_f64(dest, a->data.f64 *
- integer_to_f64(&b->data.integer));
- case TAG_S8:
- return tag_init_f64(dest, a->data.f64 * (f64) b->data.s8);
- case TAG_S16:
- return tag_init_f64(dest, a->data.f64 * (f64) b->data.s16);
- case TAG_S32:
- return tag_init_f64(dest, a->data.f64 * (f64) b->data.s32);
- case TAG_S64:
- return tag_init_f64(dest, a->data.f64 * (f64) b->data.s64);
- case TAG_U8:
- return tag_init_f64(dest, a->data.f64 * (f64) b->data.u8);
- case TAG_U16:
- return tag_init_f64(dest, a->data.f64 * (f64) b->data.u16);
- case TAG_U32:
- return tag_init_f64(dest, a->data.f64 * (f64) b->data.u32);
- case TAG_U64:
- return tag_init_f64(dest, a->data.f64 * (f64) b->data.u64);
- default:
- goto ko;
- }
- case TAG_INTEGER:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, integer_to_f32(&a->data.integer) *
- b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, integer_to_f64(&a->data.integer) *
- b->data.f64);
- case TAG_INTEGER:
- dest->type = TAG_INTEGER;
- integer_mul(&a->data.integer, &b->data.integer,
- &dest->data.integer);
- return dest;
- case TAG_S8:
- integer_init_s8(&tmp, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_mul(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S16:
- integer_init_s16(&tmp, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_mul(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S32:
- integer_init_s32(&tmp, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_mul(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S64:
- integer_init_s64(&tmp, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_U8:
- integer_init_u8(&tmp, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_mul(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_U16:
- integer_init_u16(&tmp, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_mul(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_U32:
- integer_init_u32(&tmp, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_mul(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_U64:
- integer_init_u64(&tmp, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- default:
- goto ko;
- }
- case TAG_S8:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) a->data.s8 * b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.s8 * b->data.f64);
- case TAG_INTEGER:
- integer_init_s8(&tmp, a->data.s8);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s16(dest, (s16) a->data.s8 * (s16) b->data.s8);
- case TAG_S16:
- return tag_init_s32(dest, (s32) a->data.s8 * (s32) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.s8 * (s64) b->data.s32);
- case TAG_S64:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_s16(dest, (s16) a->data.s8 * (s16) b->data.u8);
- case TAG_U16:
- return tag_init_s32(dest, (s32) a->data.s8 * (s32) b->data.u16);
- case TAG_U32:
- return tag_init_s64(dest, (s64) a->data.s8 * (s64) b->data.u32);
- case TAG_U64:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S16:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) a->data.s16 * b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.s16 * b->data.f64);
- case TAG_INTEGER:
- integer_init_s16(&tmp, a->data.s16);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s32(dest, (s32) a->data.s16 * (s32) b->data.s8);
- case TAG_S16:
- return tag_init_s32(dest, (s32) a->data.s16 * (s32) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.s16 * (s64) b->data.s32);
- case TAG_S64:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_s32(dest, (s32) a->data.s16 * (s32) b->data.u8);
- case TAG_U16:
- return tag_init_s32(dest, (s32) a->data.s16 * (s32) b->data.u16);
- case TAG_U32:
- return tag_init_s64(dest, (s64) a->data.s16 * (s64) b->data.u32);
- case TAG_U64:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S32:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) a->data.s32 * b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.s32 * b->data.f64);
- case TAG_INTEGER:
- integer_init_s32(&tmp, a->data.s32);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.s8);
- case TAG_S16:
- return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.s32);
- case TAG_S64:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.u8);
- case TAG_U16:
- return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.u16);
- case TAG_U32:
- return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.u32);
- case TAG_U64:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S64:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) a->data.s64 * b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.s64 * b->data.f64);
- case TAG_INTEGER:
- integer_init_s64(&tmp, a->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s8(&tmp2, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S16:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s16(&tmp2, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S32:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s32(&tmp2, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S64:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u8(&tmp2, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U16:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u16(&tmp2, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U32:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u32(&tmp2, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U64:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_U8:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) a->data.u8 * b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.u8 * b->data.f64);
- case TAG_INTEGER:
- integer_init_u8(&tmp, a->data.u8);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s16(dest, (s16) a->data.u8 * (s16) b->data.s8);
- case TAG_S16:
- return tag_init_s32(dest, (s32) a->data.u8 * (s32) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s32) a->data.u8 * (s64) b->data.s32);
- case TAG_S64:
- integer_init_u8(&tmp, a->data.u8);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_u16(dest, (u16) a->data.u8 * (u16) b->data.u8);
- case TAG_U16:
- return tag_init_u32(dest, (u32) a->data.u8 * (u32) b->data.u16);
- case TAG_U32:
- return tag_init_u64(dest, (u64) a->data.u8 * (u64) b->data.u32);
- case TAG_U64:
- integer_init_u8(&tmp, a->data.u8);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_U16:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) a->data.u16 * b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.u16 * b->data.f64);
- case TAG_INTEGER:
- integer_init_u16(&tmp, a->data.u16);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s32(dest, (s32) a->data.u16 * (s32) b->data.s8);
- case TAG_S16:
- return tag_init_s32(dest, (s32) a->data.u16 * (s32) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.u16 * (s64) b->data.s32);
- case TAG_S64:
- integer_init_u16(&tmp, a->data.u16);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_u32(dest, (u32) a->data.u16 * (u32) b->data.u8);
- case TAG_U16:
- return tag_init_u32(dest, (u32) a->data.u16 * (u32) b->data.u16);
- case TAG_U32:
- return tag_init_u64(dest, (u64) a->data.u16 * (u64) b->data.u32);
- case TAG_U64:
- integer_init_u16(&tmp, a->data.u16);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_U32:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) a->data.u32 * b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.u32 * b->data.f64);
- case TAG_INTEGER:
- integer_init_u32(&tmp, a->data.u32);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s64(dest, (s64) a->data.u32 * (s64) b->data.s8);
- case TAG_S16:
- return tag_init_s64(dest, (s64) a->data.u32 * (s64) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.u32 * b->data.s32);
- case TAG_S64:
- integer_init_u32(&tmp, a->data.u32);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_u64(dest, (u64) a->data.u32 * (u64) b->data.u8);
- case TAG_U16:
- return tag_init_u64(dest, (u64) a->data.u32 * (u64) b->data.u16);
- case TAG_U32:
- return tag_init_u64(dest, (u64) a->data.u32 * (u64) b->data.u32);
- case TAG_U64:
- integer_init_u32(&tmp, a->data.u32);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_U64:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) a->data.u64 * b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.u64 * b->data.f64);
- case TAG_INTEGER:
- integer_init_u64(&tmp, a->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s8(&tmp2, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S16:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s16(&tmp2, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S32:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s32(&tmp2, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S64:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u8(&tmp2, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U16:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u16(&tmp2, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U32:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u32(&tmp2, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U64:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_mul(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- default:
- goto ko;
- }
- ko:
- errx(1, "cannot multiply %s by %s",
- tag_type_to_string(a->type),
- tag_type_to_string(b->type));
-}
-
-s_tag * tag_neg (const s_tag *tag, s_tag *result)
-{
- s_integer tmp;
- switch (tag->type) {
- case TAG_BOOL:
- return tag_init_s8(result, -(tag->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_s64(result, -tag->data.character);
- case TAG_INTEGER:
- result->type = TAG_INTEGER;
- integer_neg(&tag->data.integer, &result->data.integer);
- return result;
- case TAG_SW:
- if (tag->data.sw == SW_MIN) {
- integer_init_sw(&tmp, tag->data.sw);
- result->type = TAG_INTEGER;
- integer_neg(&tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- }
- return tag_init_sw(result, -tag->data.sw);
- case TAG_S64:
- if (tag->data.s64 == S64_MIN) {
- integer_init_s64(&tmp, tag->data.s64);
- result->type = TAG_INTEGER;
- integer_neg(&tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- }
- return tag_init_s64(result, -tag->data.s64);
- case TAG_S32:
- return tag_init_s64(result, - (s64) tag->data.s32);
- case TAG_S16:
- return tag_init_s32(result, - (s32) tag->data.s16);
- case TAG_S8:
- return tag_init_s16(result, - (s16) tag->data.s8);
- case TAG_U8:
- return tag_init_s16(result, - (s16) tag->data.u8);
- case TAG_U16:
- return tag_init_s32(result, - (s32) tag->data.u16);
- case TAG_U32:
- return tag_init_s64(result, - (s64) tag->data.u32);
- case TAG_U64:
- integer_init_u64(&tmp, tag->data.u64);
- result->type = TAG_INTEGER;
- integer_neg(&tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_UW:
- integer_init_uw(&tmp, tag->data.uw);
- result->type = TAG_INTEGER;
- integer_neg(&tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- default:
- warnx("tag_neg: invalid tag type: %s",
- tag_type_to_string(tag->type));
- }
- return NULL;
-}
-
-s_tag * tag_new (void)
-{
- s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- return tag;
-}
-
-s_tag * tag_new_1 (const s8 *p)
-{
- s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- return tag_init_1(tag, p);
-}
-
-s_tag * tag_new_array (const s_array *a)
-{
- s_tag *dest;
- assert(a);
- if (! (dest = malloc(sizeof(s_tag))))
- errx(1, "tag_new_array: out of memory");
- return tag_init_array(dest, a);
-}
-
-s_tag * tag_new_copy (const s_tag *src)
-{
- s_tag *dest;
- if (! (dest = malloc(sizeof(s_tag))))
- errx(1, "tag_new_copy: out of memory");
- return tag_init_copy(dest, src);
-}
-
-s_tag * tag_new_var (void)
-{
- s_tag *tag;
- tag = calloc(1, sizeof(s_tag));
- return tag_init_var(tag);
-}
-
-bool * tag_not (const s_tag *tag, bool *dest)
-{
- s_tag f;
- assert(tag);
- assert(dest);
- tag_init_bool(&f, false);
- *dest = compare_tag(tag, &f) == 0 ? 1 : 0;
- return dest;
-}
-
-bool * tag_not_eq (const s_tag *a, const s_tag *b, bool *dest)
-{
- assert(a);
- assert(b);
- assert(dest);
- *dest = compare_tag(a, b) != 0 ? 1 : 0;
- return dest;
-}
-
-bool * tag_or (const s_tag *a, const s_tag *b, bool *dest)
-{
- s_tag f;
- assert(a);
- assert(b);
- assert(dest);
- tag_init_bool(&f, false);
- *dest = compare_tag(a, &f) != 0 || compare_tag(b, &f) != 0 ? 1 : 0;
- return dest;
-}
-
-s_tag * tag_paren (const s_tag *tag, s_tag *dest)
-{
- assert(tag);
- assert(dest);
- return tag_init_copy(dest, tag);
-}
-
-s_tag * tag_s8 (s_tag *tag, s8 x)
-{
- assert(tag);
- tag_clean(tag);
- return tag_init_s8(tag, x);
-}
-
-s_tag * tag_s16 (s_tag *tag, s16 x)
-{
- assert(tag);
- tag_clean(tag);
- return tag_init_s16(tag, x);
-}
-
-s_tag * tag_s32 (s_tag *tag, s32 x)
-{
- assert(tag);
- tag_clean(tag);
- return tag_init_s32(tag, x);
-}
-
-s_tag * tag_s64 (s_tag *tag, s64 x)
-{
- assert(tag);
- tag_clean(tag);
- return tag_init_s64(tag, x);
-}
-
-s_tag * tag_shift_left (const s_tag *a, const s_tag *b, s_tag *result)
-{
- s_integer tmp;
- s_integer tmp2;
- s_tag tmp_a;
- switch (a->type) {
- case TAG_BOOL:
- tmp_a.data.bool = a->data.bool ? 1 : 0;
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_bool(result, tmp_a.data.bool <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_bool(result, tmp_a.data.bool << b->data.character);
- case TAG_INTEGER:
- integer_init_u8(&tmp, tmp_a.data.bool);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_bool(result, integer_to_u8(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_bool(result, tmp_a.data.bool << b->data.sw);
- case TAG_S64:
- return tag_init_bool(result, tmp_a.data.bool << b->data.s64);
- case TAG_S32:
- return tag_init_bool(result, tmp_a.data.bool << b->data.s32);
- case TAG_S16:
- return tag_init_bool(result, tmp_a.data.bool << b->data.s16);
- case TAG_S8:
- return tag_init_bool(result, tmp_a.data.bool << b->data.s8);
- case TAG_U8:
- return tag_init_bool(result, tmp_a.data.bool << b->data.u8);
- case TAG_U16:
- return tag_init_bool(result, tmp_a.data.bool << b->data.u16);
- case TAG_U32:
- return tag_init_bool(result, tmp_a.data.bool << b->data.u32);
- case TAG_U64:
- return tag_init_bool(result, tmp_a.data.bool << b->data.u64);
- case TAG_UW:
- return tag_init_bool(result, tmp_a.data.bool << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_CHARACTER:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_character(result, a->data.character <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_character(result, a->data.character << b->data.character);
- case TAG_INTEGER:
- integer_init_u32(&tmp, a->data.character);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_character(result, integer_to_u32(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_character(result, a->data.character << b->data.sw);
- case TAG_S64:
- return tag_init_character(result, a->data.character << b->data.s64);
- case TAG_S32:
- return tag_init_character(result, a->data.character << b->data.s32);
- case TAG_S16:
- return tag_init_character(result, a->data.character << b->data.s16);
- case TAG_S8:
- return tag_init_character(result, a->data.character << b->data.s8);
- case TAG_U8:
- return tag_init_character(result, a->data.character << b->data.u8);
- case TAG_U16:
- return tag_init_character(result, a->data.character << b->data.u16);
- case TAG_U32:
- return tag_init_character(result, a->data.character << b->data.u32);
- case TAG_U64:
- return tag_init_character(result, a->data.character << b->data.u64);
- case TAG_UW:
- return tag_init_character(result, a->data.character << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_INTEGER:
- switch (b->type) {
- case TAG_BOOL:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.bool ? 1 : 0,
- &result->data.integer);
- return result;
- case TAG_CHARACTER:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.character,
- &result->data.integer);
- return result;
- case TAG_INTEGER:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, integer_to_sw(&b->data.integer),
- &result->data.integer);
- return result;
- case TAG_SW:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.sw,
- &result->data.integer);
- return result;
- case TAG_S64:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.s64, &result->data.integer);
- return result;
- case TAG_S32:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.s32, &result->data.integer);
- return result;
- case TAG_S16:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.s16, &result->data.integer);
- return result;
- case TAG_S8:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.s8, &result->data.integer);
- return result;
- case TAG_U8:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.u8, &result->data.integer);
- return result;
- case TAG_U16:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.u16, &result->data.integer);
- return result;
- case TAG_U32:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.u32, &result->data.integer);
- return result;
- case TAG_U64:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.u64, &result->data.integer);
- return result;
- case TAG_UW:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.uw, &result->data.integer);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_SW:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_sw(result, a->data.sw <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_sw(result, a->data.sw << b->data.character);
- case TAG_INTEGER:
- integer_init_sw(&tmp, a->data.sw);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_sw(result, integer_to_sw(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_sw(result, a->data.sw << b->data.sw);
- case TAG_S64:
- return tag_init_sw(result, a->data.sw << b->data.s64);
- case TAG_S32:
- return tag_init_sw(result, a->data.sw << b->data.s32);
- case TAG_S16:
- return tag_init_sw(result, a->data.sw << b->data.s16);
- case TAG_S8:
- return tag_init_sw(result, a->data.sw << b->data.s8);
- case TAG_U8:
- return tag_init_sw(result, a->data.sw << b->data.u8);
- case TAG_U16:
- return tag_init_sw(result, a->data.sw << b->data.u16);
- case TAG_U32:
- return tag_init_sw(result, a->data.sw << b->data.u32);
- case TAG_U64:
- return tag_init_sw(result, a->data.sw << b->data.u64);
- case TAG_UW:
- return tag_init_sw(result, a->data.sw << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_S64:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_s64(result, a->data.s64 <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_s64(result, a->data.s64 << b->data.character);
- case TAG_INTEGER:
- integer_init_s64(&tmp, a->data.s64);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_s64(result, integer_to_s64(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_s64(result, a->data.s64 << b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, a->data.s64 << b->data.s64);
- case TAG_S32:
- return tag_init_s64(result, a->data.s64 << b->data.s32);
- case TAG_S16:
- return tag_init_s64(result, a->data.s64 << b->data.s16);
- case TAG_S8:
- return tag_init_s64(result, a->data.s64 << b->data.s8);
- case TAG_U8:
- return tag_init_s64(result, a->data.s64 << b->data.u8);
- case TAG_U16:
- return tag_init_s64(result, a->data.s64 << b->data.u16);
- case TAG_U32:
- return tag_init_s64(result, a->data.s64 << b->data.u32);
- case TAG_U64:
- return tag_init_s64(result, a->data.s64 << b->data.u64);
- case TAG_UW:
- return tag_init_s64(result, a->data.s64 << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_S32:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_s32(result, a->data.s32 <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_s32(result, a->data.s32 << b->data.character);
- case TAG_INTEGER:
- integer_init_s32(&tmp, a->data.s32);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_s32(result, integer_to_s32(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_s32(result, a->data.s32 << b->data.sw);
- case TAG_S64:
- return tag_init_s32(result, a->data.s32 << b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, a->data.s32 << b->data.s32);
- case TAG_S16:
- return tag_init_s32(result, a->data.s32 << b->data.s16);
- case TAG_S8:
- return tag_init_s32(result, a->data.s32 << b->data.s8);
- case TAG_U8:
- return tag_init_s32(result, a->data.s32 << b->data.u8);
- case TAG_U16:
- return tag_init_s32(result, a->data.s32 << b->data.u16);
- case TAG_U32:
- return tag_init_s32(result, a->data.s32 << b->data.u32);
- case TAG_U64:
- return tag_init_s32(result, a->data.s32 << b->data.u64);
- case TAG_UW:
- return tag_init_s32(result, a->data.s32 << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_S16:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_s16(result, a->data.s16 <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_s16(result, a->data.s16 << b->data.character);
- case TAG_INTEGER:
- integer_init_s16(&tmp, a->data.s16);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_s16(result, integer_to_s16(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_s16(result, a->data.s16 << b->data.sw);
- case TAG_S64:
- return tag_init_s16(result, a->data.s16 << b->data.s64);
- case TAG_S32:
- return tag_init_s16(result, a->data.s16 << b->data.s32);
- case TAG_S16:
- return tag_init_s16(result, a->data.s16 << b->data.s16);
- case TAG_S8:
- return tag_init_s16(result, a->data.s16 << b->data.s8);
- case TAG_U8:
- return tag_init_s16(result, a->data.s16 << b->data.u8);
- case TAG_U16:
- return tag_init_s16(result, a->data.s16 << b->data.u16);
- case TAG_U32:
- return tag_init_s16(result, a->data.s16 << b->data.u32);
- case TAG_U64:
- return tag_init_s16(result, a->data.s16 << b->data.u64);
- case TAG_UW:
- return tag_init_s16(result, a->data.s16 << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_S8:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_s8(result, a->data.s8 <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_s8(result, a->data.s8 << b->data.character);
- case TAG_INTEGER:
- integer_init_s8(&tmp, a->data.s8);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_s8(result, integer_to_s8(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_s8(result, a->data.s8 << b->data.sw);
- case TAG_S64:
- return tag_init_s8(result, a->data.s8 << b->data.s64);
- case TAG_S32:
- return tag_init_s8(result, a->data.s8 << b->data.s32);
- case TAG_S16:
- return tag_init_s8(result, a->data.s8 << b->data.s16);
- case TAG_S8:
- return tag_init_s8(result, a->data.s8 << b->data.s8);
- case TAG_U8:
- return tag_init_s8(result, a->data.s8 << b->data.u8);
- case TAG_U16:
- return tag_init_s8(result, a->data.s8 << b->data.u16);
- case TAG_U32:
- return tag_init_s8(result, a->data.s8 << b->data.u32);
- case TAG_U64:
- return tag_init_s8(result, a->data.s8 << b->data.u64);
- case TAG_UW:
- return tag_init_s8(result, a->data.s8 << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_U8:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_u8(result, a->data.u8 <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_u8(result, a->data.u8 << b->data.character);
- case TAG_INTEGER:
- integer_init_u8(&tmp, a->data.u8);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_u8(result, integer_to_u8(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_u8(result, a->data.u8 << b->data.sw);
- case TAG_S64:
- return tag_init_u8(result, a->data.u8 << b->data.s64);
- case TAG_S32:
- return tag_init_u8(result, a->data.u8 << b->data.s32);
- case TAG_S16:
- return tag_init_u8(result, a->data.u8 << b->data.s16);
- case TAG_S8:
- return tag_init_u8(result, a->data.u8 << b->data.s8);
- case TAG_U8:
- return tag_init_u8(result, a->data.u8 << b->data.u8);
- case TAG_U16:
- return tag_init_u8(result, a->data.u8 << b->data.u16);
- case TAG_U32:
- return tag_init_u8(result, a->data.u8 << b->data.u32);
- case TAG_U64:
- return tag_init_u8(result, a->data.u8 << b->data.u64);
- case TAG_UW:
- return tag_init_u8(result, a->data.u8 << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_U16:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_u16(result, a->data.u16 <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_u16(result, a->data.u16 << b->data.character);
- case TAG_INTEGER:
- integer_init_u16(&tmp, a->data.u16);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_u16(result, integer_to_u16(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_u16(result, a->data.u16 << b->data.sw);
- case TAG_S64:
- return tag_init_u16(result, a->data.u16 << b->data.s64);
- case TAG_S32:
- return tag_init_u16(result, a->data.u16 << b->data.s32);
- case TAG_S16:
- return tag_init_u16(result, a->data.u16 << b->data.s16);
- case TAG_S8:
- return tag_init_u16(result, a->data.u16 << b->data.s8);
- case TAG_U8:
- return tag_init_u16(result, a->data.u16 << b->data.u8);
- case TAG_U16:
- return tag_init_u16(result, a->data.u16 << b->data.u16);
- case TAG_U32:
- return tag_init_u16(result, a->data.u16 << b->data.u32);
- case TAG_U64:
- return tag_init_u16(result, a->data.u16 << b->data.u64);
- case TAG_UW:
- return tag_init_u16(result, a->data.u16 << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_U32:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_u32(result, a->data.u32 <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_u32(result, a->data.u32 << b->data.character);
- case TAG_INTEGER:
- integer_init_u32(&tmp, a->data.u32);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_u32(result, integer_to_u32(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_u32(result, a->data.u32 << b->data.sw);
- case TAG_S64:
- return tag_init_u32(result, a->data.u32 << b->data.s64);
- case TAG_S32:
- return tag_init_u32(result, a->data.u32 << b->data.s32);
- case TAG_S16:
- return tag_init_u32(result, a->data.u32 << b->data.s16);
- case TAG_S8:
- return tag_init_u32(result, a->data.u32 << b->data.s8);
- case TAG_U8:
- return tag_init_u32(result, a->data.u32 << b->data.u8);
- case TAG_U16:
- return tag_init_u32(result, a->data.u32 << b->data.u16);
- case TAG_U32:
- return tag_init_u32(result, a->data.u32 << b->data.u32);
- case TAG_U64:
- return tag_init_u32(result, a->data.u32 << b->data.u64);
- case TAG_UW:
- return tag_init_u32(result, a->data.u32 << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_U64:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_u64(result, a->data.u64 <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_u64(result, a->data.u64 << b->data.character);
- case TAG_INTEGER:
- integer_init_u64(&tmp, a->data.u64);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_u64(result, integer_to_u64(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_u64(result, a->data.u64 << b->data.sw);
- case TAG_S64:
- return tag_init_u64(result, a->data.u64 << b->data.s64);
- case TAG_S32:
- return tag_init_u64(result, a->data.u64 << b->data.s32);
- case TAG_S16:
- return tag_init_u64(result, a->data.u64 << b->data.s16);
- case TAG_S8:
- return tag_init_u64(result, a->data.u64 << b->data.s8);
- case TAG_U8:
- return tag_init_u64(result, a->data.u64 << b->data.u8);
- case TAG_U16:
- return tag_init_u64(result, a->data.u64 << b->data.u16);
- case TAG_U32:
- return tag_init_u64(result, a->data.u64 << b->data.u32);
- case TAG_U64:
- return tag_init_u64(result, a->data.u64 << b->data.u64);
- case TAG_UW:
- return tag_init_u64(result, a->data.u64 << b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_UW:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_uw(result, a->data.uw <<
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_uw(result, a->data.uw << b->data.character);
- case TAG_INTEGER:
- integer_init_uw(&tmp, a->data.uw);
- integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
- tag_init_uw(result, integer_to_uw(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_uw(result, a->data.uw << b->data.sw);
- case TAG_S64:
- return tag_init_uw(result, a->data.uw << b->data.s64);
- case TAG_S32:
- return tag_init_uw(result, a->data.uw << b->data.s32);
- case TAG_S16:
- return tag_init_uw(result, a->data.uw << b->data.s16);
- case TAG_S8:
- return tag_init_uw(result, a->data.uw << b->data.s8);
- case TAG_U8:
- return tag_init_uw(result, a->data.uw << b->data.u8);
- case TAG_U16:
- return tag_init_uw(result, a->data.uw << b->data.u16);
- case TAG_U32:
- return tag_init_uw(result, a->data.uw << b->data.u32);
- case TAG_U64:
- return tag_init_uw(result, a->data.uw << b->data.u64);
- case TAG_UW:
- return tag_init_uw(result, a->data.uw << b->data.uw);
- default:
- goto error;
- }
- goto error;
- default:
- goto error;
- }
- error:
- warnx("tag_shift_left: invalid tag type: %s << %s",
- tag_type_to_string(a->type),
- tag_type_to_string(b->type));
- return NULL;
-}
-
-s_tag * tag_shift_right (const s_tag *a, const s_tag *b, s_tag *result)
-{
- s_integer tmp;
- s_integer tmp2;
- s_tag tmp_a;
- switch (a->type) {
- case TAG_BOOL:
- tmp_a.data.bool = a->data.bool ? 1 : 0;
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_bool(result, tmp_a.data.bool >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.character);
- case TAG_INTEGER:
- integer_init_u8(&tmp, tmp_a.data.bool);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_bool(result, integer_to_u8(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.sw);
- case TAG_S64:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.s64);
- case TAG_S32:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.s32);
- case TAG_S16:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.s16);
- case TAG_S8:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.s8);
- case TAG_U8:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.u8);
- case TAG_U16:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.u16);
- case TAG_U32:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.u32);
- case TAG_U64:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.u64);
- case TAG_UW:
- return tag_init_bool(result, tmp_a.data.bool >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_CHARACTER:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_character(result, a->data.character >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_character(result, a->data.character >> b->data.character);
- case TAG_INTEGER:
- integer_init_u32(&tmp, a->data.character);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_character(result, integer_to_u32(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_character(result, a->data.character >> b->data.sw);
- case TAG_S64:
- return tag_init_character(result, a->data.character >> b->data.s64);
- case TAG_S32:
- return tag_init_character(result, a->data.character >> b->data.s32);
- case TAG_S16:
- return tag_init_character(result, a->data.character >> b->data.s16);
- case TAG_S8:
- return tag_init_character(result, a->data.character >> b->data.s8);
- case TAG_U8:
- return tag_init_character(result, a->data.character >> b->data.u8);
- case TAG_U16:
- return tag_init_character(result, a->data.character >> b->data.u16);
- case TAG_U32:
- return tag_init_character(result, a->data.character >> b->data.u32);
- case TAG_U64:
- return tag_init_character(result, a->data.character >> b->data.u64);
- case TAG_UW:
- return tag_init_character(result, a->data.character >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_INTEGER:
- switch (b->type) {
- case TAG_BOOL:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, b->data.bool ? -1 : 0,
- &result->data.integer);
- return result;
- case TAG_CHARACTER:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.character,
- &result->data.integer);
- return result;
- case TAG_INTEGER:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -integer_to_sw(&b->data.integer),
- &result->data.integer);
- return result;
- case TAG_SW:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.sw,
- &result->data.integer);
- return result;
- case TAG_S64:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.s64, &result->data.integer);
- return result;
- case TAG_S32:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.s32, &result->data.integer);
- return result;
- case TAG_S16:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.s16, &result->data.integer);
- return result;
- case TAG_S8:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.s8, &result->data.integer);
- return result;
- case TAG_U8:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.u8, &result->data.integer);
- return result;
- case TAG_U16:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.u16, &result->data.integer);
- return result;
- case TAG_U32:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.u32, &result->data.integer);
- return result;
- case TAG_U64:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.u64, &result->data.integer);
- return result;
- case TAG_UW:
- result->type = TAG_INTEGER;
- integer_lshift(&a->data.integer, -b->data.uw, &result->data.integer);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_SW:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_sw(result, a->data.sw >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_sw(result, a->data.sw >> b->data.character);
- case TAG_INTEGER:
- integer_init_sw(&tmp, a->data.sw);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_sw(result, integer_to_sw(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_sw(result, a->data.sw >> b->data.sw);
- case TAG_S64:
- return tag_init_sw(result, a->data.sw >> b->data.s64);
- case TAG_S32:
- return tag_init_sw(result, a->data.sw >> b->data.s32);
- case TAG_S16:
- return tag_init_sw(result, a->data.sw >> b->data.s16);
- case TAG_S8:
- return tag_init_sw(result, a->data.sw >> b->data.s8);
- case TAG_U8:
- return tag_init_sw(result, a->data.sw >> b->data.u8);
- case TAG_U16:
- return tag_init_sw(result, a->data.sw >> b->data.u16);
- case TAG_U32:
- return tag_init_sw(result, a->data.sw >> b->data.u32);
- case TAG_U64:
- return tag_init_sw(result, a->data.sw >> b->data.u64);
- case TAG_UW:
- return tag_init_sw(result, a->data.sw >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_S64:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_s64(result, a->data.s64 >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_s64(result, a->data.s64 >> b->data.character);
- case TAG_INTEGER:
- integer_init_s64(&tmp, a->data.s64);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_s64(result, integer_to_s64(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_s64(result, a->data.s64 >> b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, a->data.s64 >> b->data.s64);
- case TAG_S32:
- return tag_init_s64(result, a->data.s64 >> b->data.s32);
- case TAG_S16:
- return tag_init_s64(result, a->data.s64 >> b->data.s16);
- case TAG_S8:
- return tag_init_s64(result, a->data.s64 >> b->data.s8);
- case TAG_U8:
- return tag_init_s64(result, a->data.s64 >> b->data.u8);
- case TAG_U16:
- return tag_init_s64(result, a->data.s64 >> b->data.u16);
- case TAG_U32:
- return tag_init_s64(result, a->data.s64 >> b->data.u32);
- case TAG_U64:
- return tag_init_s64(result, a->data.s64 >> b->data.u64);
- case TAG_UW:
- return tag_init_s64(result, a->data.s64 >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_S32:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_s32(result, a->data.s32 >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_s32(result, a->data.s32 >> b->data.character);
- case TAG_INTEGER:
- integer_init_s32(&tmp, a->data.s32);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_s32(result, integer_to_s32(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_s32(result, a->data.s32 >> b->data.sw);
- case TAG_S64:
- return tag_init_s32(result, a->data.s32 >> b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, a->data.s32 >> b->data.s32);
- case TAG_S16:
- return tag_init_s32(result, a->data.s32 >> b->data.s16);
- case TAG_S8:
- return tag_init_s32(result, a->data.s32 >> b->data.s8);
- case TAG_U8:
- return tag_init_s32(result, a->data.s32 >> b->data.u8);
- case TAG_U16:
- return tag_init_s32(result, a->data.s32 >> b->data.u16);
- case TAG_U32:
- return tag_init_s32(result, a->data.s32 >> b->data.u32);
- case TAG_U64:
- return tag_init_s32(result, a->data.s32 >> b->data.u64);
- case TAG_UW:
- return tag_init_s32(result, a->data.s32 >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_S16:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_s16(result, a->data.s16 >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_s16(result, a->data.s16 >> b->data.character);
- case TAG_INTEGER:
- integer_init_s16(&tmp, a->data.s16);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_s16(result, integer_to_s16(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_s16(result, a->data.s16 >> b->data.sw);
- case TAG_S64:
- return tag_init_s16(result, a->data.s16 >> b->data.s64);
- case TAG_S32:
- return tag_init_s16(result, a->data.s16 >> b->data.s32);
- case TAG_S16:
- return tag_init_s16(result, a->data.s16 >> b->data.s16);
- case TAG_S8:
- return tag_init_s16(result, a->data.s16 >> b->data.s8);
- case TAG_U8:
- return tag_init_s16(result, a->data.s16 >> b->data.u8);
- case TAG_U16:
- return tag_init_s16(result, a->data.s16 >> b->data.u16);
- case TAG_U32:
- return tag_init_s16(result, a->data.s16 >> b->data.u32);
- case TAG_U64:
- return tag_init_s16(result, a->data.s16 >> b->data.u64);
- case TAG_UW:
- return tag_init_s16(result, a->data.s16 >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_S8:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_s8(result, a->data.s8 >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_s8(result, a->data.s8 >> b->data.character);
- case TAG_INTEGER:
- integer_init_s8(&tmp, a->data.s8);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_s8(result, integer_to_s8(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_s8(result, a->data.s8 >> b->data.sw);
- case TAG_S64:
- return tag_init_s8(result, a->data.s8 >> b->data.s64);
- case TAG_S32:
- return tag_init_s8(result, a->data.s8 >> b->data.s32);
- case TAG_S16:
- return tag_init_s8(result, a->data.s8 >> b->data.s16);
- case TAG_S8:
- return tag_init_s8(result, a->data.s8 >> b->data.s8);
- case TAG_U8:
- return tag_init_s8(result, a->data.s8 >> b->data.u8);
- case TAG_U16:
- return tag_init_s8(result, a->data.s8 >> b->data.u16);
- case TAG_U32:
- return tag_init_s8(result, a->data.s8 >> b->data.u32);
- case TAG_U64:
- return tag_init_s8(result, a->data.s8 >> b->data.u64);
- case TAG_UW:
- return tag_init_s8(result, a->data.s8 >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_U8:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_u8(result, a->data.u8 >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_u8(result, a->data.u8 >> b->data.character);
- case TAG_INTEGER:
- integer_init_u8(&tmp, a->data.u8);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_u8(result, integer_to_u8(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_u8(result, a->data.u8 >> b->data.sw);
- case TAG_S64:
- return tag_init_u8(result, a->data.u8 >> b->data.s64);
- case TAG_S32:
- return tag_init_u8(result, a->data.u8 >> b->data.s32);
- case TAG_S16:
- return tag_init_u8(result, a->data.u8 >> b->data.s16);
- case TAG_S8:
- return tag_init_u8(result, a->data.u8 >> b->data.s8);
- case TAG_U8:
- return tag_init_u8(result, a->data.u8 >> b->data.u8);
- case TAG_U16:
- return tag_init_u8(result, a->data.u8 >> b->data.u16);
- case TAG_U32:
- return tag_init_u8(result, a->data.u8 >> b->data.u32);
- case TAG_U64:
- return tag_init_u8(result, a->data.u8 >> b->data.u64);
- case TAG_UW:
- return tag_init_u8(result, a->data.u8 >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_U16:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_u16(result, a->data.u16 >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_u16(result, a->data.u16 >> b->data.character);
- case TAG_INTEGER:
- integer_init_u16(&tmp, a->data.u16);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_u16(result, integer_to_u16(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_u16(result, a->data.u16 >> b->data.sw);
- case TAG_S64:
- return tag_init_u16(result, a->data.u16 >> b->data.s64);
- case TAG_S32:
- return tag_init_u16(result, a->data.u16 >> b->data.s32);
- case TAG_S16:
- return tag_init_u16(result, a->data.u16 >> b->data.s16);
- case TAG_S8:
- return tag_init_u16(result, a->data.u16 >> b->data.s8);
- case TAG_U8:
- return tag_init_u16(result, a->data.u16 >> b->data.u8);
- case TAG_U16:
- return tag_init_u16(result, a->data.u16 >> b->data.u16);
- case TAG_U32:
- return tag_init_u16(result, a->data.u16 >> b->data.u32);
- case TAG_U64:
- return tag_init_u16(result, a->data.u16 >> b->data.u64);
- case TAG_UW:
- return tag_init_u16(result, a->data.u16 >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_U32:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_u32(result, a->data.u32 >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_u32(result, a->data.u32 >> b->data.character);
- case TAG_INTEGER:
- integer_init_u32(&tmp, a->data.u32);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_u32(result, integer_to_u32(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_u32(result, a->data.u32 >> b->data.sw);
- case TAG_S64:
- return tag_init_u32(result, a->data.u32 >> b->data.s64);
- case TAG_S32:
- return tag_init_u32(result, a->data.u32 >> b->data.s32);
- case TAG_S16:
- return tag_init_u32(result, a->data.u32 >> b->data.s16);
- case TAG_S8:
- return tag_init_u32(result, a->data.u32 >> b->data.s8);
- case TAG_U8:
- return tag_init_u32(result, a->data.u32 >> b->data.u8);
- case TAG_U16:
- return tag_init_u32(result, a->data.u32 >> b->data.u16);
- case TAG_U32:
- return tag_init_u32(result, a->data.u32 >> b->data.u32);
- case TAG_U64:
- return tag_init_u32(result, a->data.u32 >> b->data.u64);
- case TAG_UW:
- return tag_init_u32(result, a->data.u32 >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_U64:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_u64(result, a->data.u64 >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_u64(result, a->data.u64 >> b->data.character);
- case TAG_INTEGER:
- integer_init_u64(&tmp, a->data.u64);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_u64(result, integer_to_u64(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_u64(result, a->data.u64 >> b->data.sw);
- case TAG_S64:
- return tag_init_u64(result, a->data.u64 >> b->data.s64);
- case TAG_S32:
- return tag_init_u64(result, a->data.u64 >> b->data.s32);
- case TAG_S16:
- return tag_init_u64(result, a->data.u64 >> b->data.s16);
- case TAG_S8:
- return tag_init_u64(result, a->data.u64 >> b->data.s8);
- case TAG_U8:
- return tag_init_u64(result, a->data.u64 >> b->data.u8);
- case TAG_U16:
- return tag_init_u64(result, a->data.u64 >> b->data.u16);
- case TAG_U32:
- return tag_init_u64(result, a->data.u64 >> b->data.u32);
- case TAG_U64:
- return tag_init_u64(result, a->data.u64 >> b->data.u64);
- case TAG_UW:
- return tag_init_u64(result, a->data.u64 >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- case TAG_UW:
- switch (b->type) {
- case TAG_BOOL:
- return tag_init_uw(result, a->data.uw >>
- (b->data.bool ? 1 : 0));
- case TAG_CHARACTER:
- return tag_init_uw(result, a->data.uw >> b->data.character);
- case TAG_INTEGER:
- integer_init_uw(&tmp, a->data.uw);
- integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
- tag_init_uw(result, integer_to_uw(&tmp2));
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_SW:
- return tag_init_uw(result, a->data.uw >> b->data.sw);
- case TAG_S64:
- return tag_init_uw(result, a->data.uw >> b->data.s64);
- case TAG_S32:
- return tag_init_uw(result, a->data.uw >> b->data.s32);
- case TAG_S16:
- return tag_init_uw(result, a->data.uw >> b->data.s16);
- case TAG_S8:
- return tag_init_uw(result, a->data.uw >> b->data.s8);
- case TAG_U8:
- return tag_init_uw(result, a->data.uw >> b->data.u8);
- case TAG_U16:
- return tag_init_uw(result, a->data.uw >> b->data.u16);
- case TAG_U32:
- return tag_init_uw(result, a->data.uw >> b->data.u32);
- case TAG_U64:
- return tag_init_uw(result, a->data.uw >> b->data.u64);
- case TAG_UW:
- return tag_init_uw(result, a->data.uw >> b->data.uw);
- default:
- goto error;
- }
- goto error;
- default:
- goto error;
- }
- error:
- warnx("tag_shift_right: invalid tag type: %s >> %s",
- tag_type_to_string(a->type),
- tag_type_to_string(b->type));
- return NULL;
-}
-
-s_tag * tag_sw (s_tag *tag, sw x)
-{
- assert(tag);
- tag_clean(tag);
- return tag_init_sw(tag, x);
-}
-
-s_tag * tag_str (s_tag *tag, s8 *free, uw size, const s8 *p)
-{
- assert(tag);
- tag_clean(tag);
- return tag_init_str(tag, free, size, p);
-}
-
-s_tag * tag_str_1 (s_tag *tag, s8 *free, const s8 *p)
-{
- assert(tag);
- tag_clean(tag);
- return tag_init_str_1(tag, free, p);
-}
-
-s_tag * tag_sub (const s_tag *a, const s_tag *b, s_tag *dest)
-{
- s_integer tmp;
- s_integer tmp2;
- assert(a);
- assert(b);
- assert(dest);
- switch (a->type) {
- case TAG_F32:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.f32 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.f32 - b->data.f64);
- case TAG_INTEGER:
- return tag_init_f32(dest, a->data.f32 -
- integer_to_f32(&b->data.integer));
- case TAG_S8:
- return tag_init_f32(dest, a->data.f32 - b->data.s8);
- case TAG_S16:
- return tag_init_f32(dest, a->data.f32 - b->data.s16);
- case TAG_S32:
- return tag_init_f32(dest, a->data.f32 - b->data.s32);
- case TAG_S64:
- return tag_init_f32(dest, a->data.f32 - b->data.s64);
- case TAG_U8:
- return tag_init_f32(dest, a->data.f32 - b->data.u8);
- case TAG_U16:
- return tag_init_f32(dest, a->data.f32 - b->data.u16);
- case TAG_U32:
- return tag_init_f32(dest, a->data.f32 - b->data.u32);
- case TAG_U64:
- return tag_init_f32(dest, a->data.f32 - b->data.u64);
- default:
- goto ko;
- }
- case TAG_F64:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f64(dest, a->data.f64 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.f64 - b->data.f64);
- case TAG_INTEGER:
- return tag_init_f64(dest, a->data.f64 -
- integer_to_f64(&b->data.integer));
- case TAG_S8:
- return tag_init_f64(dest, a->data.f64 - b->data.s8);
- case TAG_S16:
- return tag_init_f64(dest, a->data.f64 - b->data.s16);
- case TAG_S32:
- return tag_init_f64(dest, a->data.f64 - b->data.s32);
- case TAG_S64:
- return tag_init_f64(dest, a->data.f64 - b->data.s64);
- case TAG_U8:
- return tag_init_f64(dest, a->data.f64 - b->data.u8);
- case TAG_U16:
- return tag_init_f64(dest, a->data.f64 - b->data.u16);
- case TAG_U32:
- return tag_init_f64(dest, a->data.f64 - b->data.u32);
- case TAG_U64:
- return tag_init_f64(dest, a->data.f64 - b->data.u64);
- default:
- goto ko;
- }
- case TAG_INTEGER:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, integer_to_f64(&a->data.integer) -
- b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, integer_to_f64(&a->data.integer) -
- b->data.f64);
- case TAG_INTEGER:
- dest->type = TAG_INTEGER;
- integer_sub(&a->data.integer, &b->data.integer,
- &dest->data.integer);
- return dest;
- case TAG_S8:
- integer_init_s8(&tmp, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_sub(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S16:
- integer_init_s16(&tmp, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_sub(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S32:
- integer_init_s32(&tmp, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_sub(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S64:
- integer_init_s64(&tmp, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_U8:
- integer_init_u8(&tmp, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_sub(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_U16:
- integer_init_u16(&tmp, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_sub(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_U32:
- integer_init_u32(&tmp, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_sub(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_U64:
- integer_init_u64(&tmp, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- default:
- goto ko;
- }
- case TAG_S8:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.s8 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.s8 - b->data.f64);
- case TAG_INTEGER:
- integer_init_s8(&tmp, a->data.s8);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s16(dest, (s16) a->data.s8 - (s16) b->data.s8);
- case TAG_S16:
- return tag_init_s32(dest, (s32) a->data.s8 - (s32) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.s8 - (s64) b->data.s32);
- case TAG_S64:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_s16(dest, (s16) a->data.s8 - (s16) b->data.u8);
- case TAG_U16:
- return tag_init_s32(dest, (s32) a->data.s8 - (s32) b->data.u16);
- case TAG_U32:
- return tag_init_s64(dest, (s64) a->data.s8 - (s64) b->data.u32);
- case TAG_U64:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S16:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.s16 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.s16 - b->data.f64);
- case TAG_INTEGER:
- integer_init_s16(&tmp, a->data.s16);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s16(dest, a->data.s16 - b->data.s8);
- case TAG_S16:
- return tag_init_s16(dest, a->data.s16 - b->data.s16);
- case TAG_S32:
- return tag_init_s32(dest, a->data.s16 - b->data.s32);
- case TAG_S64:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_s32(dest, (s32) a->data.s16 - (s32) b->data.u8);
- case TAG_U16:
- return tag_init_s32(dest, (s32) a->data.s16 - (s32) b->data.u16);
- case TAG_U32:
- return tag_init_s64(dest, (s64) a->data.s16 - (s64) b->data.u32);
- case TAG_U64:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S32:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.s32 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.s32 - b->data.f64);
- case TAG_INTEGER:
- integer_init_s32(&tmp, a->data.s32);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.s8);
- case TAG_S16:
- return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.s32);
- case TAG_S64:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.u8);
- case TAG_U16:
- return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.u16);
- case TAG_U32:
- return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.u32);
- case TAG_U64:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_S64:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.s64 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.s64 - b->data.f64);
- case TAG_INTEGER:
- integer_init_s64(&tmp, a->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s8(&tmp2, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S16:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s16(&tmp2, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S32:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s32(&tmp2, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S64:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u8(&tmp2, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U16:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u16(&tmp2, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U32:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u32(&tmp2, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U64:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
- case TAG_U8:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.u8 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.u8 - b->data.f64);
- case TAG_INTEGER:
- integer_init_u8(&tmp, a->data.u8);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s16(dest, (s16) a->data.u8 - (s16) b->data.s8);
- case TAG_S16:
- return tag_init_s32(dest, (s32) a->data.u8 - (s32) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.u8 - (s64) b->data.s32);
- case TAG_S64:
- integer_init_u8(&tmp, a->data.u8);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_s16(dest, (s16) a->data.u8 - (s16) b->data.u8);
- case TAG_U16:
- return tag_init_s32(dest, (s32) a->data.u8 - (s32) b->data.u16);
- case TAG_U32:
- return tag_init_s64(dest, (s64) a->data.u8 - (s64) b->data.u32);
- case TAG_U64:
- integer_init_u8(&tmp, a->data.u8);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
+ return tag_init_s16(result, - (s16) tag->data.u8);
case TAG_U16:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.u16 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.u16 - b->data.f64);
- case TAG_INTEGER:
- integer_init_u16(&tmp, a->data.u16);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s32(dest, (s32) a->data.u16 - (s32) b->data.s8);
- case TAG_S16:
- return tag_init_s32(dest, (s32) a->data.u16 - (s32) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.u16 - (s64) b->data.s32);
- case TAG_S64:
- integer_init_u16(&tmp, a->data.u16);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_s32(dest, (s32) a->data.u16 - (s32) b->data.u8);
- case TAG_U16:
- return tag_init_s32(dest, (s32) a->data.u16 - (s32) b->data.u16);
- case TAG_U32:
- return tag_init_s64(dest, (s64) a->data.u16 - (s64) b->data.u32);
- case TAG_U64:
- integer_init_u16(&tmp, a->data.u16);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
+ return tag_init_s32(result, - (s32) tag->data.u16);
case TAG_U32:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.u32 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.u32 - b->data.f64);
- case TAG_INTEGER:
- integer_init_u32(&tmp, a->data.u32);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.s8);
- case TAG_S16:
- return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.s16);
- case TAG_S32:
- return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.s32);
- case TAG_S64:
- integer_init_u32(&tmp, a->data.u32);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.u8);
- case TAG_U16:
- return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.u16);
- case TAG_U32:
- return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.u32);
- case TAG_U64:
- integer_init_u32(&tmp, a->data.u32);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
+ return tag_init_s64(result, - (s64) tag->data.u32);
case TAG_U64:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, a->data.u64 - b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, a->data.u64 - b->data.f64);
- case TAG_INTEGER:
- integer_init_u64(&tmp, a->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s8(&tmp2, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S16:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s16(&tmp2, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S32:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s32(&tmp2, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_S64:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u8(&tmp2, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U16:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u16(&tmp2, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U32:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u32(&tmp2, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U64:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_sub(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- default:
- goto ko;
- }
+ integer_init_u64(&tmp, tag->data.u64);
+ result->type = TAG_INTEGER;
+ integer_neg(&tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_UW:
+ integer_init_uw(&tmp, tag->data.uw);
+ result->type = TAG_INTEGER;
+ integer_neg(&tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
default:
- goto ko;
+ warnx("tag_neg: invalid tag type: %s",
+ tag_type_to_string(tag->type));
}
- ko:
- errx(1, "cannot subtract %s by %s",
- tag_type_to_string(a->type),
- tag_type_to_string(b->type));
+ return NULL;
+}
+
+s_tag * tag_new (void)
+{
+ s_tag *tag;
+ tag = calloc(1, sizeof(s_tag));
+ return tag;
+}
+
+s_tag * tag_new_1 (const s8 *p)
+{
+ s_tag *tag;
+ tag = calloc(1, sizeof(s_tag));
+ return tag_init_1(tag, p);
+}
+
+s_tag * tag_new_array (const s_sym *type, uw dimension,
+ const uw *dimensions)
+{
+ s_tag *dest;
+ if (! (dest = malloc(sizeof(s_tag)))) {
+ warnx("tag_new_array: out of memory");
+ return NULL;
+ }
+ if (! tag_init_array(dest, type, dimension, dimensions)) {
+ free(dest);
+ return NULL;
+ }
+ return dest;
+}
+
+s_tag * tag_new_copy (const s_tag *src)
+{
+ s_tag *dest;
+ if (! (dest = malloc(sizeof(s_tag))))
+ errx(1, "tag_new_copy: out of memory");
+ return tag_init_copy(dest, src);
+}
+
+s_tag * tag_new_var (void)
+{
+ s_tag *tag;
+ tag = calloc(1, sizeof(s_tag));
+ return tag_init_var(tag);
+}
+
+bool * tag_not (const s_tag *tag, bool *dest)
+{
+ s_tag f;
+ assert(tag);
+ assert(dest);
+ tag_init_bool(&f, false);
+ *dest = compare_tag(tag, &f) == 0 ? 1 : 0;
+ return dest;
+}
+
+bool * tag_not_eq (const s_tag *a, const s_tag *b, bool *dest)
+{
+ assert(a);
+ assert(b);
+ assert(dest);
+ *dest = compare_tag(a, b) != 0 ? 1 : 0;
+ return dest;
+}
+
+bool * tag_or (const s_tag *a, const s_tag *b, bool *dest)
+{
+ s_tag f;
+ assert(a);
+ assert(b);
+ assert(dest);
+ tag_init_bool(&f, false);
+ *dest = compare_tag(a, &f) != 0 || compare_tag(b, &f) != 0 ? 1 : 0;
+ return dest;
+}
+
+s_tag * tag_paren (const s_tag *tag, s_tag *dest)
+{
+ assert(tag);
+ assert(dest);
+ return tag_init_copy(dest, tag);
+}
+
+s_tag * tag_s8 (s_tag *tag, s8 x)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_s8(tag, x);
+}
+
+s_tag * tag_s16 (s_tag *tag, s16 x)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_s16(tag, x);
+}
+
+s_tag * tag_s32 (s_tag *tag, s32 x)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_s32(tag, x);
+}
+
+s_tag * tag_s64 (s_tag *tag, s64 x)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_s64(tag, x);
+}
+
+s_tag * tag_sw (s_tag *tag, sw x)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_sw(tag, x);
+}
+
+s_tag * tag_str (s_tag *tag, s8 *free, uw size, const s8 *p)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_str(tag, free, size, p);
+}
+
+s_tag * tag_str_1 (s_tag *tag, s8 *free, const s8 *p)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_str_1(tag, free, p);
}
s_tag * tag_sym (s_tag *tag, const s_sym *x)
@@ -4747,6 +1822,20 @@ void * tag_to_pointer (s_tag *tag, const s_sym *type)
}
+s_tag * tag_tuple (s_tag *tag, uw count)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_tuple(tag, count);
+}
+
+s_tag * tag_tuple_2 (s_tag *tag, s_tag *a, s_tag *b)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_tuple_2(tag, a, b);
+}
+
const s_sym ** tag_type (const s_tag *tag, const s_sym **dest)
{
assert(tag);
diff --git a/libc3/tag.h b/libc3/tag.h
index 6fa3326..1127658 100644
--- a/libc3/tag.h
+++ b/libc3/tag.h
@@ -33,7 +33,8 @@ extern s_tag g_tag_last;
void tag_clean (s_tag *tag);
s_tag * tag_init (s_tag *tag);
s_tag * tag_init_1 (s_tag *tag, const s8 *p);
-s_tag * tag_init_array (s_tag *tag, const s_array *a);
+s_tag * tag_init_array (s_tag *tag, const s_sym *type, uw dimension,
+ const uw *dimensions);
s_tag * tag_init_bool (s_tag *tag, bool p);
s_tag * tag_init_call (s_tag *tag, const s_call *call);
s_tag * tag_init_character (s_tag *tag, character c);
@@ -74,7 +75,8 @@ s_tag * tag_init_uw (s_tag *tag, uw i);
/* Constructors, call tag_delete after use */
s_tag * tag_new (void);
s_tag * tag_new_1 (const s8 *p);
-s_tag * tag_new_array (const s_array *a);
+s_tag * tag_new_array (const s_sym *type, uw dimension,
+ const uw *dimensions);
s_tag * tag_new_bool (bool p);
s_tag * tag_new_character (character c);
s_tag * tag_new_copy (const s_tag *src);
@@ -119,41 +121,46 @@ s8 * tag_type_to_string (e_tag_type type);
const s_sym * tag_type_to_sym (e_tag_type tag_type);
/* Modifiers */
-s_tag * tag_1 (s_tag *tag, const s8 *p);
-s_tag * tag_array (s_tag *tag, const s_array *a);
-s_tag * tag_bool (s_tag *tag, bool p);
-s_tag * tag_cast_integer_to_s16 (s_tag *tag);
-s_tag * tag_cast_integer_to_s32 (s_tag *tag);
-s_tag * tag_cast_integer_to_s64 (s_tag *tag);
-s_tag * tag_cast_integer_to_s8 (s_tag *tag);
-s_tag * tag_cast_integer_to_u16 (s_tag *tag);
-s_tag * tag_cast_integer_to_u32 (s_tag *tag);
-s_tag * tag_cast_integer_to_u64 (s_tag *tag);
-s_tag * tag_cast_integer_to_u8 (s_tag *tag);
-s_tag * tag_character (s_tag *tag, character c);
-s_tag * tag_f32 (s_tag *tag, f32 f);
-s_tag * tag_f64 (s_tag *tag, f64 f);
-s_tag * tag_ident (s_tag *tag, const s_ident *ident);
-s_tag * tag_ident_1 (s_tag *tag, const s8 *p);
-s_tag * tag_integer (s_tag *tag, const s_integer *x);
-s_tag * tag_integer_1 (s_tag *tag, const s8 *p);
-s_tag * tag_integer_reduce (s_tag *tag);
-s_tag * tag_list (s_tag *tag, s_list *list);
-s_tag * tag_list_1 (s_tag *tag, const s8 *p);
-s_tag * tag_s16 (s_tag *tag, s16 i);
-s_tag * tag_s32 (s_tag *tag, s32 i);
-s_tag * tag_s64 (s_tag *tag, s64 i);
-s_tag * tag_s8 (s_tag *tag, s8 i);
-s_tag * tag_str (s_tag *tag, s8 *free, uw size, const s8 *p);
-s_tag * tag_str_1 (s_tag *tag, s8 *free, const s8 *p);
-s_tag * tag_sym (s_tag *tag, const s_sym *p);
-s_tag * tag_sym_1 (s_tag *tag, const s8 *p);
-s_tag * tag_u16 (s_tag *tag, u16 i);
-s_tag * tag_u32 (s_tag *tag, u32 i);
-s_tag * tag_u64 (s_tag *tag, u64 i);
-s_tag * tag_u8 (s_tag *tag, u8 i);
-s_tag * tag_var (s_tag *tag);
-s_tag * tag_void (s_tag *tag);
+s_tag * tag_1 (s_tag *tag, const s8 *p);
+s_tag * tag_array (s_tag *tag, const s_sym *type, uw dimension,
+ const uw *dimensions);
+s_tag * tag_bool (s_tag *tag, bool p);
+s_tag * tag_cast_integer_to_s16 (s_tag *tag);
+s_tag * tag_cast_integer_to_s32 (s_tag *tag);
+s_tag * tag_cast_integer_to_s64 (s_tag *tag);
+s_tag * tag_cast_integer_to_s8 (s_tag *tag);
+s_tag * tag_cast_integer_to_u16 (s_tag *tag);
+s_tag * tag_cast_integer_to_u32 (s_tag *tag);
+s_tag * tag_cast_integer_to_u64 (s_tag *tag);
+s_tag * tag_cast_integer_to_u8 (s_tag *tag);
+s_tag * tag_character (s_tag *tag, character c);
+s_tag * tag_f32 (s_tag *tag, f32 f);
+s_tag * tag_f64 (s_tag *tag, f64 f);
+s_tag * tag_ident (s_tag *tag, const s_ident *ident);
+s_tag * tag_ident_1 (s_tag *tag, const s8 *p);
+s_tag * tag_integer (s_tag *tag, const s_integer *x);
+s_tag * tag_integer_1 (s_tag *tag, const s8 *p);
+s_tag * tag_integer_reduce (s_tag *tag);
+s_tag * tag_list (s_tag *tag, s_list *list);
+s_tag * tag_list_1 (s_tag *tag, const s8 *p);
+s_tag * tag_map (s_tag *tag, uw count);
+s_tag * tag_map_1 (s_tag *tag, const s8 *p);
+s_tag * tag_s16 (s_tag *tag, s16 i);
+s_tag * tag_s32 (s_tag *tag, s32 i);
+s_tag * tag_s64 (s_tag *tag, s64 i);
+s_tag * tag_s8 (s_tag *tag, s8 i);
+s_tag * tag_str (s_tag *tag, s8 *free, uw size, const s8 *p);
+s_tag * tag_str_1 (s_tag *tag, s8 *free, const s8 *p);
+s_tag * tag_sym (s_tag *tag, const s_sym *p);
+s_tag * tag_sym_1 (s_tag *tag, const s8 *p);
+s_tag * tag_tuple (s_tag *tag, uw count);
+s_tag * tag_tuple_2 (s_tag *tag, s_tag *a, s_tag *b);
+s_tag * tag_u16 (s_tag *tag, u16 i);
+s_tag * tag_u32 (s_tag *tag, u32 i);
+s_tag * tag_u64 (s_tag *tag, u64 i);
+s_tag * tag_u8 (s_tag *tag, u8 i);
+s_tag * tag_var (s_tag *tag);
+s_tag * tag_void (s_tag *tag);
/* operators */
s_tag * tag_add (const s_tag *a, const s_tag *b, s_tag *dest);
diff --git a/libc3/tag_mod.c b/libc3/tag_mod.c
new file mode 100644
index 0000000..768d516
--- /dev/null
+++ b/libc3/tag_mod.c
@@ -0,0 +1,787 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <err.h>
+#include <math.h>
+#include "integer.h"
+#include "tag.h"
+
+s_tag * tag_mod (const s_tag *a, const s_tag *b, s_tag *dest)
+{
+ s_integer tmp;
+ s_integer tmp2;
+ assert(a);
+ assert(b);
+ assert(dest);
+ switch (a->type) {
+ case TAG_F32:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, fmodf(a->data.f32, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.f32, b->data.f64));
+ case TAG_INTEGER:
+ return tag_init_f64(dest, fmod((f64) a->data.f32,
+ integer_to_f64(&b->data.integer)));
+ case TAG_S8:
+ return tag_init_f32(dest, fmodf(a->data.f32, (f32) b->data.s8));
+ case TAG_S16:
+ return tag_init_f32(dest, fmodf(a->data.f32, (f32) b->data.s16));
+ case TAG_S32:
+ return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.s32));
+ case TAG_S64:
+ return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.s64));
+ case TAG_SW:
+ return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.sw));
+ case TAG_U8:
+ return tag_init_f32(dest, fmodf(a->data.f32, (f32) b->data.u8));
+ case TAG_U16:
+ return tag_init_f32(dest, fmodf(a->data.f32, (f32) b->data.u16));
+ case TAG_U32:
+ return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.u32));
+ case TAG_U64:
+ return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.u64));
+ case TAG_UW:
+ return tag_init_f64(dest, fmod((f64) a->data.f32, (f64) b->data.uw));
+ default:
+ goto ko;
+ }
+ case TAG_F64:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod(a->data.f64, b->data.f64));
+ case TAG_INTEGER:
+ return tag_init_f64(dest, fmod(a->data.f64,
+ integer_to_f64(&b->data.integer)));
+ case TAG_S8:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.s8));
+ case TAG_S16:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.s16));
+ case TAG_S32:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.s32));
+ case TAG_S64:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.s64));
+ case TAG_SW:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.sw));
+ case TAG_U8:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.u8));
+ case TAG_U16:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.u16));
+ case TAG_U32:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.u32));
+ case TAG_U64:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.u64));
+ case TAG_UW:
+ return tag_init_f64(dest, fmod(a->data.f64, (f64) b->data.uw));
+ default:
+ goto ko;
+ }
+ case TAG_INTEGER:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, fmod(integer_to_f64(&a->data.integer),
+ (f64) b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod(integer_to_f64(&a->data.integer),
+ b->data.f64));
+ case TAG_INTEGER:
+ dest->type = TAG_INTEGER;
+ integer_mod(&a->data.integer, &b->data.integer,
+ &dest->data.integer);
+ return dest;
+ case TAG_S8:
+ integer_init_s8(&tmp, b->data.s8);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_s8(dest, integer_to_s8(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S16:
+ integer_init_s16(&tmp, b->data.s16);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_s16(dest, integer_to_s16(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S32:
+ integer_init_s32(&tmp, b->data.s32);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_s32(dest, integer_to_s32(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S64:
+ integer_init_s64(&tmp, b->data.s64);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_s64(dest, integer_to_s64(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_SW:
+ integer_init_sw(&tmp, b->data.sw);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_sw(dest, integer_to_sw(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ integer_init_u8(&tmp, b->data.u8);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_u8(dest, integer_to_u8(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U16:
+ integer_init_u16(&tmp, b->data.u16);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_u16(dest, integer_to_u16(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U32:
+ integer_init_u32(&tmp, b->data.u32);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_u32(dest, integer_to_u32(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U64:
+ integer_init_u64(&tmp, b->data.u64);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_u64(dest, integer_to_u64(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_UW:
+ integer_init_uw(&tmp, b->data.uw);
+ integer_mod(&a->data.integer, &tmp, &tmp2);
+ tag_init_uw(dest, integer_to_uw(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S8:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, fmodf((f32) a->data.s8, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.s8, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_s8(&tmp, a->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s8(dest, a->data.s8 % b->data.s8);
+ case TAG_S16:
+ return tag_init_s8(dest, a->data.s8 % b->data.s16);
+ case TAG_S32:
+ return tag_init_s8(dest, a->data.s8 % b->data.s32);
+ case TAG_S64:
+ return tag_init_s8(dest, a->data.s8 % b->data.s64);
+ case TAG_SW:
+ return tag_init_s8(dest, a->data.s8 % b->data.sw);
+ case TAG_U8: {
+ s16 i = a->data.s8 % (s16) b->data.u8;
+ if (i < 0)
+ i += b->data.u8;
+ return tag_init_u8(dest, i);
+ }
+ case TAG_U16: {
+ s32 i = a->data.s8 % (s32) b->data.u16;
+ if (i < 0)
+ i += b->data.u16;
+ return tag_init_u16(dest, i);
+ }
+ case TAG_U32: {
+ s64 i = a->data.s8 % (s64) b->data.u32;
+ if (i < 0)
+ i += b->data.u32;
+ return tag_init_u32(dest, i);
+ }
+ case TAG_U64:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_UW:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S16:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, fmodf((f32) a->data.s16, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.s16, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_s16(&tmp, a->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s8(dest, a->data.s16 % b->data.s8);
+ case TAG_S16:
+ return tag_init_s16(dest, a->data.s16 % b->data.s16);
+ case TAG_S32:
+ return tag_init_s16(dest, a->data.s16 % b->data.s32);
+ case TAG_S64:
+ return tag_init_s16(dest, a->data.s16 % b->data.s64);
+ case TAG_SW:
+ return tag_init_s16(dest, a->data.s16 % b->data.sw);
+ case TAG_U8: {
+ s16 i = a->data.s16 % (s16) b->data.u8;
+ if (i < 0)
+ i += b->data.u8;
+ return tag_init_u8(dest, i);
+ }
+ case TAG_U16: {
+ s32 i = a->data.s16 % (s32) b->data.u16;
+ if (i < 0)
+ i += b->data.u16;
+ return tag_init_u16(dest, i);
+ }
+ case TAG_U32: {
+ s64 i = a->data.s16 % (s64) b->data.u32;
+ if (i < 0)
+ i += b->data.u32;
+ return tag_init_u32(dest, i);
+ }
+ case TAG_U64:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_UW:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S32:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, fmod((f64) a->data.s32, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.s32, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_s32(&tmp, a->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s8(dest, a->data.s32 % b->data.s8);
+ case TAG_S16:
+ return tag_init_s16(dest, a->data.s32 % b->data.s16);
+ case TAG_S32:
+ return tag_init_s32(dest, a->data.s32 % b->data.s32);
+ case TAG_S64:
+ return tag_init_s64(dest, a->data.s32 % b->data.s64);
+ case TAG_SW:
+ return tag_init_sw(dest, a->data.s32 % b->data.sw);
+ case TAG_U8: {
+ s16 i = a->data.s32 % (s16) b->data.u8;
+ if (i < 0)
+ i += b->data.u8;
+ return tag_init_u8(dest, i);
+ }
+ case TAG_U16: {
+ s32 i = a->data.s32 % (s32) b->data.u16;
+ if (i < 0)
+ i += b->data.u16;
+ return tag_init_u16(dest, i);
+ }
+ case TAG_U32: {
+ s64 i = a->data.s32 % (s64) b->data.u32;
+ if (i < 0)
+ i += b->data.u32;
+ return tag_init_u32(dest, i);
+ }
+ case TAG_U64:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_UW:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S64:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, fmod((f64) a->data.s64, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.s64, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_s64(&tmp, a->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s8(dest, a->data.s64 % b->data.s8);
+ case TAG_S16:
+ return tag_init_s16(dest, a->data.s64 % b->data.s16);
+ case TAG_S32:
+ return tag_init_s32(dest, a->data.s64 % b->data.s32);
+ case TAG_S64:
+ return tag_init_s64(dest, a->data.s64 % b->data.s64);
+ case TAG_SW:
+ return tag_init_sw(dest, a->data.s64 % b->data.sw);
+ case TAG_U8: {
+ s16 i = a->data.s64 % b->data.u8;
+ if (i < 0)
+ i += b->data.u8;
+ return tag_init_u8(dest, i);
+ }
+ case TAG_U16: {
+ s32 i = a->data.s64 % b->data.u16;
+ if (i < 0)
+ i += b->data.u16;
+ return tag_init_u16(dest, i);
+ }
+ case TAG_U32: {
+ s64 i = a->data.s64 % b->data.u32;
+ if (i < 0)
+ i += b->data.u32;
+ return tag_init_u32(dest, i);
+ }
+ case TAG_U64:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_UW:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_SW:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, fmod((f64) a->data.sw, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.sw, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_mod(&tmp, &b->data.integer, &tmp2);
+ tag_init_sw(dest, integer_to_sw(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S8:
+ return tag_init_s8(dest, a->data.sw % b->data.s8);
+ case TAG_S16:
+ return tag_init_s16(dest, a->data.sw % b->data.s16);
+ case TAG_S32:
+ return tag_init_s32(dest, a->data.sw % b->data.s32);
+ case TAG_S64:
+ return tag_init_sw(dest, a->data.sw % b->data.s64);
+ case TAG_SW:
+ return tag_init_sw(dest, a->data.sw % b->data.sw);
+ case TAG_U8: {
+ s16 i = a->data.sw % b->data.u8;
+ if (i < 0)
+ i += b->data.u8;
+ return tag_init_u8(dest, i);
+ }
+ case TAG_U16: {
+ s32 i = a->data.sw % b->data.u16;
+ if (i < 0)
+ i += b->data.u16;
+ return tag_init_u16(dest, i);
+ }
+ case TAG_U32: {
+ s64 i = a->data.sw % b->data.u32;
+ if (i < 0)
+ i += b->data.u32;
+ return tag_init_u32(dest, i);
+ }
+ case TAG_U64:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_UW:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_U8:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, fmodf((f32) a->data.u8, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.u8, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, a->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8: {
+ s16 i = a->data.u8 % b->data.s8;
+ if (b->data.s8 < 0 && i > 0)
+ i += b->data.s8;
+ return tag_init_s8(dest, i);
+ }
+ case TAG_S16: {
+ s32 i = a->data.u8 % b->data.s16;
+ if (b->data.s16 < 0 && i > 0)
+ i += b->data.s16;
+ return tag_init_s16(dest, i);
+ }
+ case TAG_S32: {
+ s64 i = a->data.u8 % b->data.s32;
+ if (b->data.s32 < 0 && i > 0)
+ i += b->data.s32;
+ return tag_init_s32(dest, i);
+ }
+ case TAG_S64:
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_SW:
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_u8(dest, a->data.u8 % b->data.u8);
+ case TAG_U16:
+ return tag_init_u8(dest, a->data.u8 % b->data.u16);
+ case TAG_U32:
+ return tag_init_u8(dest, a->data.u8 % b->data.u32);
+ case TAG_U64:
+ return tag_init_u8(dest, a->data.u8 % b->data.u64);
+ case TAG_UW:
+ return tag_init_u8(dest, a->data.u8 % b->data.uw);
+ default:
+ goto ko;
+ }
+ case TAG_U16:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, fmodf((f32) a->data.u16, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.u16, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_u16(&tmp, a->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8: {
+ s16 i = a->data.u16 % b->data.s8;
+ if (b->data.s8 < 0 && i > 0)
+ i += b->data.s8;
+ return tag_init_s8(dest, i);
+ }
+ case TAG_S16: {
+ s32 i = a->data.u16 % b->data.s16;
+ if (b->data.s16 < 0 && i > 0)
+ i += b->data.s16;
+ return tag_init_s16(dest, i);
+ }
+ case TAG_S32: {
+ s64 i = a->data.u16 % b->data.s32;
+ if (b->data.s32 < 0 && i > 0)
+ i += b->data.s32;
+ return tag_init_s32(dest, i);
+ }
+ case TAG_S64:
+ integer_init_u16(&tmp, a->data.u16);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_SW:
+ integer_init_u16(&tmp, a->data.u16);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_u8(dest, a->data.u16 % b->data.u8);
+ case TAG_U16:
+ return tag_init_u16(dest, a->data.u16 % b->data.u16);
+ case TAG_U32:
+ return tag_init_u16(dest, a->data.u16 % b->data.u32);
+ case TAG_U64:
+ return tag_init_u16(dest, a->data.u16 % b->data.u64);
+ case TAG_UW:
+ return tag_init_u16(dest, a->data.u16 % b->data.uw);
+ default:
+ goto ko;
+ }
+ case TAG_U32:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, fmod((f64) a->data.u32, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.u32, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_u32(&tmp, a->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8: {
+ s64 i = a->data.u32 % (s64) b->data.s8;
+ if (b->data.s8 < 0 && i > 0)
+ i += b->data.s8;
+ return tag_init_s8(dest, i);
+ }
+ case TAG_S16: {
+ s64 i = a->data.u32 % (s64) b->data.s16;
+ if (b->data.s16 < 0 && i > 0)
+ i += b->data.s16;
+ return tag_init_s16(dest, i);
+ }
+ case TAG_S32: {
+ s64 i = a->data.u32 % (s64) b->data.s32;
+ if (b->data.s32 < 0 && i > 0)
+ i += b->data.s32;
+ return tag_init_s32(dest, i);
+ }
+ case TAG_S64:
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_SW:
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_u8(dest, a->data.u32 % b->data.u8);
+ case TAG_U16:
+ return tag_init_u16(dest, a->data.u32 % b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(dest, a->data.u32 % b->data.u32);
+ case TAG_U64:
+ return tag_init_u32(dest, a->data.u32 % b->data.u64);
+ case TAG_UW:
+ return tag_init_u32(dest, a->data.u32 % b->data.uw);
+ default:
+ goto ko;
+ }
+ case TAG_U64:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, fmod((f64) a->data.u64, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.u64, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_u64(&tmp, a->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s8(&tmp2, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S16:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s16(&tmp2, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S32:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s32(&tmp2, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S64:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_SW:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_u8(dest, a->data.u64 % b->data.u8);
+ case TAG_U16:
+ return tag_init_u16(dest, a->data.u64 % b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(dest, a->data.u64 % b->data.u32);
+ case TAG_U64:
+ return tag_init_u64(dest, a->data.u64 % b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(dest, a->data.u64 % b->data.uw);
+ default:
+ goto ko;
+ }
+ case TAG_UW:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, fmod((f64) a->data.uw, b->data.f32));
+ case TAG_F64:
+ return tag_init_f64(dest, fmod((f64) a->data.uw, b->data.f64));
+ case TAG_INTEGER:
+ integer_init_uw(&tmp, a->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_s8(&tmp2, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S16:
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_s16(&tmp2, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S32:
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_s32(&tmp2, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S64:
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_SW:
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_mod(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_u8(dest, a->data.uw % b->data.u8);
+ case TAG_U16:
+ return tag_init_u16(dest, a->data.uw % b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(dest, a->data.uw % b->data.u32);
+ case TAG_U64:
+ return tag_init_uw(dest, a->data.uw % b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(dest, a->data.uw % b->data.uw);
+ default:
+ goto ko;
+ }
+ default:
+ goto ko;
+ }
+ ko:
+ errx(1, "cannot divide %s by %s",
+ tag_type_to_string(a->type),
+ tag_type_to_string(b->type));
+}
diff --git a/libc3/tag_mul.c b/libc3/tag_mul.c
new file mode 100644
index 0000000..0fa60ce
--- /dev/null
+++ b/libc3/tag_mul.c
@@ -0,0 +1,570 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <err.h>
+#include <math.h>
+#include "integer.h"
+#include "tag.h"
+
+s_tag * tag_mul (const s_tag *a, const s_tag *b, s_tag *dest)
+{
+ s_integer tmp;
+ s_integer tmp2;
+ assert(a);
+ assert(b);
+ assert(dest);
+ switch (a->type) {
+ case TAG_F32:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.f32 * b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.f32 * b->data.f64);
+ case TAG_INTEGER:
+ return tag_init_f32(dest, a->data.f32 *
+ integer_to_f32(&b->data.integer));
+ case TAG_S8:
+ return tag_init_f32(dest, a->data.f32 * (f32) b->data.s8);
+ case TAG_S16:
+ return tag_init_f32(dest, a->data.f32 * (f32) b->data.s16);
+ case TAG_S32:
+ return tag_init_f32(dest, a->data.f32 * (f32) b->data.s32);
+ case TAG_S64:
+ return tag_init_f32(dest, a->data.f32 * (f32) b->data.s64);
+ case TAG_U8:
+ return tag_init_f32(dest, a->data.f32 * (f32) b->data.u8);
+ case TAG_U16:
+ return tag_init_f32(dest, a->data.f32 * (f32) b->data.u16);
+ case TAG_U32:
+ return tag_init_f32(dest, a->data.f32 * (f32) b->data.u32);
+ case TAG_U64:
+ return tag_init_f32(dest, a->data.f32 * (f32) b->data.u64);
+ default:
+ goto ko;
+ }
+ case TAG_F64:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, a->data.f64 * (f64) b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.f64 * b->data.f64);
+ case TAG_INTEGER:
+ return tag_init_f64(dest, a->data.f64 *
+ integer_to_f64(&b->data.integer));
+ case TAG_S8:
+ return tag_init_f64(dest, a->data.f64 * (f64) b->data.s8);
+ case TAG_S16:
+ return tag_init_f64(dest, a->data.f64 * (f64) b->data.s16);
+ case TAG_S32:
+ return tag_init_f64(dest, a->data.f64 * (f64) b->data.s32);
+ case TAG_S64:
+ return tag_init_f64(dest, a->data.f64 * (f64) b->data.s64);
+ case TAG_U8:
+ return tag_init_f64(dest, a->data.f64 * (f64) b->data.u8);
+ case TAG_U16:
+ return tag_init_f64(dest, a->data.f64 * (f64) b->data.u16);
+ case TAG_U32:
+ return tag_init_f64(dest, a->data.f64 * (f64) b->data.u32);
+ case TAG_U64:
+ return tag_init_f64(dest, a->data.f64 * (f64) b->data.u64);
+ default:
+ goto ko;
+ }
+ case TAG_INTEGER:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, integer_to_f32(&a->data.integer) *
+ b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, integer_to_f64(&a->data.integer) *
+ b->data.f64);
+ case TAG_INTEGER:
+ dest->type = TAG_INTEGER;
+ integer_mul(&a->data.integer, &b->data.integer,
+ &dest->data.integer);
+ return dest;
+ case TAG_S8:
+ integer_init_s8(&tmp, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_mul(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S16:
+ integer_init_s16(&tmp, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_mul(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S32:
+ integer_init_s32(&tmp, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_mul(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S64:
+ integer_init_s64(&tmp, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_U8:
+ integer_init_u8(&tmp, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_mul(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_U16:
+ integer_init_u16(&tmp, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_mul(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_U32:
+ integer_init_u32(&tmp, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_mul(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_U64:
+ integer_init_u64(&tmp, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S8:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) a->data.s8 * b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.s8 * b->data.f64);
+ case TAG_INTEGER:
+ integer_init_s8(&tmp, a->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s16(dest, (s16) a->data.s8 * (s16) b->data.s8);
+ case TAG_S16:
+ return tag_init_s32(dest, (s32) a->data.s8 * (s32) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.s8 * (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_s16(dest, (s16) a->data.s8 * (s16) b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(dest, (s32) a->data.s8 * (s32) b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(dest, (s64) a->data.s8 * (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S16:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) a->data.s16 * b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.s16 * b->data.f64);
+ case TAG_INTEGER:
+ integer_init_s16(&tmp, a->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s32(dest, (s32) a->data.s16 * (s32) b->data.s8);
+ case TAG_S16:
+ return tag_init_s32(dest, (s32) a->data.s16 * (s32) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.s16 * (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_s32(dest, (s32) a->data.s16 * (s32) b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(dest, (s32) a->data.s16 * (s32) b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(dest, (s64) a->data.s16 * (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S32:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) a->data.s32 * b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.s32 * b->data.f64);
+ case TAG_INTEGER:
+ integer_init_s32(&tmp, a->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.s8);
+ case TAG_S16:
+ return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.u8);
+ case TAG_U16:
+ return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(dest, (s64) a->data.s32 * (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S64:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) a->data.s64 * b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.s64 * b->data.f64);
+ case TAG_INTEGER:
+ integer_init_s64(&tmp, a->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s8(&tmp2, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S16:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s16(&tmp2, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S32:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s32(&tmp2, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S64:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u8(&tmp2, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U16:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u16(&tmp2, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U32:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u32(&tmp2, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U64:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_U8:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) a->data.u8 * b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.u8 * b->data.f64);
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, a->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s16(dest, (s16) a->data.u8 * (s16) b->data.s8);
+ case TAG_S16:
+ return tag_init_s32(dest, (s32) a->data.u8 * (s32) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s32) a->data.u8 * (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_u16(dest, (u16) a->data.u8 * (u16) b->data.u8);
+ case TAG_U16:
+ return tag_init_u32(dest, (u32) a->data.u8 * (u32) b->data.u16);
+ case TAG_U32:
+ return tag_init_u64(dest, (u64) a->data.u8 * (u64) b->data.u32);
+ case TAG_U64:
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_U16:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) a->data.u16 * b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.u16 * b->data.f64);
+ case TAG_INTEGER:
+ integer_init_u16(&tmp, a->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s32(dest, (s32) a->data.u16 * (s32) b->data.s8);
+ case TAG_S16:
+ return tag_init_s32(dest, (s32) a->data.u16 * (s32) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.u16 * (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_u16(&tmp, a->data.u16);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_u32(dest, (u32) a->data.u16 * (u32) b->data.u8);
+ case TAG_U16:
+ return tag_init_u32(dest, (u32) a->data.u16 * (u32) b->data.u16);
+ case TAG_U32:
+ return tag_init_u64(dest, (u64) a->data.u16 * (u64) b->data.u32);
+ case TAG_U64:
+ integer_init_u16(&tmp, a->data.u16);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_U32:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) a->data.u32 * b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.u32 * b->data.f64);
+ case TAG_INTEGER:
+ integer_init_u32(&tmp, a->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s64(dest, (s64) a->data.u32 * (s64) b->data.s8);
+ case TAG_S16:
+ return tag_init_s64(dest, (s64) a->data.u32 * (s64) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.u32 * b->data.s32);
+ case TAG_S64:
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_u64(dest, (u64) a->data.u32 * (u64) b->data.u8);
+ case TAG_U16:
+ return tag_init_u64(dest, (u64) a->data.u32 * (u64) b->data.u16);
+ case TAG_U32:
+ return tag_init_u64(dest, (u64) a->data.u32 * (u64) b->data.u32);
+ case TAG_U64:
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_U64:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) a->data.u64 * b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.u64 * b->data.f64);
+ case TAG_INTEGER:
+ integer_init_u64(&tmp, a->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s8(&tmp2, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S16:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s16(&tmp2, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S32:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s32(&tmp2, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S64:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u8(&tmp2, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U16:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u16(&tmp2, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U32:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u32(&tmp2, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U64:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_mul(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ default:
+ goto ko;
+ }
+ ko:
+ errx(1, "cannot multiply %s by %s",
+ tag_type_to_string(a->type),
+ tag_type_to_string(b->type));
+}
diff --git a/libc3/tag_shift_left.c b/libc3/tag_shift_left.c
new file mode 100644
index 0000000..5c258fa
--- /dev/null
+++ b/libc3/tag_shift_left.c
@@ -0,0 +1,551 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <err.h>
+#include "integer.h"
+#include "tag.h"
+
+s_tag * tag_shift_left (const s_tag *a, const s_tag *b, s_tag *result)
+{
+ s_integer tmp;
+ s_integer tmp2;
+ s_tag tmp_a;
+ switch (a->type) {
+ case TAG_BOOL:
+ tmp_a.data.bool = a->data.bool ? 1 : 0;
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_bool(result, tmp_a.data.bool <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.character);
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, tmp_a.data.bool);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_bool(result, integer_to_u8(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.sw);
+ case TAG_S64:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.s64);
+ case TAG_S32:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.s32);
+ case TAG_S16:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.s16);
+ case TAG_S8:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.s8);
+ case TAG_U8:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.u8);
+ case TAG_U16:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.u16);
+ case TAG_U32:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.u32);
+ case TAG_U64:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.u64);
+ case TAG_UW:
+ return tag_init_bool(result, tmp_a.data.bool << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_CHARACTER:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_character(result, a->data.character <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_character(result, a->data.character << b->data.character);
+ case TAG_INTEGER:
+ integer_init_u32(&tmp, a->data.character);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_character(result, integer_to_u32(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_character(result, a->data.character << b->data.sw);
+ case TAG_S64:
+ return tag_init_character(result, a->data.character << b->data.s64);
+ case TAG_S32:
+ return tag_init_character(result, a->data.character << b->data.s32);
+ case TAG_S16:
+ return tag_init_character(result, a->data.character << b->data.s16);
+ case TAG_S8:
+ return tag_init_character(result, a->data.character << b->data.s8);
+ case TAG_U8:
+ return tag_init_character(result, a->data.character << b->data.u8);
+ case TAG_U16:
+ return tag_init_character(result, a->data.character << b->data.u16);
+ case TAG_U32:
+ return tag_init_character(result, a->data.character << b->data.u32);
+ case TAG_U64:
+ return tag_init_character(result, a->data.character << b->data.u64);
+ case TAG_UW:
+ return tag_init_character(result, a->data.character << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_INTEGER:
+ switch (b->type) {
+ case TAG_BOOL:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.bool ? 1 : 0,
+ &result->data.integer);
+ return result;
+ case TAG_CHARACTER:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.character,
+ &result->data.integer);
+ return result;
+ case TAG_INTEGER:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, integer_to_sw(&b->data.integer),
+ &result->data.integer);
+ return result;
+ case TAG_SW:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.sw,
+ &result->data.integer);
+ return result;
+ case TAG_S64:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.s64, &result->data.integer);
+ return result;
+ case TAG_S32:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.s32, &result->data.integer);
+ return result;
+ case TAG_S16:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.s16, &result->data.integer);
+ return result;
+ case TAG_S8:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.s8, &result->data.integer);
+ return result;
+ case TAG_U8:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.u8, &result->data.integer);
+ return result;
+ case TAG_U16:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.u16, &result->data.integer);
+ return result;
+ case TAG_U32:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.u32, &result->data.integer);
+ return result;
+ case TAG_U64:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.u64, &result->data.integer);
+ return result;
+ case TAG_UW:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.uw, &result->data.integer);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_SW:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_sw(result, a->data.sw <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_sw(result, a->data.sw << b->data.character);
+ case TAG_INTEGER:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_sw(result, integer_to_sw(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, a->data.sw << b->data.sw);
+ case TAG_S64:
+ return tag_init_sw(result, a->data.sw << b->data.s64);
+ case TAG_S32:
+ return tag_init_sw(result, a->data.sw << b->data.s32);
+ case TAG_S16:
+ return tag_init_sw(result, a->data.sw << b->data.s16);
+ case TAG_S8:
+ return tag_init_sw(result, a->data.sw << b->data.s8);
+ case TAG_U8:
+ return tag_init_sw(result, a->data.sw << b->data.u8);
+ case TAG_U16:
+ return tag_init_sw(result, a->data.sw << b->data.u16);
+ case TAG_U32:
+ return tag_init_sw(result, a->data.sw << b->data.u32);
+ case TAG_U64:
+ return tag_init_sw(result, a->data.sw << b->data.u64);
+ case TAG_UW:
+ return tag_init_sw(result, a->data.sw << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S64:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_s64(result, a->data.s64 <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_s64(result, a->data.s64 << b->data.character);
+ case TAG_INTEGER:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_s64(result, integer_to_s64(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_s64(result, a->data.s64 << b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, a->data.s64 << b->data.s64);
+ case TAG_S32:
+ return tag_init_s64(result, a->data.s64 << b->data.s32);
+ case TAG_S16:
+ return tag_init_s64(result, a->data.s64 << b->data.s16);
+ case TAG_S8:
+ return tag_init_s64(result, a->data.s64 << b->data.s8);
+ case TAG_U8:
+ return tag_init_s64(result, a->data.s64 << b->data.u8);
+ case TAG_U16:
+ return tag_init_s64(result, a->data.s64 << b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(result, a->data.s64 << b->data.u32);
+ case TAG_U64:
+ return tag_init_s64(result, a->data.s64 << b->data.u64);
+ case TAG_UW:
+ return tag_init_s64(result, a->data.s64 << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S32:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_s32(result, a->data.s32 <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_s32(result, a->data.s32 << b->data.character);
+ case TAG_INTEGER:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_s32(result, integer_to_s32(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_s32(result, a->data.s32 << b->data.sw);
+ case TAG_S64:
+ return tag_init_s32(result, a->data.s32 << b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, a->data.s32 << b->data.s32);
+ case TAG_S16:
+ return tag_init_s32(result, a->data.s32 << b->data.s16);
+ case TAG_S8:
+ return tag_init_s32(result, a->data.s32 << b->data.s8);
+ case TAG_U8:
+ return tag_init_s32(result, a->data.s32 << b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(result, a->data.s32 << b->data.u16);
+ case TAG_U32:
+ return tag_init_s32(result, a->data.s32 << b->data.u32);
+ case TAG_U64:
+ return tag_init_s32(result, a->data.s32 << b->data.u64);
+ case TAG_UW:
+ return tag_init_s32(result, a->data.s32 << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S16:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_s16(result, a->data.s16 <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_s16(result, a->data.s16 << b->data.character);
+ case TAG_INTEGER:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_s16(result, integer_to_s16(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_s16(result, a->data.s16 << b->data.sw);
+ case TAG_S64:
+ return tag_init_s16(result, a->data.s16 << b->data.s64);
+ case TAG_S32:
+ return tag_init_s16(result, a->data.s16 << b->data.s32);
+ case TAG_S16:
+ return tag_init_s16(result, a->data.s16 << b->data.s16);
+ case TAG_S8:
+ return tag_init_s16(result, a->data.s16 << b->data.s8);
+ case TAG_U8:
+ return tag_init_s16(result, a->data.s16 << b->data.u8);
+ case TAG_U16:
+ return tag_init_s16(result, a->data.s16 << b->data.u16);
+ case TAG_U32:
+ return tag_init_s16(result, a->data.s16 << b->data.u32);
+ case TAG_U64:
+ return tag_init_s16(result, a->data.s16 << b->data.u64);
+ case TAG_UW:
+ return tag_init_s16(result, a->data.s16 << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S8:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_s8(result, a->data.s8 <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_s8(result, a->data.s8 << b->data.character);
+ case TAG_INTEGER:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_s8(result, integer_to_s8(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_s8(result, a->data.s8 << b->data.sw);
+ case TAG_S64:
+ return tag_init_s8(result, a->data.s8 << b->data.s64);
+ case TAG_S32:
+ return tag_init_s8(result, a->data.s8 << b->data.s32);
+ case TAG_S16:
+ return tag_init_s8(result, a->data.s8 << b->data.s16);
+ case TAG_S8:
+ return tag_init_s8(result, a->data.s8 << b->data.s8);
+ case TAG_U8:
+ return tag_init_s8(result, a->data.s8 << b->data.u8);
+ case TAG_U16:
+ return tag_init_s8(result, a->data.s8 << b->data.u16);
+ case TAG_U32:
+ return tag_init_s8(result, a->data.s8 << b->data.u32);
+ case TAG_U64:
+ return tag_init_s8(result, a->data.s8 << b->data.u64);
+ case TAG_UW:
+ return tag_init_s8(result, a->data.s8 << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_U8:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_u8(result, a->data.u8 <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_u8(result, a->data.u8 << b->data.character);
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, a->data.u8);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_u8(result, integer_to_u8(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_u8(result, a->data.u8 << b->data.sw);
+ case TAG_S64:
+ return tag_init_u8(result, a->data.u8 << b->data.s64);
+ case TAG_S32:
+ return tag_init_u8(result, a->data.u8 << b->data.s32);
+ case TAG_S16:
+ return tag_init_u8(result, a->data.u8 << b->data.s16);
+ case TAG_S8:
+ return tag_init_u8(result, a->data.u8 << b->data.s8);
+ case TAG_U8:
+ return tag_init_u8(result, a->data.u8 << b->data.u8);
+ case TAG_U16:
+ return tag_init_u8(result, a->data.u8 << b->data.u16);
+ case TAG_U32:
+ return tag_init_u8(result, a->data.u8 << b->data.u32);
+ case TAG_U64:
+ return tag_init_u8(result, a->data.u8 << b->data.u64);
+ case TAG_UW:
+ return tag_init_u8(result, a->data.u8 << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_U16:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_u16(result, a->data.u16 <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_u16(result, a->data.u16 << b->data.character);
+ case TAG_INTEGER:
+ integer_init_u16(&tmp, a->data.u16);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_u16(result, integer_to_u16(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_u16(result, a->data.u16 << b->data.sw);
+ case TAG_S64:
+ return tag_init_u16(result, a->data.u16 << b->data.s64);
+ case TAG_S32:
+ return tag_init_u16(result, a->data.u16 << b->data.s32);
+ case TAG_S16:
+ return tag_init_u16(result, a->data.u16 << b->data.s16);
+ case TAG_S8:
+ return tag_init_u16(result, a->data.u16 << b->data.s8);
+ case TAG_U8:
+ return tag_init_u16(result, a->data.u16 << b->data.u8);
+ case TAG_U16:
+ return tag_init_u16(result, a->data.u16 << b->data.u16);
+ case TAG_U32:
+ return tag_init_u16(result, a->data.u16 << b->data.u32);
+ case TAG_U64:
+ return tag_init_u16(result, a->data.u16 << b->data.u64);
+ case TAG_UW:
+ return tag_init_u16(result, a->data.u16 << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_U32:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_u32(result, a->data.u32 <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_u32(result, a->data.u32 << b->data.character);
+ case TAG_INTEGER:
+ integer_init_u32(&tmp, a->data.u32);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_u32(result, integer_to_u32(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_u32(result, a->data.u32 << b->data.sw);
+ case TAG_S64:
+ return tag_init_u32(result, a->data.u32 << b->data.s64);
+ case TAG_S32:
+ return tag_init_u32(result, a->data.u32 << b->data.s32);
+ case TAG_S16:
+ return tag_init_u32(result, a->data.u32 << b->data.s16);
+ case TAG_S8:
+ return tag_init_u32(result, a->data.u32 << b->data.s8);
+ case TAG_U8:
+ return tag_init_u32(result, a->data.u32 << b->data.u8);
+ case TAG_U16:
+ return tag_init_u32(result, a->data.u32 << b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(result, a->data.u32 << b->data.u32);
+ case TAG_U64:
+ return tag_init_u32(result, a->data.u32 << b->data.u64);
+ case TAG_UW:
+ return tag_init_u32(result, a->data.u32 << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_U64:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_u64(result, a->data.u64 <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_u64(result, a->data.u64 << b->data.character);
+ case TAG_INTEGER:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_u64(result, integer_to_u64(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_u64(result, a->data.u64 << b->data.sw);
+ case TAG_S64:
+ return tag_init_u64(result, a->data.u64 << b->data.s64);
+ case TAG_S32:
+ return tag_init_u64(result, a->data.u64 << b->data.s32);
+ case TAG_S16:
+ return tag_init_u64(result, a->data.u64 << b->data.s16);
+ case TAG_S8:
+ return tag_init_u64(result, a->data.u64 << b->data.s8);
+ case TAG_U8:
+ return tag_init_u64(result, a->data.u64 << b->data.u8);
+ case TAG_U16:
+ return tag_init_u64(result, a->data.u64 << b->data.u16);
+ case TAG_U32:
+ return tag_init_u64(result, a->data.u64 << b->data.u32);
+ case TAG_U64:
+ return tag_init_u64(result, a->data.u64 << b->data.u64);
+ case TAG_UW:
+ return tag_init_u64(result, a->data.u64 << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_UW:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_uw(result, a->data.uw <<
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_uw(result, a->data.uw << b->data.character);
+ case TAG_INTEGER:
+ integer_init_uw(&tmp, a->data.uw);
+ integer_lshift(&tmp, integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_uw(result, integer_to_uw(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_uw(result, a->data.uw << b->data.sw);
+ case TAG_S64:
+ return tag_init_uw(result, a->data.uw << b->data.s64);
+ case TAG_S32:
+ return tag_init_uw(result, a->data.uw << b->data.s32);
+ case TAG_S16:
+ return tag_init_uw(result, a->data.uw << b->data.s16);
+ case TAG_S8:
+ return tag_init_uw(result, a->data.uw << b->data.s8);
+ case TAG_U8:
+ return tag_init_uw(result, a->data.uw << b->data.u8);
+ case TAG_U16:
+ return tag_init_uw(result, a->data.uw << b->data.u16);
+ case TAG_U32:
+ return tag_init_uw(result, a->data.uw << b->data.u32);
+ case TAG_U64:
+ return tag_init_uw(result, a->data.uw << b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(result, a->data.uw << b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ default:
+ goto error;
+ }
+ error:
+ warnx("tag_shift_left: invalid tag type: %s << %s",
+ tag_type_to_string(a->type),
+ tag_type_to_string(b->type));
+ return NULL;
+}
diff --git a/libc3/tag_shift_right.c b/libc3/tag_shift_right.c
new file mode 100644
index 0000000..818546e
--- /dev/null
+++ b/libc3/tag_shift_right.c
@@ -0,0 +1,551 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <err.h>
+#include "integer.h"
+#include "tag.h"
+
+s_tag * tag_shift_right (const s_tag *a, const s_tag *b, s_tag *result)
+{
+ s_integer tmp;
+ s_integer tmp2;
+ s_tag tmp_a;
+ switch (a->type) {
+ case TAG_BOOL:
+ tmp_a.data.bool = a->data.bool ? 1 : 0;
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_bool(result, tmp_a.data.bool >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, tmp_a.data.bool);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_bool(result, integer_to_u8(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.sw);
+ case TAG_S64:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.s64);
+ case TAG_S32:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.s32);
+ case TAG_S16:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.s16);
+ case TAG_S8:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.s8);
+ case TAG_U8:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.u8);
+ case TAG_U16:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.u16);
+ case TAG_U32:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.u32);
+ case TAG_U64:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.u64);
+ case TAG_UW:
+ return tag_init_bool(result, tmp_a.data.bool >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_CHARACTER:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_character(result, a->data.character >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_character(result, a->data.character >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_u32(&tmp, a->data.character);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_character(result, integer_to_u32(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_character(result, a->data.character >> b->data.sw);
+ case TAG_S64:
+ return tag_init_character(result, a->data.character >> b->data.s64);
+ case TAG_S32:
+ return tag_init_character(result, a->data.character >> b->data.s32);
+ case TAG_S16:
+ return tag_init_character(result, a->data.character >> b->data.s16);
+ case TAG_S8:
+ return tag_init_character(result, a->data.character >> b->data.s8);
+ case TAG_U8:
+ return tag_init_character(result, a->data.character >> b->data.u8);
+ case TAG_U16:
+ return tag_init_character(result, a->data.character >> b->data.u16);
+ case TAG_U32:
+ return tag_init_character(result, a->data.character >> b->data.u32);
+ case TAG_U64:
+ return tag_init_character(result, a->data.character >> b->data.u64);
+ case TAG_UW:
+ return tag_init_character(result, a->data.character >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_INTEGER:
+ switch (b->type) {
+ case TAG_BOOL:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, b->data.bool ? -1 : 0,
+ &result->data.integer);
+ return result;
+ case TAG_CHARACTER:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.character,
+ &result->data.integer);
+ return result;
+ case TAG_INTEGER:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -integer_to_sw(&b->data.integer),
+ &result->data.integer);
+ return result;
+ case TAG_SW:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.sw,
+ &result->data.integer);
+ return result;
+ case TAG_S64:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.s64, &result->data.integer);
+ return result;
+ case TAG_S32:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.s32, &result->data.integer);
+ return result;
+ case TAG_S16:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.s16, &result->data.integer);
+ return result;
+ case TAG_S8:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.s8, &result->data.integer);
+ return result;
+ case TAG_U8:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.u8, &result->data.integer);
+ return result;
+ case TAG_U16:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.u16, &result->data.integer);
+ return result;
+ case TAG_U32:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.u32, &result->data.integer);
+ return result;
+ case TAG_U64:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.u64, &result->data.integer);
+ return result;
+ case TAG_UW:
+ result->type = TAG_INTEGER;
+ integer_lshift(&a->data.integer, -b->data.uw, &result->data.integer);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_SW:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_sw(result, a->data.sw >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_sw(result, a->data.sw >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_sw(result, integer_to_sw(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, a->data.sw >> b->data.sw);
+ case TAG_S64:
+ return tag_init_sw(result, a->data.sw >> b->data.s64);
+ case TAG_S32:
+ return tag_init_sw(result, a->data.sw >> b->data.s32);
+ case TAG_S16:
+ return tag_init_sw(result, a->data.sw >> b->data.s16);
+ case TAG_S8:
+ return tag_init_sw(result, a->data.sw >> b->data.s8);
+ case TAG_U8:
+ return tag_init_sw(result, a->data.sw >> b->data.u8);
+ case TAG_U16:
+ return tag_init_sw(result, a->data.sw >> b->data.u16);
+ case TAG_U32:
+ return tag_init_sw(result, a->data.sw >> b->data.u32);
+ case TAG_U64:
+ return tag_init_sw(result, a->data.sw >> b->data.u64);
+ case TAG_UW:
+ return tag_init_sw(result, a->data.sw >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S64:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_s64(result, a->data.s64 >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_s64(result, a->data.s64 >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_s64(result, integer_to_s64(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_s64(result, a->data.s64 >> b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, a->data.s64 >> b->data.s64);
+ case TAG_S32:
+ return tag_init_s64(result, a->data.s64 >> b->data.s32);
+ case TAG_S16:
+ return tag_init_s64(result, a->data.s64 >> b->data.s16);
+ case TAG_S8:
+ return tag_init_s64(result, a->data.s64 >> b->data.s8);
+ case TAG_U8:
+ return tag_init_s64(result, a->data.s64 >> b->data.u8);
+ case TAG_U16:
+ return tag_init_s64(result, a->data.s64 >> b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(result, a->data.s64 >> b->data.u32);
+ case TAG_U64:
+ return tag_init_s64(result, a->data.s64 >> b->data.u64);
+ case TAG_UW:
+ return tag_init_s64(result, a->data.s64 >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S32:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_s32(result, a->data.s32 >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_s32(result, a->data.s32 >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_s32(result, integer_to_s32(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_s32(result, a->data.s32 >> b->data.sw);
+ case TAG_S64:
+ return tag_init_s32(result, a->data.s32 >> b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, a->data.s32 >> b->data.s32);
+ case TAG_S16:
+ return tag_init_s32(result, a->data.s32 >> b->data.s16);
+ case TAG_S8:
+ return tag_init_s32(result, a->data.s32 >> b->data.s8);
+ case TAG_U8:
+ return tag_init_s32(result, a->data.s32 >> b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(result, a->data.s32 >> b->data.u16);
+ case TAG_U32:
+ return tag_init_s32(result, a->data.s32 >> b->data.u32);
+ case TAG_U64:
+ return tag_init_s32(result, a->data.s32 >> b->data.u64);
+ case TAG_UW:
+ return tag_init_s32(result, a->data.s32 >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S16:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_s16(result, a->data.s16 >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_s16(result, a->data.s16 >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_s16(result, integer_to_s16(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_s16(result, a->data.s16 >> b->data.sw);
+ case TAG_S64:
+ return tag_init_s16(result, a->data.s16 >> b->data.s64);
+ case TAG_S32:
+ return tag_init_s16(result, a->data.s16 >> b->data.s32);
+ case TAG_S16:
+ return tag_init_s16(result, a->data.s16 >> b->data.s16);
+ case TAG_S8:
+ return tag_init_s16(result, a->data.s16 >> b->data.s8);
+ case TAG_U8:
+ return tag_init_s16(result, a->data.s16 >> b->data.u8);
+ case TAG_U16:
+ return tag_init_s16(result, a->data.s16 >> b->data.u16);
+ case TAG_U32:
+ return tag_init_s16(result, a->data.s16 >> b->data.u32);
+ case TAG_U64:
+ return tag_init_s16(result, a->data.s16 >> b->data.u64);
+ case TAG_UW:
+ return tag_init_s16(result, a->data.s16 >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S8:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_s8(result, a->data.s8 >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_s8(result, a->data.s8 >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_s8(result, integer_to_s8(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_s8(result, a->data.s8 >> b->data.sw);
+ case TAG_S64:
+ return tag_init_s8(result, a->data.s8 >> b->data.s64);
+ case TAG_S32:
+ return tag_init_s8(result, a->data.s8 >> b->data.s32);
+ case TAG_S16:
+ return tag_init_s8(result, a->data.s8 >> b->data.s16);
+ case TAG_S8:
+ return tag_init_s8(result, a->data.s8 >> b->data.s8);
+ case TAG_U8:
+ return tag_init_s8(result, a->data.s8 >> b->data.u8);
+ case TAG_U16:
+ return tag_init_s8(result, a->data.s8 >> b->data.u16);
+ case TAG_U32:
+ return tag_init_s8(result, a->data.s8 >> b->data.u32);
+ case TAG_U64:
+ return tag_init_s8(result, a->data.s8 >> b->data.u64);
+ case TAG_UW:
+ return tag_init_s8(result, a->data.s8 >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_U8:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_u8(result, a->data.u8 >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_u8(result, a->data.u8 >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, a->data.u8);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_u8(result, integer_to_u8(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_u8(result, a->data.u8 >> b->data.sw);
+ case TAG_S64:
+ return tag_init_u8(result, a->data.u8 >> b->data.s64);
+ case TAG_S32:
+ return tag_init_u8(result, a->data.u8 >> b->data.s32);
+ case TAG_S16:
+ return tag_init_u8(result, a->data.u8 >> b->data.s16);
+ case TAG_S8:
+ return tag_init_u8(result, a->data.u8 >> b->data.s8);
+ case TAG_U8:
+ return tag_init_u8(result, a->data.u8 >> b->data.u8);
+ case TAG_U16:
+ return tag_init_u8(result, a->data.u8 >> b->data.u16);
+ case TAG_U32:
+ return tag_init_u8(result, a->data.u8 >> b->data.u32);
+ case TAG_U64:
+ return tag_init_u8(result, a->data.u8 >> b->data.u64);
+ case TAG_UW:
+ return tag_init_u8(result, a->data.u8 >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_U16:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_u16(result, a->data.u16 >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_u16(result, a->data.u16 >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_u16(&tmp, a->data.u16);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_u16(result, integer_to_u16(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_u16(result, a->data.u16 >> b->data.sw);
+ case TAG_S64:
+ return tag_init_u16(result, a->data.u16 >> b->data.s64);
+ case TAG_S32:
+ return tag_init_u16(result, a->data.u16 >> b->data.s32);
+ case TAG_S16:
+ return tag_init_u16(result, a->data.u16 >> b->data.s16);
+ case TAG_S8:
+ return tag_init_u16(result, a->data.u16 >> b->data.s8);
+ case TAG_U8:
+ return tag_init_u16(result, a->data.u16 >> b->data.u8);
+ case TAG_U16:
+ return tag_init_u16(result, a->data.u16 >> b->data.u16);
+ case TAG_U32:
+ return tag_init_u16(result, a->data.u16 >> b->data.u32);
+ case TAG_U64:
+ return tag_init_u16(result, a->data.u16 >> b->data.u64);
+ case TAG_UW:
+ return tag_init_u16(result, a->data.u16 >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_U32:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_u32(result, a->data.u32 >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_u32(result, a->data.u32 >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_u32(&tmp, a->data.u32);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_u32(result, integer_to_u32(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_u32(result, a->data.u32 >> b->data.sw);
+ case TAG_S64:
+ return tag_init_u32(result, a->data.u32 >> b->data.s64);
+ case TAG_S32:
+ return tag_init_u32(result, a->data.u32 >> b->data.s32);
+ case TAG_S16:
+ return tag_init_u32(result, a->data.u32 >> b->data.s16);
+ case TAG_S8:
+ return tag_init_u32(result, a->data.u32 >> b->data.s8);
+ case TAG_U8:
+ return tag_init_u32(result, a->data.u32 >> b->data.u8);
+ case TAG_U16:
+ return tag_init_u32(result, a->data.u32 >> b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(result, a->data.u32 >> b->data.u32);
+ case TAG_U64:
+ return tag_init_u32(result, a->data.u32 >> b->data.u64);
+ case TAG_UW:
+ return tag_init_u32(result, a->data.u32 >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_U64:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_u64(result, a->data.u64 >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_u64(result, a->data.u64 >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_u64(result, integer_to_u64(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_u64(result, a->data.u64 >> b->data.sw);
+ case TAG_S64:
+ return tag_init_u64(result, a->data.u64 >> b->data.s64);
+ case TAG_S32:
+ return tag_init_u64(result, a->data.u64 >> b->data.s32);
+ case TAG_S16:
+ return tag_init_u64(result, a->data.u64 >> b->data.s16);
+ case TAG_S8:
+ return tag_init_u64(result, a->data.u64 >> b->data.s8);
+ case TAG_U8:
+ return tag_init_u64(result, a->data.u64 >> b->data.u8);
+ case TAG_U16:
+ return tag_init_u64(result, a->data.u64 >> b->data.u16);
+ case TAG_U32:
+ return tag_init_u64(result, a->data.u64 >> b->data.u32);
+ case TAG_U64:
+ return tag_init_u64(result, a->data.u64 >> b->data.u64);
+ case TAG_UW:
+ return tag_init_u64(result, a->data.u64 >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_UW:
+ switch (b->type) {
+ case TAG_BOOL:
+ return tag_init_uw(result, a->data.uw >>
+ (b->data.bool ? 1 : 0));
+ case TAG_CHARACTER:
+ return tag_init_uw(result, a->data.uw >> b->data.character);
+ case TAG_INTEGER:
+ integer_init_uw(&tmp, a->data.uw);
+ integer_lshift(&tmp, -integer_to_sw(&b->data.integer), &tmp2);
+ tag_init_uw(result, integer_to_uw(&tmp2));
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_SW:
+ return tag_init_uw(result, a->data.uw >> b->data.sw);
+ case TAG_S64:
+ return tag_init_uw(result, a->data.uw >> b->data.s64);
+ case TAG_S32:
+ return tag_init_uw(result, a->data.uw >> b->data.s32);
+ case TAG_S16:
+ return tag_init_uw(result, a->data.uw >> b->data.s16);
+ case TAG_S8:
+ return tag_init_uw(result, a->data.uw >> b->data.s8);
+ case TAG_U8:
+ return tag_init_uw(result, a->data.uw >> b->data.u8);
+ case TAG_U16:
+ return tag_init_uw(result, a->data.uw >> b->data.u16);
+ case TAG_U32:
+ return tag_init_uw(result, a->data.uw >> b->data.u32);
+ case TAG_U64:
+ return tag_init_uw(result, a->data.uw >> b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(result, a->data.uw >> b->data.uw);
+ default:
+ goto error;
+ }
+ goto error;
+ default:
+ goto error;
+ }
+ error:
+ warnx("tag_shift_right: invalid tag type: %s >> %s",
+ tag_type_to_string(a->type),
+ tag_type_to_string(b->type));
+ return NULL;
+}
diff --git a/libc3/tag_sub.c b/libc3/tag_sub.c
new file mode 100644
index 0000000..800a6a6
--- /dev/null
+++ b/libc3/tag_sub.c
@@ -0,0 +1,570 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <err.h>
+#include <math.h>
+#include "integer.h"
+#include "tag.h"
+
+s_tag * tag_sub (const s_tag *a, const s_tag *b, s_tag *dest)
+{
+ s_integer tmp;
+ s_integer tmp2;
+ assert(a);
+ assert(b);
+ assert(dest);
+ switch (a->type) {
+ case TAG_F32:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.f32 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.f32 - b->data.f64);
+ case TAG_INTEGER:
+ return tag_init_f32(dest, a->data.f32 -
+ integer_to_f32(&b->data.integer));
+ case TAG_S8:
+ return tag_init_f32(dest, a->data.f32 - b->data.s8);
+ case TAG_S16:
+ return tag_init_f32(dest, a->data.f32 - b->data.s16);
+ case TAG_S32:
+ return tag_init_f32(dest, a->data.f32 - b->data.s32);
+ case TAG_S64:
+ return tag_init_f32(dest, a->data.f32 - b->data.s64);
+ case TAG_U8:
+ return tag_init_f32(dest, a->data.f32 - b->data.u8);
+ case TAG_U16:
+ return tag_init_f32(dest, a->data.f32 - b->data.u16);
+ case TAG_U32:
+ return tag_init_f32(dest, a->data.f32 - b->data.u32);
+ case TAG_U64:
+ return tag_init_f32(dest, a->data.f32 - b->data.u64);
+ default:
+ goto ko;
+ }
+ case TAG_F64:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f64(dest, a->data.f64 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.f64 - b->data.f64);
+ case TAG_INTEGER:
+ return tag_init_f64(dest, a->data.f64 -
+ integer_to_f64(&b->data.integer));
+ case TAG_S8:
+ return tag_init_f64(dest, a->data.f64 - b->data.s8);
+ case TAG_S16:
+ return tag_init_f64(dest, a->data.f64 - b->data.s16);
+ case TAG_S32:
+ return tag_init_f64(dest, a->data.f64 - b->data.s32);
+ case TAG_S64:
+ return tag_init_f64(dest, a->data.f64 - b->data.s64);
+ case TAG_U8:
+ return tag_init_f64(dest, a->data.f64 - b->data.u8);
+ case TAG_U16:
+ return tag_init_f64(dest, a->data.f64 - b->data.u16);
+ case TAG_U32:
+ return tag_init_f64(dest, a->data.f64 - b->data.u32);
+ case TAG_U64:
+ return tag_init_f64(dest, a->data.f64 - b->data.u64);
+ default:
+ goto ko;
+ }
+ case TAG_INTEGER:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, integer_to_f64(&a->data.integer) -
+ b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, integer_to_f64(&a->data.integer) -
+ b->data.f64);
+ case TAG_INTEGER:
+ dest->type = TAG_INTEGER;
+ integer_sub(&a->data.integer, &b->data.integer,
+ &dest->data.integer);
+ return dest;
+ case TAG_S8:
+ integer_init_s8(&tmp, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_sub(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S16:
+ integer_init_s16(&tmp, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_sub(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S32:
+ integer_init_s32(&tmp, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_sub(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S64:
+ integer_init_s64(&tmp, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_U8:
+ integer_init_u8(&tmp, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_sub(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_U16:
+ integer_init_u16(&tmp, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_sub(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_U32:
+ integer_init_u32(&tmp, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_sub(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_U64:
+ integer_init_u64(&tmp, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S8:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.s8 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.s8 - b->data.f64);
+ case TAG_INTEGER:
+ integer_init_s8(&tmp, a->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s16(dest, (s16) a->data.s8 - (s16) b->data.s8);
+ case TAG_S16:
+ return tag_init_s32(dest, (s32) a->data.s8 - (s32) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.s8 - (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_s16(dest, (s16) a->data.s8 - (s16) b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(dest, (s32) a->data.s8 - (s32) b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(dest, (s64) a->data.s8 - (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S16:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.s16 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.s16 - b->data.f64);
+ case TAG_INTEGER:
+ integer_init_s16(&tmp, a->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s16(dest, a->data.s16 - b->data.s8);
+ case TAG_S16:
+ return tag_init_s16(dest, a->data.s16 - b->data.s16);
+ case TAG_S32:
+ return tag_init_s32(dest, a->data.s16 - b->data.s32);
+ case TAG_S64:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_s32(dest, (s32) a->data.s16 - (s32) b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(dest, (s32) a->data.s16 - (s32) b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(dest, (s64) a->data.s16 - (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S32:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.s32 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.s32 - b->data.f64);
+ case TAG_INTEGER:
+ integer_init_s32(&tmp, a->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.s8);
+ case TAG_S16:
+ return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.u8);
+ case TAG_U16:
+ return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(dest, (s64) a->data.s32 - (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_S64:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.s64 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.s64 - b->data.f64);
+ case TAG_INTEGER:
+ integer_init_s64(&tmp, a->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s8(&tmp2, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S16:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s16(&tmp2, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S32:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s32(&tmp2, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S64:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u8(&tmp2, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U16:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u16(&tmp2, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U32:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u32(&tmp2, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U64:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_U8:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.u8 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.u8 - b->data.f64);
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, a->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s16(dest, (s16) a->data.u8 - (s16) b->data.s8);
+ case TAG_S16:
+ return tag_init_s32(dest, (s32) a->data.u8 - (s32) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.u8 - (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_s16(dest, (s16) a->data.u8 - (s16) b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(dest, (s32) a->data.u8 - (s32) b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(dest, (s64) a->data.u8 - (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_U16:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.u16 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.u16 - b->data.f64);
+ case TAG_INTEGER:
+ integer_init_u16(&tmp, a->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s32(dest, (s32) a->data.u16 - (s32) b->data.s8);
+ case TAG_S16:
+ return tag_init_s32(dest, (s32) a->data.u16 - (s32) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.u16 - (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_u16(&tmp, a->data.u16);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_s32(dest, (s32) a->data.u16 - (s32) b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(dest, (s32) a->data.u16 - (s32) b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(dest, (s64) a->data.u16 - (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_u16(&tmp, a->data.u16);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_U32:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.u32 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.u32 - b->data.f64);
+ case TAG_INTEGER:
+ integer_init_u32(&tmp, a->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.s8);
+ case TAG_S16:
+ return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.s16);
+ case TAG_S32:
+ return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.s32);
+ case TAG_S64:
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.u8);
+ case TAG_U16:
+ return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(dest, (s64) a->data.u32 - (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ case TAG_U64:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, a->data.u64 - b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, a->data.u64 - b->data.f64);
+ case TAG_INTEGER:
+ integer_init_u64(&tmp, a->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s8(&tmp2, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S16:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s16(&tmp2, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S32:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s32(&tmp2, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_S64:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u8(&tmp2, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U16:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u16(&tmp2, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U32:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u32(&tmp2, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U64:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_sub(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ default:
+ goto ko;
+ }
+ default:
+ goto ko;
+ }
+ ko:
+ errx(1, "cannot subtract %s by %s",
+ tag_type_to_string(a->type),
+ tag_type_to_string(b->type));
+}
diff --git a/libc3/window/cairo/demo/flies.c b/libc3/window/cairo/demo/flies.c
new file mode 100644
index 0000000..1c8411b
--- /dev/null
+++ b/libc3/window/cairo/demo/flies.c
@@ -0,0 +1,141 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <math.h>
+#include <libc3/c3.h>
+#include "../window_cairo.h"
+#include "flies.h"
+
+#define BOARD_SIZE 25
+
+static const character g_block = 0x2588;
+static const character g_fly = 0x1FAB0;
+static const character g_space = ' ';
+
+bool flies_load (s_sequence *seq,
+ s_window_cairo *window)
+{
+ uw address[2];
+ s_array *board;
+ uw i;
+ uw j;
+ s_map *map;
+ (void) window;
+ tag_map(&seq->tag, 1);
+ map = &seq->tag.data.map;
+ tag_init_sym_1( map->keys + 0, "board");
+ tag_init_array(map->values + 0, sym_1("Character"),
+ 2, (uw[]) {BOARD_SIZE, BOARD_SIZE});
+ board = &map->values[0].data.array;
+ i = 0;
+ while (i < BOARD_SIZE) {
+ address[0] = i;
+ j = 0;
+ while (j < BOARD_SIZE) {
+ address[1] = j;
+ array_data_set(board, address, &g_space);
+ j++;
+ }
+ i++;
+ }
+ i = 0;
+ while (i < BOARD_SIZE) {
+ address[0] = i;
+ address[1] = 0;
+ array_data_set(board, address, &g_block);
+ address[1] = BOARD_SIZE - 1;
+ array_data_set(board, address, &g_block);
+ address[0] = 0;
+ address[1] = i;
+ array_data_set(board, address, &g_block);
+ address[0] = BOARD_SIZE - 1;
+ array_data_set(board, address, &g_block);
+ i++;
+ }
+ address[0] = BOARD_SIZE / 2;
+ address[1] = 0;
+ array_data_set(board, address, &g_space);
+ address[1] = BOARD_SIZE - 1;
+ array_data_set(board, address, &g_space);
+ address[1] = BOARD_SIZE / 2;
+ i = 1;
+ while (i < BOARD_SIZE * 3 / 4) {
+ address[0] = i;
+ array_data_set(board, address, &g_block);
+ i++;
+ }
+ address[0] = BOARD_SIZE * 3 / 4 - 1;
+ j = BOARD_SIZE / 4;
+ while (j < BOARD_SIZE / 2 - 1) {
+ address[1] = j;
+ array_data_set(board, address, &g_block);
+ j++;
+ }
+ address[1] = BOARD_SIZE * 3 / 4;
+ i = BOARD_SIZE / 4;
+ while (i < BOARD_SIZE - 1) {
+ address[0] = i;
+ array_data_set(board, address, &g_block);
+ i++;
+ }
+ return true;
+}
+
+bool flies_render (s_sequence *seq, s_window_cairo *window,
+ cairo_t *cr)
+{
+ uw address[2];
+ s_array *board;
+ s_buf buf;
+ character *c;
+ uw i;
+ s8 line[BOARD_SIZE * 4 + 1];
+ s_map *map;
+ cairo_text_extents_t te;
+ cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
+ cairo_rectangle(cr, 0, 0, window->w, window->h);
+ cairo_fill(cr);
+ cairo_set_font_size(cr, window->h / BOARD_SIZE);
+ cairo_select_font_face(cr, "Courier New",
+ CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
+ i = 0;
+ while (i < BOARD_SIZE) {
+ line[i] = ' ';
+ i++;
+ }
+ line[i] = 0;
+ cairo_text_extents(cr, line, &te);
+ /* io_inspect(&seq->tag); */
+ if (seq->tag.type == TAG_MAP) {
+ map = &seq->tag.data.map;
+ if (map->count > 0 && map->values[0].type == TAG_ARRAY) {
+ board = &map->values[0].data.array;
+ address[1] = 0;
+ while (address[1] < BOARD_SIZE) {
+ address[0] = 0;
+ buf_init(&buf, false, sizeof(line), line);
+ while (address[0] < BOARD_SIZE) {
+ c = (character *) array_data(board, address);
+ buf_write_character_utf8(&buf, *c);
+ address[0]++;
+ }
+ buf_write_u8(&buf, 0);
+
+ address[1]++;
+ }
+ address[0] = BOARD_SIZE / 2;
+ address[1] = 0;
+ array_data_set(board, address, &g_fly);
+ }
+ }
+ return true;
+}
diff --git a/libc3/window/cairo/demo/flies.h b/libc3/window/cairo/demo/flies.h
new file mode 100644
index 0000000..abff47b
--- /dev/null
+++ b/libc3/window/cairo/demo/flies.h
@@ -0,0 +1,22 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#ifndef FLIES_H
+#define FLIES_H
+
+#include "../types.h"
+
+bool flies_load (s_sequence *seq, s_window_cairo *window);
+bool flies_render (s_sequence *seq, s_window_cairo *window,
+ cairo_t *cr);
+
+#endif /* FLIES_H */
diff --git a/libc3/window/cairo/demo/lightspeed.c b/libc3/window/cairo/demo/lightspeed.c
index 1db1a4e..395bc5d 100644
--- a/libc3/window/cairo/demo/lightspeed.c
+++ b/libc3/window/cairo/demo/lightspeed.c
@@ -57,8 +57,7 @@ bool lightspeed_load (s_sequence *seq, s_window_cairo *window)
{
uw i;
(void) window;
- tag_clean(&seq->tag);
- tag_init_tuple(&seq->tag, LIGHTSPEED_STARS);
+ tag_tuple(&seq->tag, LIGHTSPEED_STARS);
i = 0;
while (i < LIGHTSPEED_STARS) {
star_init(seq->tag.data.tuple.tag + i);
diff --git a/libc3/window/cairo/demo/sources.mk b/libc3/window/cairo/demo/sources.mk
index d98f3d4..3714ca2 100644
--- a/libc3/window/cairo/demo/sources.mk
+++ b/libc3/window/cairo/demo/sources.mk
@@ -1,12 +1,14 @@
# sources.mk generated by update_sources
HEADERS = \
bg_rect.h \
+ flies.h \
lightspeed.h \
toasters.h \
window_cairo_demo.h \
SOURCES = \
bg_rect.c \
+ flies.c \
lightspeed.c \
toasters.c \
window_cairo_demo.c \
diff --git a/libc3/window/cairo/demo/sources.sh b/libc3/window/cairo/demo/sources.sh
index 4bff3a2..0534e8b 100644
--- a/libc3/window/cairo/demo/sources.sh
+++ b/libc3/window/cairo/demo/sources.sh
@@ -1,3 +1,3 @@
# sources.sh generated by update_sources
-HEADERS='bg_rect.h lightspeed.h toasters.h window_cairo_demo.h '
-SOURCES='bg_rect.c lightspeed.c toasters.c window_cairo_demo.c '
+HEADERS='bg_rect.h flies.h lightspeed.h toasters.h window_cairo_demo.h '
+SOURCES='bg_rect.c flies.c lightspeed.c toasters.c window_cairo_demo.c '
diff --git a/libc3/window/cairo/demo/toasters.c b/libc3/window/cairo/demo/toasters.c
index bcff595..d706b0b 100644
--- a/libc3/window/cairo/demo/toasters.c
+++ b/libc3/window/cairo/demo/toasters.c
@@ -104,8 +104,7 @@ bool toasters_load (s_sequence *seq,
{
s_map *map;
(void) window;
- tag_clean(&seq->tag);
- tag_init_map(&seq->tag, 2);
+ tag_map(&seq->tag, 2);
map = &seq->tag.data.map;
tag_init_sym_1( map->keys + 0, "toasters");
tag_init_list(map->values + 0, NULL);
diff --git a/sources.mk b/sources.mk
index f70e822..d8dda0f 100644
--- a/sources.mk
+++ b/sources.mk
@@ -7,26 +7,26 @@ C3_CONFIGURES = \
ic3/update_sources \
libc3/configure \
libc3/update_sources \
- libc3/window/configure \
- libc3/window/update_sources \
- libc3/window/cairo/demo/configure \
- libc3/window/cairo/demo/update_sources \
- libc3/window/cairo/xcb/demo/configure \
- libc3/window/cairo/xcb/demo/update_sources \
libc3/window/cairo/xcb/configure \
libc3/window/cairo/xcb/update_sources \
+ libc3/window/cairo/xcb/demo/update_sources \
+ libc3/window/cairo/xcb/demo/configure \
libc3/window/cairo/configure \
- libc3/window/cairo/update_sources \
- libc3/window/cairo/quartz/demo/configure \
- libc3/window/cairo/quartz/demo/update_sources \
libc3/window/cairo/quartz/configure \
libc3/window/cairo/quartz/update_sources \
+ libc3/window/cairo/quartz/demo/configure \
+ libc3/window/cairo/quartz/demo/update_sources \
+ libc3/window/cairo/demo/configure \
+ libc3/window/cairo/demo/update_sources \
+ libc3/window/cairo/update_sources \
+ libc3/window/cairo/win32/configure \
libc3/window/cairo/win32/demo/configure \
libc3/window/cairo/win32/demo/update_sources \
- libc3/window/cairo/win32/configure \
libc3/window/cairo/win32/update_sources \
- libtommath/configure \
+ libc3/window/configure \
+ libc3/window/update_sources \
libtommath/update_sources \
+ libtommath/configure \
test/configure \
test/update_sources \
ucd2c/configure \
@@ -35,17 +35,17 @@ C3_MAKEFILES = \
c3c/Makefile \
c3s/Makefile \
ic3/Makefile \
- libc3/Makefile \
libc3/gen.mk \
- libc3/window/Makefile \
- libc3/window/cairo/demo/Makefile \
- libc3/window/cairo/xcb/demo/Makefile \
+ libc3/Makefile \
libc3/window/cairo/xcb/Makefile \
+ libc3/window/cairo/xcb/demo/Makefile \
libc3/window/cairo/Makefile \
- libc3/window/cairo/quartz/demo/Makefile \
libc3/window/cairo/quartz/Makefile \
- libc3/window/cairo/win32/demo/Makefile \
+ libc3/window/cairo/quartz/demo/Makefile \
+ libc3/window/cairo/demo/Makefile \
libc3/window/cairo/win32/Makefile \
+ libc3/window/cairo/win32/demo/Makefile \
+ libc3/window/Makefile \
libtommath/Makefile \
test/Makefile \
ucd2c/Makefile \
@@ -55,387 +55,394 @@ C3_C_SOURCES = \
c3s/buf_readline.c \
c3s/c3s.c \
c3s/buf_readline.h \
- ic3/buf_linenoise.h \
ic3/ic3.c \
- ic3/linenoise.c \
ic3/buf_linenoise.c \
- libc3/buf_inspect_s_base.c.in \
- libc3/type.h \
- libc3/fact.c \
- libc3/time.h \
- libc3/fn.h \
- libc3/s16.h \
- libc3/buf_inspect_s8_octal.h \
- libc3/log.c \
- libc3/error.h \
- libc3/buf_inspect_u64_octal.h \
- libc3/set_item.h.in \
- libc3/compare.c \
- libc3/buf_inspect_s8_binary.h \
- libc3/buf_inspect_uw_hexadecimal.h \
- libc3/uw.c \
- libc3/eval.c \
- libc3/set__fact.c \
- libc3/sym.h \
- libc3/env.h \
- libc3/cfn.c \
- libc3/buf_inspect_u16_octal.h \
- libc3/u.h.in \
- libc3/buf_parse_s16.c \
- libc3/s8.h \
- libc3/quote.h \
- libc3/buf_inspect_s32.h \
- libc3/buf_inspect.c \
- libc3/buf_parse_u.h.in \
- libc3/skiplist_node__fact.h \
- libc3/skiplist__fact.c \
- libc3/tag_add.c \
- libc3/buf_inspect_s32_hexadecimal.h \
- libc3/ceiling.h \
- libc3/list.c \
- libc3/buf_inspect_u64.c \
- libc3/facts.h \
- libc3/buf_inspect_u16_decimal.c \
- libc3/facts_with_cursor.c \
- libc3/buf_inspect_sw_decimal.c \
- libc3/facts_cursor.c \
- libc3/buf_inspect_u64_binary.h \
- libc3/buf_inspect_sw_hexadecimal.h \
- libc3/buf_inspect_s32_decimal.h \
- libc3/u16.h \
- libc3/buf_inspect_s64_octal.h \
- libc3/buf_inspect_u8_binary.h \
+ ic3/buf_linenoise.h \
+ ic3/linenoise.c \
+ libc3/abs.c \
+ libc3/buf.c \
+ libc3/buf_inspect_s8.c \
libc3/buf_inspect_s8.h \
- libc3/buf_inspect_s16_octal.h \
- libc3/ucd.c \
- libc3/buf_inspect_s16_binary.h \
- libc3/tuple.c \
- libc3/buf_inspect_uw_octal.h \
- libc3/buf_parse_u8.c \
- libc3/tag.h \
- libc3/float.h \
- libc3/buf_inspect_u_base.c.in \
- libc3/buf_parse_u16.c \
- libc3/buf_inspect_u16_hexadecimal.h \
+ libc3/buf_inspect_s8_binary.c \
+ libc3/buf_inspect_s8_binary.h \
+ libc3/buf_inspect_s8_octal.c \
+ libc3/buf_inspect_s8_octal.h \
libc3/buf_inspect_s8_decimal.c \
- libc3/buf_inspect_u32.h \
- libc3/array.c \
- libc3/buf_parse_sw.h \
- libc3/set.h.in \
- libc3/s.c.in \
- libc3/buf_parse_s.c.in \
- libc3/map.h \
- libc3/skiplist.h.in \
- libc3/set__tag.h \
- libc3/buf_inspect_s64.c \
- libc3/io.c \
- libc3/set_item__tag.c \
- libc3/sequence.c \
- libc3/types.h \
- libc3/buf_inspect_uw.c \
- libc3/buf_inspect_u32_binary.c \
- libc3/buf_inspect_s64_decimal.h \
- libc3/set_cursor.c.in \
- libc3/ident.c \
- libc3/buf_inspect_s64_hexadecimal.c \
- libc3/bool.h \
- libc3/s.h.in \
- libc3/set.c.in \
- libc3/skiplist.c.in \
- libc3/operator.h \
- libc3/fn_clause.h \
- libc3/buf_parse_s.h.in \
+ libc3/buf_inspect_s8_decimal.h \
+ libc3/array.h \
+ libc3/buf_inspect_s8_hexadecimal.c \
libc3/buf_inspect_s16.c \
+ libc3/call.c \
+ libc3/arg.c \
+ libc3/array.c \
libc3/binding.c \
- libc3/ptag.h \
- libc3/buf_parse_s32.h \
- libc3/tag_bor.c \
- libc3/var.h \
- libc3/set_item__fact.h \
- libc3/u8.c \
- libc3/set_cursor.h.in \
- libc3/f32.c \
- libc3/buf_inspect_sw_octal.h \
- libc3/c3.h \
- libc3/arg.h \
- libc3/buf_inspect_u8_hexadecimal.c \
- libc3/buf_inspect_u32_hexadecimal.h \
- libc3/buf_parse_u64.c \
- libc3/module.c \
- libc3/frame.h \
+ libc3/c3.c \
+ libc3/buf_inspect_s8_hexadecimal.h \
+ libc3/buf_inspect_s16.h \
+ libc3/buf_inspect_s16_binary.c \
+ libc3/buf_inspect_s16_binary.h \
+ libc3/buf_inspect_s16_octal.c \
+ libc3/buf_inspect_s16_octal.h \
libc3/buf_inspect_s16_decimal.c \
- libc3/file.h \
- libc3/sw.h \
- libc3/s32.c \
- libc3/error_handler.c \
- libc3/str.c \
- libc3/buf_parse.h \
- libc3/buf_inspect_uw_binary.c \
- libc3/buf_inspect_uw_decimal.h \
- libc3/facts_spec_cursor.c \
- libc3/u64.h \
- libc3/buf_inspect_u_base.h.in \
+ libc3/buf_inspect_s16_decimal.h \
+ libc3/buf_inspect_s16_hexadecimal.c \
+ libc3/buf_inspect_s16_hexadecimal.h \
+ libc3/buf_inspect_s32.c \
+ libc3/buf_inspect_s32.h \
+ libc3/s8.c \
+ libc3/env.c \
+ libc3/bool.c \
+ libc3/bool.h \
+ libc3/buf_file.c \
+ libc3/buf_inspect_s32_binary.c \
+ libc3/buf_inspect_s32_binary.h \
+ libc3/buf_inspect_s32_octal.c \
libc3/buf_inspect_s32_octal.h \
- libc3/f64.h \
- libc3/buf_inspect_u8_octal.h \
+ libc3/buf_inspect_s32_decimal.c \
+ libc3/buf_inspect_s32_decimal.h \
+ libc3/buf_inspect_s32_hexadecimal.c \
+ libc3/buf_inspect_s32_hexadecimal.h \
+ libc3/buf_inspect_s64.c \
+ libc3/buf_inspect_s64.h \
libc3/buf_inspect_s64_binary.c \
- libc3/buf_inspect_u64_hexadecimal.c \
- libc3/buf_inspect_u16_binary.c \
- libc3/buf_save.h \
- libc3/buf_inspect_u16.c \
- libc3/buf_inspect_s8_hexadecimal.c \
- libc3/u.c.in \
- libc3/buf_inspect_sw.h \
- libc3/facts_with.c \
- libc3/buf_parse_u.c.in \
- libc3/buf_parse_u32.h \
- libc3/set_cursor__fact.c \
+ libc3/buf_inspect_s64_binary.h \
+ libc3/buf_inspect_sw.c \
+ libc3/buf_parse.h \
libc3/buf.h \
- libc3/set_cursor__tag.h \
- libc3/buf_inspect_s16_hexadecimal.h \
- libc3/buf_inspect_u32_decimal.h \
- libc3/buf_parse_uw.c \
- libc3/buf_parse_s64.c \
- libc3/abs.h \
+ libc3/buf_save.c \
+ libc3/facts_spec_cursor.c \
+ libc3/buf_inspect_s64_octal.c \
+ libc3/buf_inspect_s64_octal.h \
+ libc3/buf_inspect_s64_decimal.c \
+ libc3/buf_inspect_s64_decimal.h \
+ libc3/buf_inspect_s64_hexadecimal.c \
+ libc3/buf_inspect_s64_hexadecimal.h \
+ libc3/buf_inspect_sw.h \
libc3/buf_inspect_sw_binary.c \
- libc3/buf_parse_s8.h \
+ libc3/buf_inspect_sw_binary.h \
+ libc3/buf_inspect_sw_octal.c \
+ libc3/buf_inspect_sw_octal.h \
+ libc3/buf_inspect_sw_decimal.c \
+ libc3/buf_file.h \
+ libc3/buf_save.h \
libc3/call.h \
- libc3/sign.c \
+ libc3/buf_inspect_sw_decimal.h \
+ libc3/buf_inspect_sw_hexadecimal.c \
+ libc3/buf_inspect_sw_hexadecimal.h \
+ libc3/buf_inspect_u8.c \
+ libc3/buf_inspect_u8.h \
+ libc3/buf_inspect_u8_binary.c \
+ libc3/buf_inspect_u8_binary.h \
+ libc3/buf_inspect_u8_octal.c \
+ libc3/buf_inspect_u8_octal.h \
+ libc3/buf_inspect_u8_decimal.c \
libc3/buf_inspect_u8_decimal.h \
+ libc3/buf_inspect_u16.c \
+ libc3/binding.h \
+ libc3/sequence.c \
+ libc3/io.c \
+ libc3/ceiling.c \
+ libc3/ceiling.h \
+ libc3/cfn.c \
+ libc3/cfn.h \
+ libc3/character.c \
libc3/character.h \
- libc3/buf_inspect_u64_decimal.h \
- libc3/buf_inspect_s_base.h.in \
- libc3/buf_inspect_u32_octal.h \
- libc3/u32.c \
- libc3/hash.c \
- libc3/buf_file.h \
- libc3/integer.c \
- libc3/buf_inspect_u8.c \
- libc3/facts_spec.c \
- libc3/buf_inspect_s32_binary.h \
- libc3/set_item.c.in \
- libc3/tag_bxor.c \
- libc3/s64.h \
+ libc3/buf_inspect_u8_hexadecimal.c \
+ libc3/buf_inspect_u8_hexadecimal.h \
+ libc3/buf_inspect_u16.h \
+ libc3/buf_inspect_u16_binary.c \
+ libc3/buf_inspect_u16_binary.h \
+ libc3/buf_inspect_u16_octal.c \
+ libc3/buf_inspect_u16_octal.h \
+ libc3/buf_inspect_u16_decimal.c \
libc3/buf_inspect_u16_decimal.h \
- libc3/facts.c \
- libc3/buf_inspect_u64.h \
- libc3/buf_inspect_sw_decimal.h \
- libc3/facts_with_cursor.h \
- libc3/skiplist_node__fact.c \
- libc3/buf_inspect.h \
- libc3/quote.c \
- libc3/buf_inspect_s32.c \
- libc3/skiplist_node.h.in \
- libc3/s8.c \
- libc3/buf_parse_s16.h \
- libc3/list.h \
- libc3/ceiling.c \
- libc3/buf_inspect_s.h.in \
- libc3/buf_inspect_s32_hexadecimal.c \
- libc3/skiplist__fact.h \
- libc3/uw.h \
- libc3/buf_inspect_uw_hexadecimal.c \
- libc3/buf_inspect_s8_binary.c \
+ libc3/buf_inspect_u16_hexadecimal.c \
+ libc3/buf_inspect_u16_hexadecimal.h \
+ libc3/compare.c \
+ libc3/buf_inspect.c \
libc3/compare.h \
+ libc3/buf_inspect_u32.c \
+ libc3/buf_inspect_u32.h \
+ libc3/buf_inspect_u32_binary.c \
+ libc3/buf_inspect_u32_binary.h \
+ libc3/buf_inspect_u32_octal.c \
+ libc3/buf_inspect_u32_octal.h \
+ libc3/buf_inspect_u32_decimal.c \
+ libc3/buf_inspect_u32_decimal.h \
+ libc3/buf_inspect_u32_hexadecimal.c \
+ libc3/buf_inspect_u32_hexadecimal.h \
+ libc3/buf_inspect_u64.c \
+ libc3/error.c \
+ libc3/error.h \
+ libc3/error_handler.c \
+ libc3/eval.h \
+ libc3/eval.c \
+ libc3/facts.h \
+ libc3/buf_inspect_u64.h \
+ libc3/buf_inspect_u64_binary.c \
+ libc3/buf_inspect_u64_binary.h \
libc3/buf_inspect_u64_octal.c \
- libc3/buf_inspect_u16_octal.c \
- libc3/tag_band.c \
- libc3/cfn.h \
- libc3/env.c \
+ libc3/buf_inspect_u64_octal.h \
+ libc3/buf_inspect_u64_decimal.c \
+ libc3/buf_inspect_u64_decimal.h \
+ libc3/buf_inspect_u64_hexadecimal.c \
+ libc3/buf_inspect_u64_hexadecimal.h \
+ libc3/buf_inspect_uw.c \
+ libc3/buf_inspect_uw.h \
+ libc3/set__fact.c \
+ libc3/file.h \
+ libc3/fact.c \
+ libc3/fact.h \
+ libc3/facts_cursor.c \
+ libc3/buf_inspect_uw_binary.c \
+ libc3/buf_inspect_uw_binary.h \
+ libc3/buf_inspect_uw_octal.c \
+ libc3/buf_inspect_uw_octal.h \
+ libc3/buf_inspect_uw_decimal.c \
+ libc3/buf_inspect_uw_decimal.h \
+ libc3/buf_inspect_uw_hexadecimal.c \
+ libc3/buf_inspect_uw_hexadecimal.h \
+ libc3/buf_parse_s8.c \
+ libc3/buf_parse_s8.h \
+ libc3/buf_parse_s16.c \
+ libc3/buf_parse_s16.h \
+ libc3/buf_parse_s32.c \
+ libc3/buf_parse_s32.h \
+ libc3/s8.h \
+ libc3/list.c \
+ libc3/facts_cursor.h \
+ libc3/facts_spec.c \
+ libc3/facts_spec.h \
+ libc3/facts_spec_cursor.h \
+ libc3/buf_parse_s64.c \
+ libc3/buf_parse_s64.h \
+ libc3/buf_parse_sw.c \
+ libc3/buf_parse_sw.h \
+ libc3/buf_parse_u8.c \
+ libc3/buf_parse_u8.h \
+ libc3/buf_parse_u16.c \
+ libc3/buf_parse_u16.h \
+ libc3/buf_parse_u32.c \
+ libc3/buf_parse_u32.h \
+ libc3/buf_parse_u64.c \
+ libc3/buf_parse_u64.h \
+ libc3/buf_parse_uw.c \
+ libc3/buf_parse_uw.h \
libc3/set__fact.h \
- libc3/sym.c \
- libc3/eval.h \
- libc3/c3_main.h \
- libc3/buf_inspect_s8_octal.c \
+ libc3/set__tag.c \
+ libc3/buf_parse_u.h.in \
+ libc3/facts_with.c \
+ libc3/facts_with.h \
+ libc3/facts_with_cursor.c \
+ libc3/set__tag.h \
+ libc3/set_cursor__fact.c \
+ libc3/set_cursor__fact.h \
+ libc3/set_cursor__tag.c \
+ libc3/set_cursor__tag.h \
+ libc3/set_item__fact.c \
+ libc3/set_item__fact.h \
+ libc3/set_item__tag.c \
+ libc3/set_item__tag.h \
+ libc3/skiplist__fact.c \
+ libc3/skiplist__fact.h \
+ libc3/skiplist_node__fact.c \
+ libc3/skiplist_node__fact.h \
libc3/s16.c \
- libc3/fn.c \
- libc3/time.c \
- libc3/fact.h \
- libc3/type.c \
- libc3/error.c \
+ libc3/s16.h \
+ libc3/s32.c \
+ libc3/s32.h \
+ libc3/s64.c \
+ libc3/facts_with_cursor.h \
+ libc3/float.h \
+ libc3/frame.c \
+ libc3/frame.h \
+ libc3/types.h \
+ libc3/s64.h \
+ libc3/sw.c \
+ libc3/sw.h \
+ libc3/u8.c \
+ libc3/u8.h \
+ libc3/u16.c \
+ libc3/f64.h \
+ libc3/u16.h \
+ libc3/u32.c \
+ libc3/f32.c \
+ libc3/f64.c \
+ libc3/u32.h \
+ libc3/u64.c \
+ libc3/u64.h \
+ libc3/uw.c \
+ libc3/uw.h \
+ libc3/hash.h \
+ libc3/ident.h \
+ libc3/integer.c \
+ libc3/integer.h \
+ libc3/list.h \
+ libc3/log.c \
libc3/log.h \
+ libc3/buf_inspect_s.h.in \
+ libc3/module.c \
+ libc3/buf_inspect.h \
+ libc3/c3_main.h \
+ libc3/map.c \
+ libc3/abs.h \
+ libc3/str.c \
+ libc3/module.h \
+ libc3/buf_parse_u.c.in \
+ libc3/quote.c \
+ libc3/quote.h \
+ libc3/set.c.in \
+ libc3/set.h.in \
+ libc3/buf_inspect_s_base.h.in \
libc3/sequence.h \
- libc3/set_item__tag.h \
- libc3/io.h \
- libc3/buf_inspect_s64.h \
- libc3/buf_inspect_s64_hexadecimal.h \
- libc3/window/types.h \
- libc3/window/window.h \
- libc3/window/cairo/demo/toasters.h \
- libc3/window/cairo/demo/window_cairo_demo.c \
- libc3/window/cairo/demo/lightspeed.h \
- libc3/window/cairo/demo/bg_rect.h \
- libc3/window/cairo/demo/window_cairo_demo.h \
- libc3/window/cairo/demo/toasters.c \
- libc3/window/cairo/demo/lightspeed.c \
- libc3/window/cairo/demo/bg_rect.c \
- libc3/window/cairo/xcb/demo/window_cairo_xcb_demo.c \
- libc3/window/cairo/xcb/window_cairo_xcb.h \
+ libc3/tag_mod.c \
+ libc3/tag_mul.c \
+ libc3/set_cursor.c.in \
+ libc3/set_cursor.h.in \
+ libc3/f32.h \
+ libc3/facts.c \
+ libc3/set_item.c.in \
+ libc3/set_item.h.in \
+ libc3/tag_sub.c \
+ libc3/tag_shift_right.c \
+ libc3/s.h.in \
+ libc3/sign.c \
+ libc3/sign.h \
+ libc3/skiplist.c.in \
+ libc3/skiplist.h.in \
+ libc3/type.h \
+ libc3/tag.c \
+ libc3/skiplist_node.c.in \
+ libc3/skiplist_node.h.in \
+ libc3/str.h \
+ libc3/tag.h \
+ libc3/ucd.c \
+ libc3/sym.h \
+ libc3/tuple.c \
+ libc3/tuple.h \
+ libc3/type.c \
+ libc3/ucd.h \
+ libc3/buf_parse_s.c.in \
+ libc3/buf_parse_s.h.in \
+ libc3/buf_inspect_s.c.in \
+ libc3/error_handler.h \
+ libc3/ident.c \
+ libc3/tag_bor.c \
+ libc3/tag_bxor.c \
+ libc3/buf_inspect_s_base.c.in \
+ libc3/buf_inspect_u.c.in \
+ libc3/buf_inspect_u.h.in \
+ libc3/env.h \
+ libc3/arg.h \
+ libc3/buf_inspect_u_base.c.in \
+ libc3/buf_inspect_u_base.h.in \
libc3/window/cairo/xcb/config.h \
libc3/window/cairo/xcb/window_cairo_xcb.c \
+ libc3/window/cairo/xcb/demo/window_cairo_xcb_demo.c \
+ libc3/window/cairo/xcb/window_cairo_xcb.h \
libc3/window/cairo/types.h \
+ libc3/window/cairo/window_cairo.h \
libc3/window/cairo/window_cairo.c \
- libc3/window/cairo/cairo_png.h \
- libc3/window/cairo/cairo_sprite.h \
- libc3/window/cairo/quartz/demo/window_cairo_quartz_demo.c \
- libc3/window/cairo/quartz/window_cairo_quartz_view_controller.h \
- libc3/window/cairo/quartz/quartz_to_xkbcommon.c \
libc3/window/cairo/quartz/window_cairo_quartz.h \
+ libc3/window/cairo/quartz/demo/window_cairo_quartz_demo.c \
libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.h \
- libc3/window/cairo/quartz/quartz_to_xkbcommon.h \
libc3/window/cairo/quartz/xkbquartz.h \
libc3/window/cairo/quartz/window_cairo_quartz_view.h \
- libc3/window/cairo/window_cairo.h \
+ libc3/window/cairo/quartz/window_cairo_quartz_view_controller.h \
+ libc3/window/cairo/quartz/quartz_to_xkbcommon.c \
+ libc3/window/cairo/quartz/quartz_to_xkbcommon.h \
+ libc3/window/cairo/demo/bg_rect.c \
+ libc3/window/cairo/demo/bg_rect.h \
+ libc3/window/cairo/demo/lightspeed.c \
+ libc3/window/cairo/demo/lightspeed.h \
+ libc3/window/cairo/demo/window_cairo_demo.c \
+ libc3/window/cairo/demo/window_cairo_demo.h \
+ libc3/window/cairo/demo/toasters.c \
+ libc3/window/cairo/demo/flies.h \
+ libc3/window/cairo/demo/toasters.h \
+ libc3/window/cairo/demo/flies.c \
+ libc3/window/cairo/cairo_png.c \
libc3/window/cairo/win32/demo/window_cairo_win32_demo.c \
libc3/window/cairo/win32/vk_to_xkbcommon.c \
- libc3/window/cairo/win32/window_cairo_win32.h \
libc3/window/cairo/win32/vk_to_xkbcommon.h \
libc3/window/cairo/win32/window_cairo_win32.c \
+ libc3/window/cairo/win32/window_cairo_win32.h \
+ libc3/window/cairo/cairo_png.h \
libc3/window/cairo/cairo_sprite.c \
- libc3/window/cairo/cairo_png.c \
+ libc3/window/cairo/cairo_sprite.h \
+ libc3/window/types.h \
libc3/window/window.c \
- libc3/ident.h \
- libc3/buf_inspect_s64_decimal.c \
- libc3/buf_inspect_u32_binary.h \
- libc3/buf_inspect_uw.h \
- libc3/buf_inspect_u.c.in \
- libc3/buf_parse_sw.c \
- libc3/array.h \
- libc3/buf_inspect_u32.c \
- libc3/buf_inspect_s8_decimal.h \
- libc3/buf_inspect_u16_hexadecimal.c \
- libc3/buf_parse_u16.h \
- libc3/set__tag.c \
- libc3/map.c \
- libc3/tag.c \
- libc3/buf_parse_u8.h \
- libc3/buf_inspect_uw_octal.c \
- libc3/buf_inspect_u8_binary.c \
- libc3/buf_inspect_s64_octal.c \
- libc3/u16.c \
- libc3/buf_inspect_sw_hexadecimal.c \
- libc3/buf_inspect_s32_decimal.c \
- libc3/buf_inspect_u64_binary.c \
- libc3/facts_cursor.h \
- libc3/tuple.h \
- libc3/buf_inspect_s16_binary.c \
- libc3/ucd.h \
- libc3/buf_inspect_s16_octal.c \
- libc3/buf_inspect_s8.c \
- libc3/sha1.h \
- libc3/buf_inspect_uw_binary.h \
+ libc3/window/window.h \
libc3/buf_parse.c \
- libc3/str.h \
- libc3/error_handler.h \
- libc3/u64.c \
- libc3/buf_inspect_s32_octal.c \
- libc3/facts_spec_cursor.h \
- libc3/buf_inspect_uw_decimal.c \
- libc3/sw.c \
+ libc3/u.c.in \
+ libc3/fn.c \
+ libc3/u.h.in \
+ libc3/sha1.h \
+ libc3/c3.h \
+ libc3/fn.h \
+ libc3/map.h \
libc3/file.c \
- libc3/buf_inspect_s16_decimal.h \
- libc3/frame.c \
- libc3/s32.h \
- libc3/c3.c \
- libc3/f32.h \
- libc3/buf_inspect_sw_octal.c \
- libc3/u8.h \
- libc3/set_item__fact.c \
- libc3/var.c \
- libc3/module.h \
libc3/license.c \
- libc3/buf_inspect_u32_hexadecimal.c \
- libc3/buf_parse_u64.h \
- libc3/buf_inspect_u8_hexadecimal.h \
- libc3/arg.c \
- libc3/fn_clause.c \
libc3/operator.c \
- libc3/bool.c \
- libc3/buf_parse_s32.c \
+ libc3/ptag.h \
+ libc3/tag_add.c \
+ libc3/tag_band.c \
+ libc3/fn_clause.h \
+ libc3/s.c.in \
+ libc3/operator.h \
+ libc3/sym.c \
+ libc3/fn_clause.c \
+ libc3/io.h \
libc3/ptag.c \
- libc3/binding.h \
- libc3/buf_inspect_u.h.in \
- libc3/buf_inspect_s16.h \
- libc3/integer.h \
- libc3/buf_file.c \
- libc3/s64.c \
- libc3/buf_inspect_s32_binary.c \
- libc3/buf_inspect_u8.h \
- libc3/facts_spec.h \
- libc3/buf_inspect_u8_decimal.c \
- libc3/sign.h \
- libc3/call.c \
- libc3/buf_parse_s8.c \
- libc3/buf_inspect_sw_binary.h \
- libc3/hash.h \
- libc3/u32.h \
- libc3/buf_inspect_u32_octal.c \
- libc3/character.c \
- libc3/buf_inspect_u64_decimal.c \
- libc3/buf_parse_uw.h \
- libc3/buf_inspect_u32_decimal.c \
- libc3/buf_inspect_s16_hexadecimal.c \
- libc3/set_cursor__tag.c \
- libc3/set_cursor__fact.h \
- libc3/buf.c \
- libc3/abs.c \
- libc3/buf_parse_s64.h \
- libc3/buf_inspect_s.c.in \
- libc3/buf_inspect_s64_binary.h \
- libc3/buf_inspect_u8_octal.c \
- libc3/f64.c \
- libc3/skiplist_node.c.in \
- libc3/buf_parse_u32.c \
- libc3/facts_with.h \
- libc3/buf_inspect_sw.c \
- libc3/buf_inspect_u16.h \
- libc3/buf_inspect_s8_hexadecimal.h \
- libc3/buf_inspect_u16_binary.h \
- libc3/buf_inspect_u64_hexadecimal.h \
- libc3/buf_save.c \
- test/ident_test.c \
- test/buf_parse_test_s16.c \
+ libc3/var.h \
+ libc3/var.c \
+ libc3/time.c \
+ libc3/time.h \
+ libc3/tag_shift_left.c \
+ libc3/hash.c \
test/buf_inspect_test.c \
- test/libc3_test.c \
- test/fn_test.c \
+ test/bool_test.c \
+ test/buf_parse_test.c \
+ test/facts_test.c \
+ test/buf_file_test.c \
+ test/list_test.c \
+ test/test.c \
+ test/test.h \
+ test/buf_parse_test_u8.c \
+ test/buf_parse_test.h \
+ test/buf_parse_test_s16.c \
+ test/buf_parse_test_s32.c \
+ test/buf_parse_test_s64.c \
+ test/buf_parse_test_s8.c \
+ test/buf_parse_test_su.h \
test/buf_parse_test_u16.c \
- test/str_test.c \
+ test/buf_parse_test_u32.c \
+ test/buf_test.c \
+ test/buf_parse_test_u64.c \
+ test/call_test.c \
+ test/facts_cursor_test.c \
test/cfn_test.c \
test/character_test.c \
- test/buf_parse_test_s8.c \
- test/skiplist__fact_test.c \
- test/sym_test.c \
- test/tag_test.h \
- test/buf_file_test.c \
- test/bool_test.c \
+ test/env_test.c \
+ test/fact_test.c \
test/fact_test.h \
- test/buf_parse_test_u64.c \
- test/compare_test.c \
+ test/libc3_test.c \
+ test/str_test.c \
test/facts_with_test.c \
- test/array_test.c \
- test/buf_parse_test.h \
- test/test.h \
- test/buf_parse_test_su.h \
- test/env_test.c \
- test/buf_parse_test_s64.c \
- test/types_test.c \
test/hash_test.c \
- test/call_test.c \
- test/set__tag_test.c \
- test/facts_test.c \
- test/facts_cursor_test.c \
+ test/compare_test.c \
test/compare_test.h \
- test/buf_parse_test_s32.c \
- test/test.c \
- test/buf_parse_test.c \
- test/fact_test.c \
- test/tag_test.c \
+ test/ident_test.c \
test/set__fact_test.c \
- test/buf_parse_test_u32.c \
- test/buf_test.c \
- test/list_test.c \
- test/buf_parse_test_u8.c \
+ test/set__tag_test.c \
+ test/skiplist__fact_test.c \
+ test/sym_test.c \
+ test/tag_test.c \
+ test/tag_test.h \
+ test/array_test.c \
+ test/fn_test.c \
test/tuple_test.c \
+ test/types_test.c \
ucd2c/ucd.h \
ucd2c/ucd2c.c \
diff --git a/sources.sh b/sources.sh
index e20d3fc..a07b16e 100644
--- a/sources.sh
+++ b/sources.sh
@@ -1,4 +1,4 @@
# sources.sh generated by update_sources
-C3_CONFIGURES='c3c/configure c3s/configure c3s/update_sources ic3/configure ic3/update_sources libc3/configure libc3/update_sources libc3/window/configure libc3/window/update_sources libc3/window/cairo/demo/configure libc3/window/cairo/demo/update_sources libc3/window/cairo/xcb/demo/configure libc3/window/cairo/xcb/demo/update_sources libc3/window/cairo/xcb/configure libc3/window/cairo/xcb/update_sources libc3/window/cairo/configure libc3/window/cairo/update_sources libc3/window/cairo/quartz/demo/configure libc3/window/cairo/quartz/demo/update_sources libc3/window/cairo/quartz/configure libc3/window/cairo/quartz/update_sources libc3/window/cairo/win32/demo/configure libc3/window/cairo/win32/demo/update_sources libc3/window/cairo/win32/configure libc3/window/cairo/win32/update_sources libtommath/configure libtommath/update_sources test/configure test/update_sources ucd2c/configure '
-C3_MAKEFILES='c3c/Makefile c3s/Makefile ic3/Makefile libc3/Makefile libc3/gen.mk libc3/window/Makefile libc3/window/cairo/demo/Makefile libc3/window/cairo/xcb/demo/Makefile libc3/window/cairo/xcb/Makefile libc3/window/cairo/Makefile libc3/window/cairo/quartz/demo/Makefile libc3/window/cairo/quartz/Makefile libc3/window/cairo/win32/demo/Makefile libc3/window/cairo/win32/Makefile libtommath/Makefile test/Makefile ucd2c/Makefile '
-C3_C_SOURCES='c3c/c3c.c c3s/buf_readline.c c3s/c3s.c c3s/buf_readline.h ic3/buf_linenoise.h ic3/ic3.c ic3/linenoise.c ic3/buf_linenoise.c libc3/buf_inspect_s_base.c.in libc3/type.h libc3/fact.c libc3/time.h libc3/fn.h libc3/s16.h libc3/buf_inspect_s8_octal.h libc3/log.c libc3/error.h libc3/buf_inspect_u64_octal.h libc3/set_item.h.in libc3/compare.c libc3/buf_inspect_s8_binary.h libc3/buf_inspect_uw_hexadecimal.h libc3/uw.c libc3/eval.c libc3/set__fact.c libc3/sym.h libc3/env.h libc3/cfn.c libc3/buf_inspect_u16_octal.h libc3/u.h.in libc3/buf_parse_s16.c libc3/s8.h libc3/quote.h libc3/buf_inspect_s32.h libc3/buf_inspect.c libc3/buf_parse_u.h.in libc3/skiplist_node__fact.h libc3/skiplist__fact.c libc3/tag_add.c libc3/buf_inspect_s32_hexadecimal.h libc3/ceiling.h libc3/list.c libc3/buf_inspect_u64.c libc3/facts.h libc3/buf_inspect_u16_decimal.c libc3/facts_with_cursor.c libc3/buf_inspect_sw_decimal.c libc3/facts_cursor.c libc3/buf_inspect_u64_binary.h libc3/buf_inspect_sw_hexadecimal.h libc3/buf_inspect_s32_decimal.h libc3/u16.h libc3/buf_inspect_s64_octal.h libc3/buf_inspect_u8_binary.h libc3/buf_inspect_s8.h libc3/buf_inspect_s16_octal.h libc3/ucd.c libc3/buf_inspect_s16_binary.h libc3/tuple.c libc3/buf_inspect_uw_octal.h libc3/buf_parse_u8.c libc3/tag.h libc3/float.h libc3/buf_inspect_u_base.c.in libc3/buf_parse_u16.c libc3/buf_inspect_u16_hexadecimal.h libc3/buf_inspect_s8_decimal.c libc3/buf_inspect_u32.h libc3/array.c libc3/buf_parse_sw.h libc3/set.h.in libc3/s.c.in libc3/buf_parse_s.c.in libc3/map.h libc3/skiplist.h.in libc3/set__tag.h libc3/buf_inspect_s64.c libc3/io.c libc3/set_item__tag.c libc3/sequence.c libc3/types.h libc3/buf_inspect_uw.c libc3/buf_inspect_u32_binary.c libc3/buf_inspect_s64_decimal.h libc3/set_cursor.c.in libc3/ident.c libc3/buf_inspect_s64_hexadecimal.c libc3/bool.h libc3/s.h.in libc3/set.c.in libc3/skiplist.c.in libc3/operator.h libc3/fn_clause.h libc3/buf_parse_s.h.in libc3/buf_inspect_s16.c libc3/binding.c libc3/ptag.h libc3/buf_parse_s32.h libc3/tag_bor.c libc3/var.h libc3/set_item__fact.h libc3/u8.c libc3/set_cursor.h.in libc3/f32.c libc3/buf_inspect_sw_octal.h libc3/c3.h libc3/arg.h libc3/buf_inspect_u8_hexadecimal.c libc3/buf_inspect_u32_hexadecimal.h libc3/buf_parse_u64.c libc3/module.c libc3/frame.h libc3/buf_inspect_s16_decimal.c libc3/file.h libc3/sw.h libc3/s32.c libc3/error_handler.c libc3/str.c libc3/buf_parse.h libc3/buf_inspect_uw_binary.c libc3/buf_inspect_uw_decimal.h libc3/facts_spec_cursor.c libc3/u64.h libc3/buf_inspect_u_base.h.in libc3/buf_inspect_s32_octal.h libc3/f64.h libc3/buf_inspect_u8_octal.h libc3/buf_inspect_s64_binary.c libc3/buf_inspect_u64_hexadecimal.c libc3/buf_inspect_u16_binary.c libc3/buf_save.h libc3/buf_inspect_u16.c libc3/buf_inspect_s8_hexadecimal.c libc3/u.c.in libc3/buf_inspect_sw.h libc3/facts_with.c libc3/buf_parse_u.c.in libc3/buf_parse_u32.h libc3/set_cursor__fact.c libc3/buf.h libc3/set_cursor__tag.h libc3/buf_inspect_s16_hexadecimal.h libc3/buf_inspect_u32_decimal.h libc3/buf_parse_uw.c libc3/buf_parse_s64.c libc3/abs.h libc3/buf_inspect_sw_binary.c libc3/buf_parse_s8.h libc3/call.h libc3/sign.c libc3/buf_inspect_u8_decimal.h libc3/character.h libc3/buf_inspect_u64_decimal.h libc3/buf_inspect_s_base.h.in libc3/buf_inspect_u32_octal.h libc3/u32.c libc3/hash.c libc3/buf_file.h libc3/integer.c libc3/buf_inspect_u8.c libc3/facts_spec.c libc3/buf_inspect_s32_binary.h libc3/set_item.c.in libc3/tag_bxor.c libc3/s64.h libc3/buf_inspect_u16_decimal.h libc3/facts.c libc3/buf_inspect_u64.h libc3/buf_inspect_sw_decimal.h libc3/facts_with_cursor.h libc3/skiplist_node__fact.c libc3/buf_inspect.h libc3/quote.c libc3/buf_inspect_s32.c libc3/skiplist_node.h.in libc3/s8.c libc3/buf_parse_s16.h libc3/list.h libc3/ceiling.c libc3/buf_inspect_s.h.in libc3/buf_inspect_s32_hexadecimal.c libc3/skiplist__fact.h libc3/uw.h libc3/buf_inspect_uw_hexadecimal.c libc3/buf_inspect_s8_binary.c libc3/compare.h libc3/buf_inspect_u64_octal.c libc3/buf_inspect_u16_octal.c libc3/tag_band.c libc3/cfn.h libc3/env.c libc3/set__fact.h libc3/sym.c libc3/eval.h libc3/c3_main.h libc3/buf_inspect_s8_octal.c libc3/s16.c libc3/fn.c libc3/time.c libc3/fact.h libc3/type.c libc3/error.c libc3/log.h libc3/sequence.h libc3/set_item__tag.h libc3/io.h libc3/buf_inspect_s64.h libc3/buf_inspect_s64_hexadecimal.h libc3/window/types.h libc3/window/window.h libc3/window/cairo/demo/toasters.h libc3/window/cairo/demo/window_cairo_demo.c libc3/window/cairo/demo/lightspeed.h libc3/window/cairo/demo/bg_rect.h libc3/window/cairo/demo/window_cairo_demo.h libc3/window/cairo/demo/toasters.c libc3/window/cairo/demo/lightspeed.c libc3/window/cairo/demo/bg_rect.c libc3/window/cairo/xcb/demo/window_cairo_xcb_demo.c libc3/window/cairo/xcb/window_cairo_xcb.h libc3/window/cairo/xcb/config.h libc3/window/cairo/xcb/window_cairo_xcb.c libc3/window/cairo/types.h libc3/window/cairo/window_cairo.c libc3/window/cairo/cairo_png.h libc3/window/cairo/cairo_sprite.h libc3/window/cairo/quartz/demo/window_cairo_quartz_demo.c libc3/window/cairo/quartz/window_cairo_quartz_view_controller.h libc3/window/cairo/quartz/quartz_to_xkbcommon.c libc3/window/cairo/quartz/window_cairo_quartz.h libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.h libc3/window/cairo/quartz/quartz_to_xkbcommon.h libc3/window/cairo/quartz/xkbquartz.h libc3/window/cairo/quartz/window_cairo_quartz_view.h libc3/window/cairo/window_cairo.h libc3/window/cairo/win32/demo/window_cairo_win32_demo.c libc3/window/cairo/win32/vk_to_xkbcommon.c libc3/window/cairo/win32/window_cairo_win32.h libc3/window/cairo/win32/vk_to_xkbcommon.h libc3/window/cairo/win32/window_cairo_win32.c libc3/window/cairo/cairo_sprite.c libc3/window/cairo/cairo_png.c libc3/window/window.c libc3/ident.h libc3/buf_inspect_s64_decimal.c libc3/buf_inspect_u32_binary.h libc3/buf_inspect_uw.h libc3/buf_inspect_u.c.in libc3/buf_parse_sw.c libc3/array.h libc3/buf_inspect_u32.c libc3/buf_inspect_s8_decimal.h libc3/buf_inspect_u16_hexadecimal.c libc3/buf_parse_u16.h libc3/set__tag.c libc3/map.c libc3/tag.c libc3/buf_parse_u8.h libc3/buf_inspect_uw_octal.c libc3/buf_inspect_u8_binary.c libc3/buf_inspect_s64_octal.c libc3/u16.c libc3/buf_inspect_sw_hexadecimal.c libc3/buf_inspect_s32_decimal.c libc3/buf_inspect_u64_binary.c libc3/facts_cursor.h libc3/tuple.h libc3/buf_inspect_s16_binary.c libc3/ucd.h libc3/buf_inspect_s16_octal.c libc3/buf_inspect_s8.c libc3/sha1.h libc3/buf_inspect_uw_binary.h libc3/buf_parse.c libc3/str.h libc3/error_handler.h libc3/u64.c libc3/buf_inspect_s32_octal.c libc3/facts_spec_cursor.h libc3/buf_inspect_uw_decimal.c libc3/sw.c libc3/file.c libc3/buf_inspect_s16_decimal.h libc3/frame.c libc3/s32.h libc3/c3.c libc3/f32.h libc3/buf_inspect_sw_octal.c libc3/u8.h libc3/set_item__fact.c libc3/var.c libc3/module.h libc3/license.c libc3/buf_inspect_u32_hexadecimal.c libc3/buf_parse_u64.h libc3/buf_inspect_u8_hexadecimal.h libc3/arg.c libc3/fn_clause.c libc3/operator.c libc3/bool.c libc3/buf_parse_s32.c libc3/ptag.c libc3/binding.h libc3/buf_inspect_u.h.in libc3/buf_inspect_s16.h libc3/integer.h libc3/buf_file.c libc3/s64.c libc3/buf_inspect_s32_binary.c libc3/buf_inspect_u8.h libc3/facts_spec.h libc3/buf_inspect_u8_decimal.c libc3/sign.h libc3/call.c libc3/buf_parse_s8.c libc3/buf_inspect_sw_binary.h libc3/hash.h libc3/u32.h libc3/buf_inspect_u32_octal.c libc3/character.c libc3/buf_inspect_u64_decimal.c libc3/buf_parse_uw.h libc3/buf_inspect_u32_decimal.c libc3/buf_inspect_s16_hexadecimal.c libc3/set_cursor__tag.c libc3/set_cursor__fact.h libc3/buf.c libc3/abs.c libc3/buf_parse_s64.h libc3/buf_inspect_s.c.in libc3/buf_inspect_s64_binary.h libc3/buf_inspect_u8_octal.c libc3/f64.c libc3/skiplist_node.c.in libc3/buf_parse_u32.c libc3/facts_with.h libc3/buf_inspect_sw.c libc3/buf_inspect_u16.h libc3/buf_inspect_s8_hexadecimal.h libc3/buf_inspect_u16_binary.h libc3/buf_inspect_u64_hexadecimal.h libc3/buf_save.c test/ident_test.c test/buf_parse_test_s16.c test/buf_inspect_test.c test/libc3_test.c test/fn_test.c test/buf_parse_test_u16.c test/str_test.c test/cfn_test.c test/character_test.c test/buf_parse_test_s8.c test/skiplist__fact_test.c test/sym_test.c test/tag_test.h test/buf_file_test.c test/bool_test.c test/fact_test.h test/buf_parse_test_u64.c test/compare_test.c test/facts_with_test.c test/array_test.c test/buf_parse_test.h test/test.h test/buf_parse_test_su.h test/env_test.c test/buf_parse_test_s64.c test/types_test.c test/hash_test.c test/call_test.c test/set__tag_test.c test/facts_test.c test/facts_cursor_test.c test/compare_test.h test/buf_parse_test_s32.c test/test.c test/buf_parse_test.c test/fact_test.c test/tag_test.c test/set__fact_test.c test/buf_parse_test_u32.c test/buf_test.c test/list_test.c test/buf_parse_test_u8.c test/tuple_test.c ucd2c/ucd.h ucd2c/ucd2c.c '
+C3_CONFIGURES='c3c/configure c3s/configure c3s/update_sources ic3/configure ic3/update_sources libc3/configure libc3/update_sources libc3/window/cairo/xcb/configure libc3/window/cairo/xcb/update_sources libc3/window/cairo/xcb/demo/update_sources libc3/window/cairo/xcb/demo/configure libc3/window/cairo/configure libc3/window/cairo/quartz/configure libc3/window/cairo/quartz/update_sources libc3/window/cairo/quartz/demo/configure libc3/window/cairo/quartz/demo/update_sources libc3/window/cairo/demo/configure libc3/window/cairo/demo/update_sources libc3/window/cairo/update_sources libc3/window/cairo/win32/configure libc3/window/cairo/win32/demo/configure libc3/window/cairo/win32/demo/update_sources libc3/window/cairo/win32/update_sources libc3/window/configure libc3/window/update_sources libtommath/update_sources libtommath/configure test/configure test/update_sources ucd2c/configure '
+C3_MAKEFILES='c3c/Makefile c3s/Makefile ic3/Makefile libc3/gen.mk libc3/Makefile libc3/window/cairo/xcb/Makefile libc3/window/cairo/xcb/demo/Makefile libc3/window/cairo/Makefile libc3/window/cairo/quartz/Makefile libc3/window/cairo/quartz/demo/Makefile libc3/window/cairo/demo/Makefile libc3/window/cairo/win32/Makefile libc3/window/cairo/win32/demo/Makefile libc3/window/Makefile libtommath/Makefile test/Makefile ucd2c/Makefile '
+C3_C_SOURCES='c3c/c3c.c c3s/buf_readline.c c3s/c3s.c c3s/buf_readline.h ic3/ic3.c ic3/buf_linenoise.c ic3/buf_linenoise.h ic3/linenoise.c libc3/abs.c libc3/buf.c libc3/buf_inspect_s8.c libc3/buf_inspect_s8.h libc3/buf_inspect_s8_binary.c libc3/buf_inspect_s8_binary.h libc3/buf_inspect_s8_octal.c libc3/buf_inspect_s8_octal.h libc3/buf_inspect_s8_decimal.c libc3/buf_inspect_s8_decimal.h libc3/array.h libc3/buf_inspect_s8_hexadecimal.c libc3/buf_inspect_s16.c libc3/call.c libc3/arg.c libc3/array.c libc3/binding.c libc3/c3.c libc3/buf_inspect_s8_hexadecimal.h libc3/buf_inspect_s16.h libc3/buf_inspect_s16_binary.c libc3/buf_inspect_s16_binary.h libc3/buf_inspect_s16_octal.c libc3/buf_inspect_s16_octal.h libc3/buf_inspect_s16_decimal.c libc3/buf_inspect_s16_decimal.h libc3/buf_inspect_s16_hexadecimal.c libc3/buf_inspect_s16_hexadecimal.h libc3/buf_inspect_s32.c libc3/buf_inspect_s32.h libc3/s8.c libc3/env.c libc3/bool.c libc3/bool.h libc3/buf_file.c libc3/buf_inspect_s32_binary.c libc3/buf_inspect_s32_binary.h libc3/buf_inspect_s32_octal.c libc3/buf_inspect_s32_octal.h libc3/buf_inspect_s32_decimal.c libc3/buf_inspect_s32_decimal.h libc3/buf_inspect_s32_hexadecimal.c libc3/buf_inspect_s32_hexadecimal.h libc3/buf_inspect_s64.c libc3/buf_inspect_s64.h libc3/buf_inspect_s64_binary.c libc3/buf_inspect_s64_binary.h libc3/buf_inspect_sw.c libc3/buf_parse.h libc3/buf.h libc3/buf_save.c libc3/facts_spec_cursor.c libc3/buf_inspect_s64_octal.c libc3/buf_inspect_s64_octal.h libc3/buf_inspect_s64_decimal.c libc3/buf_inspect_s64_decimal.h libc3/buf_inspect_s64_hexadecimal.c libc3/buf_inspect_s64_hexadecimal.h libc3/buf_inspect_sw.h libc3/buf_inspect_sw_binary.c libc3/buf_inspect_sw_binary.h libc3/buf_inspect_sw_octal.c libc3/buf_inspect_sw_octal.h libc3/buf_inspect_sw_decimal.c libc3/buf_file.h libc3/buf_save.h libc3/call.h libc3/buf_inspect_sw_decimal.h libc3/buf_inspect_sw_hexadecimal.c libc3/buf_inspect_sw_hexadecimal.h libc3/buf_inspect_u8.c libc3/buf_inspect_u8.h libc3/buf_inspect_u8_binary.c libc3/buf_inspect_u8_binary.h libc3/buf_inspect_u8_octal.c libc3/buf_inspect_u8_octal.h libc3/buf_inspect_u8_decimal.c libc3/buf_inspect_u8_decimal.h libc3/buf_inspect_u16.c libc3/binding.h libc3/sequence.c libc3/io.c libc3/ceiling.c libc3/ceiling.h libc3/cfn.c libc3/cfn.h libc3/character.c libc3/character.h libc3/buf_inspect_u8_hexadecimal.c libc3/buf_inspect_u8_hexadecimal.h libc3/buf_inspect_u16.h libc3/buf_inspect_u16_binary.c libc3/buf_inspect_u16_binary.h libc3/buf_inspect_u16_octal.c libc3/buf_inspect_u16_octal.h libc3/buf_inspect_u16_decimal.c libc3/buf_inspect_u16_decimal.h libc3/buf_inspect_u16_hexadecimal.c libc3/buf_inspect_u16_hexadecimal.h libc3/compare.c libc3/buf_inspect.c libc3/compare.h libc3/buf_inspect_u32.c libc3/buf_inspect_u32.h libc3/buf_inspect_u32_binary.c libc3/buf_inspect_u32_binary.h libc3/buf_inspect_u32_octal.c libc3/buf_inspect_u32_octal.h libc3/buf_inspect_u32_decimal.c libc3/buf_inspect_u32_decimal.h libc3/buf_inspect_u32_hexadecimal.c libc3/buf_inspect_u32_hexadecimal.h libc3/buf_inspect_u64.c libc3/error.c libc3/error.h libc3/error_handler.c libc3/eval.h libc3/eval.c libc3/facts.h libc3/buf_inspect_u64.h libc3/buf_inspect_u64_binary.c libc3/buf_inspect_u64_binary.h libc3/buf_inspect_u64_octal.c libc3/buf_inspect_u64_octal.h libc3/buf_inspect_u64_decimal.c libc3/buf_inspect_u64_decimal.h libc3/buf_inspect_u64_hexadecimal.c libc3/buf_inspect_u64_hexadecimal.h libc3/buf_inspect_uw.c libc3/buf_inspect_uw.h libc3/set__fact.c libc3/file.h libc3/fact.c libc3/fact.h libc3/facts_cursor.c libc3/buf_inspect_uw_binary.c libc3/buf_inspect_uw_binary.h libc3/buf_inspect_uw_octal.c libc3/buf_inspect_uw_octal.h libc3/buf_inspect_uw_decimal.c libc3/buf_inspect_uw_decimal.h libc3/buf_inspect_uw_hexadecimal.c libc3/buf_inspect_uw_hexadecimal.h libc3/buf_parse_s8.c libc3/buf_parse_s8.h libc3/buf_parse_s16.c libc3/buf_parse_s16.h libc3/buf_parse_s32.c libc3/buf_parse_s32.h libc3/s8.h libc3/list.c libc3/facts_cursor.h libc3/facts_spec.c libc3/facts_spec.h libc3/facts_spec_cursor.h libc3/buf_parse_s64.c libc3/buf_parse_s64.h libc3/buf_parse_sw.c libc3/buf_parse_sw.h libc3/buf_parse_u8.c libc3/buf_parse_u8.h libc3/buf_parse_u16.c libc3/buf_parse_u16.h libc3/buf_parse_u32.c libc3/buf_parse_u32.h libc3/buf_parse_u64.c libc3/buf_parse_u64.h libc3/buf_parse_uw.c libc3/buf_parse_uw.h libc3/set__fact.h libc3/set__tag.c libc3/buf_parse_u.h.in libc3/facts_with.c libc3/facts_with.h libc3/facts_with_cursor.c libc3/set__tag.h libc3/set_cursor__fact.c libc3/set_cursor__fact.h libc3/set_cursor__tag.c libc3/set_cursor__tag.h libc3/set_item__fact.c libc3/set_item__fact.h libc3/set_item__tag.c libc3/set_item__tag.h libc3/skiplist__fact.c libc3/skiplist__fact.h libc3/skiplist_node__fact.c libc3/skiplist_node__fact.h libc3/s16.c libc3/s16.h libc3/s32.c libc3/s32.h libc3/s64.c libc3/facts_with_cursor.h libc3/float.h libc3/frame.c libc3/frame.h libc3/types.h libc3/s64.h libc3/sw.c libc3/sw.h libc3/u8.c libc3/u8.h libc3/u16.c libc3/f64.h libc3/u16.h libc3/u32.c libc3/f32.c libc3/f64.c libc3/u32.h libc3/u64.c libc3/u64.h libc3/uw.c libc3/uw.h libc3/hash.h libc3/ident.h libc3/integer.c libc3/integer.h libc3/list.h libc3/log.c libc3/log.h libc3/buf_inspect_s.h.in libc3/module.c libc3/buf_inspect.h libc3/c3_main.h libc3/map.c libc3/abs.h libc3/str.c libc3/module.h libc3/buf_parse_u.c.in libc3/quote.c libc3/quote.h libc3/set.c.in libc3/set.h.in libc3/buf_inspect_s_base.h.in libc3/sequence.h libc3/tag_mod.c libc3/tag_mul.c libc3/set_cursor.c.in libc3/set_cursor.h.in libc3/f32.h libc3/facts.c libc3/set_item.c.in libc3/set_item.h.in libc3/tag_sub.c libc3/tag_shift_right.c libc3/s.h.in libc3/sign.c libc3/sign.h libc3/skiplist.c.in libc3/skiplist.h.in libc3/type.h libc3/tag.c libc3/skiplist_node.c.in libc3/skiplist_node.h.in libc3/str.h libc3/tag.h libc3/ucd.c libc3/sym.h libc3/tuple.c libc3/tuple.h libc3/type.c libc3/ucd.h libc3/buf_parse_s.c.in libc3/buf_parse_s.h.in libc3/buf_inspect_s.c.in libc3/error_handler.h libc3/ident.c libc3/tag_bor.c libc3/tag_bxor.c libc3/buf_inspect_s_base.c.in libc3/buf_inspect_u.c.in libc3/buf_inspect_u.h.in libc3/env.h libc3/arg.h libc3/buf_inspect_u_base.c.in libc3/buf_inspect_u_base.h.in libc3/window/cairo/xcb/config.h libc3/window/cairo/xcb/window_cairo_xcb.c libc3/window/cairo/xcb/demo/window_cairo_xcb_demo.c libc3/window/cairo/xcb/window_cairo_xcb.h libc3/window/cairo/types.h libc3/window/cairo/window_cairo.h libc3/window/cairo/window_cairo.c libc3/window/cairo/quartz/window_cairo_quartz.h libc3/window/cairo/quartz/demo/window_cairo_quartz_demo.c libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.h libc3/window/cairo/quartz/xkbquartz.h libc3/window/cairo/quartz/window_cairo_quartz_view.h libc3/window/cairo/quartz/window_cairo_quartz_view_controller.h libc3/window/cairo/quartz/quartz_to_xkbcommon.c libc3/window/cairo/quartz/quartz_to_xkbcommon.h libc3/window/cairo/demo/bg_rect.c libc3/window/cairo/demo/bg_rect.h libc3/window/cairo/demo/lightspeed.c libc3/window/cairo/demo/lightspeed.h libc3/window/cairo/demo/window_cairo_demo.c libc3/window/cairo/demo/window_cairo_demo.h libc3/window/cairo/demo/toasters.c libc3/window/cairo/demo/flies.h libc3/window/cairo/demo/toasters.h libc3/window/cairo/demo/flies.c libc3/window/cairo/cairo_png.c libc3/window/cairo/win32/demo/window_cairo_win32_demo.c libc3/window/cairo/win32/vk_to_xkbcommon.c libc3/window/cairo/win32/vk_to_xkbcommon.h libc3/window/cairo/win32/window_cairo_win32.c libc3/window/cairo/win32/window_cairo_win32.h libc3/window/cairo/cairo_png.h libc3/window/cairo/cairo_sprite.c libc3/window/cairo/cairo_sprite.h libc3/window/types.h libc3/window/window.c libc3/window/window.h libc3/buf_parse.c libc3/u.c.in libc3/fn.c libc3/u.h.in libc3/sha1.h libc3/c3.h libc3/fn.h libc3/map.h libc3/file.c libc3/license.c libc3/operator.c libc3/ptag.h libc3/tag_add.c libc3/tag_band.c libc3/fn_clause.h libc3/s.c.in libc3/operator.h libc3/sym.c libc3/fn_clause.c libc3/io.h libc3/ptag.c libc3/var.h libc3/var.c libc3/time.c libc3/time.h libc3/tag_shift_left.c libc3/hash.c test/buf_inspect_test.c test/bool_test.c test/buf_parse_test.c test/facts_test.c test/buf_file_test.c test/list_test.c test/test.c test/test.h test/buf_parse_test_u8.c test/buf_parse_test.h test/buf_parse_test_s16.c test/buf_parse_test_s32.c test/buf_parse_test_s64.c test/buf_parse_test_s8.c test/buf_parse_test_su.h test/buf_parse_test_u16.c test/buf_parse_test_u32.c test/buf_test.c test/buf_parse_test_u64.c test/call_test.c test/facts_cursor_test.c test/cfn_test.c test/character_test.c test/env_test.c test/fact_test.c test/fact_test.h test/libc3_test.c test/str_test.c test/facts_with_test.c test/hash_test.c test/compare_test.c test/compare_test.h test/ident_test.c test/set__fact_test.c test/set__tag_test.c test/skiplist__fact_test.c test/sym_test.c test/tag_test.c test/tag_test.h test/array_test.c test/fn_test.c test/tuple_test.c test/types_test.c ucd2c/ucd.h ucd2c/ucd2c.c '