diff --git a/libc3/array.c b/libc3/array.c
index 764af7b..0550bb5 100644
--- a/libc3/array.c
+++ b/libc3/array.c
@@ -49,8 +49,6 @@
#include "uw.h"
#include "var.h"
-bool array_copy_data (f_copy copy, const u8 *src, u8 *dest);
-
void array_clean (s_array *a)
{
u8 *data;
@@ -84,76 +82,6 @@ void array_clean (s_array *a)
}
}
-s_array * array_copy (const s_array *src, s_array *dest)
-{
- f_copy copy;
- u8 *data_dest;
- u8 *data_src;
- uw i = 0;
- uw item_size;
- s_array tmp;
- assert(dest);
- assert(src);
- assert(src->dimension);
- assert(src->dimensions);
- (void) i;
- bzero(&tmp, sizeof(s_array));
- if (! src->dimension) {
- assert(! "array_copy: zero dimension");
- errx(1, "array_copy: zero dimension");
- return NULL;
- }
-#ifdef DEBUG
- while (i < src->dimension) {
- assert(src->dimensions[i].count);
- i++;
- }
-#endif
- tmp.dimension = src->dimension;
- if (! (tmp.dimensions = calloc(src->dimension,
- sizeof(s_array_dimension)))) {
- assert(! "array_copy: out of memory: dimensions");
- warnx("array_copy: out of memory: dimensions");
- return NULL;
- }
- memcpy(tmp.dimensions, src->dimensions,
- src->dimension * sizeof(s_array_dimension));
- tmp.count = src->count;
- tmp.size = src->size;
- tmp.type = src->type;
- if (src->data) {
- if (! (tmp.data = calloc(1, src->size)))
- errx(1, "array_copy: out of memory");
- copy = array_type_to_copy(src->type);
- data_dest = tmp.data;
- data_src = src->data;
- i = 0;
- item_size = src->dimensions[src->dimension - 1].item_size;
- while (i < src->count) {
- if (copy(data_src, data_dest) != data_dest) {
- return NULL;
- }
- data_dest += item_size;
- data_src += item_size;
- i++;
- }
- }
- else
- tmp.data = NULL;
- if (src->tags) {
- tmp.tags = calloc(src->count, sizeof(s_tag));
- i = 0;
- while (i < src->count) {
- tag_copy(src->tags + i, tmp.tags + i);
- i++;
- }
- }
- else
- tmp.tags = NULL;
- *dest = tmp;
- return dest;
-}
-
void * array_data (const s_array *a, const uw *address)
{
uw i = 0;
@@ -176,17 +104,17 @@ 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)
{
void *a_data;
- f_copy copy;
+ f_init_copy init_copy;
void *dest_data;
assert(a->type == TAG_ARRAY);
assert(address->type == TAG_ARRAY);
if ((a_data = array_data(&a->data.array,
address->data.array.data))) {
tag_init(dest);
- copy = array_type_to_copy(a->data.array.type);
+ init_copy = array_type_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 (copy(a_data, dest_data) != dest_data)
+ if (init_copy(dest_data, a_data) != dest_data)
return NULL;
return dest;
}
@@ -260,6 +188,76 @@ s_array * array_init_1 (s_array *array, s8 *p)
return array;
}
+s_array * array_init_copy (s_array *a, const s_array *src)
+{
+ f_init_copy init_copy;
+ u8 *data_a;
+ u8 *data_src;
+ uw i = 0;
+ uw item_size;
+ s_array tmp;
+ assert(a);
+ assert(src);
+ assert(src->dimension);
+ assert(src->dimensions);
+ (void) i;
+ bzero(&tmp, sizeof(s_array));
+ if (! src->dimension) {
+ assert(! "array_init_copy: zero dimension");
+ errx(1, "array_init_copy: zero dimension");
+ return NULL;
+ }
+#ifdef DEBUG
+ while (i < src->dimension) {
+ assert(src->dimensions[i].count);
+ i++;
+ }
+#endif
+ tmp.dimension = src->dimension;
+ if (! (tmp.dimensions = calloc(src->dimension,
+ sizeof(s_array_dimension)))) {
+ assert(! "array_init_copy: out of memory: dimensions");
+ warnx("array_init_copy: out of memory: dimensions");
+ return NULL;
+ }
+ memcpy(tmp.dimensions, src->dimensions,
+ src->dimension * sizeof(s_array_dimension));
+ tmp.count = src->count;
+ tmp.size = src->size;
+ tmp.type = src->type;
+ 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);
+ data_a = tmp.data;
+ data_src = src->data;
+ i = 0;
+ item_size = src->dimensions[src->dimension - 1].item_size;
+ while (i < src->count) {
+ if (init_copy(data_src, data_a) != data_a) {
+ return NULL;
+ }
+ data_a += item_size;
+ data_src += item_size;
+ i++;
+ }
+ }
+ else
+ tmp.data = NULL;
+ if (src->tags) {
+ tmp.tags = calloc(src->count, sizeof(s_tag));
+ i = 0;
+ while (i < src->count) {
+ tag_init_copy(tmp.tags + i, src->tags + i);
+ i++;
+ }
+ }
+ else
+ tmp.tags = NULL;
+ *a = tmp;
+ return a;
+}
+
s_str * array_inspect (const s_array *array, s_str *dest)
{
sw size;
@@ -464,64 +462,64 @@ f_buf_inspect_size array_type_to_buf_inspect_size (const s_sym *type)
return NULL;
}
-f_copy array_type_to_copy (const s_sym *type)
+f_init_copy array_type_to_init_copy (const s_sym *type)
{
if (type == sym_1("Bool"))
- return (f_copy) bool_copy;
+ return (f_init_copy) bool_init_copy;
if (type == sym_1("Call"))
- return (f_copy) call_copy;
+ return (f_init_copy) call_init_copy;
if (type == sym_1("Cfn"))
- return (f_copy) cfn_copy;
+ return (f_init_copy) cfn_init_copy;
if (type == sym_1("Character"))
- return (f_copy) character_copy;
+ return (f_init_copy) character_init_copy;
if (type == sym_1("F32"))
- return (f_copy) f32_copy;
+ return (f_init_copy) f32_init_copy;
if (type == sym_1("F64"))
- return (f_copy) f64_copy;
+ return (f_init_copy) f64_init_copy;
if (type == sym_1("Fact"))
- return (f_copy) fact_copy;
+ return (f_init_copy) fact_init_copy;
if (type == sym_1("Fn"))
- return (f_copy) fn_copy;
+ return (f_init_copy) fn_init_copy;
if (type == sym_1("Ident"))
- return (f_copy) ident_copy;
+ return (f_init_copy) ident_init_copy;
if (type == sym_1("Integer"))
- return (f_copy) integer_copy;
+ return (f_init_copy) integer_init_copy;
if (type == sym_1("List"))
- return (f_copy) list_copy;
+ return (f_init_copy) list_init_copy;
if (type == sym_1("Sw"))
- return (f_copy) sw_copy;
+ return (f_init_copy) sw_init_copy;
if (type == sym_1("S64"))
- return (f_copy) s64_copy;
+ return (f_init_copy) s64_init_copy;
if (type == sym_1("S32"))
- return (f_copy) s32_copy;
+ return (f_init_copy) s32_init_copy;
if (type == sym_1("S16"))
- return (f_copy) s16_copy;
+ return (f_init_copy) s16_init_copy;
if (type == sym_1("S8"))
- return (f_copy) s8_copy;
+ return (f_init_copy) s8_init_copy;
if (type == sym_1("U8"))
- return (f_copy) u8_copy;
+ return (f_init_copy) u8_init_copy;
if (type == sym_1("U16"))
- return (f_copy) u16_copy;
+ return (f_init_copy) u16_init_copy;
if (type == sym_1("U32"))
- return (f_copy) u32_copy;
+ return (f_init_copy) u32_init_copy;
if (type == sym_1("U64"))
- return (f_copy) u64_copy;
+ return (f_init_copy) u64_init_copy;
if (type == sym_1("Uw"))
- return (f_copy) uw_copy;
+ return (f_init_copy) uw_init_copy;
if (type == sym_1("Ptag"))
- return (f_copy) ptag_copy;
+ return (f_init_copy) ptag_init_copy;
if (type == sym_1("Quote"))
- return (f_copy) quote_copy;
+ return (f_init_copy) quote_init_copy;
if (type == sym_1("Str"))
- return (f_copy) str_copy;
+ return (f_init_copy) str_init_copy;
if (type == sym_1("Sym"))
- return (f_copy) sym_copy;
+ return (f_init_copy) sym_init_copy;
if (type == sym_1("Tuple"))
- return (f_copy) tuple_copy;
+ return (f_init_copy) tuple_init_copy;
if (type == sym_1("Var"))
- return (f_copy) var_copy;
- assert(! "array_type_to_copy: unknown type");
- errx(1, "array_type_to_copy: unknown type");
+ 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;
}
diff --git a/libc3/array.h b/libc3/array.h
index 5b8a0e2..6466790 100644
--- a/libc3/array.h
+++ b/libc3/array.h
@@ -15,11 +15,14 @@
#include "types.h"
-void array_clean (s_array *a);
-s_array * array_copy (const s_array *src, s_array *dest);
-s_array * array_init (s_array *a, const s_sym *type,
- uw dimension, const uw *dimensions);
-s_array * array_init_1 (s_array *a, s8 *p);
+/* Stack-allocation compatible functions, call array_clean after use. */
+void array_clean (s_array *a);
+s_array * array_init (s_array *a, const s_sym *type,
+ uw dimension, const uw *dimensions);
+s_array * array_init_1 (s_array *a, s8 *p);
+s_array * array_init_copy (s_array *a, const s_array *src);
+
+/* Observers */
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,
@@ -27,7 +30,7 @@ s_tag * array_data_tag (s_tag *a, const s_tag *address,
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_copy array_type_to_copy (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);
#endif /* LIBC3_ARRAY_H */
diff --git a/libc3/binding.c b/libc3/binding.c
index a5830fc..5e971d8 100644
--- a/libc3/binding.c
+++ b/libc3/binding.c
@@ -49,7 +49,7 @@ s_binding * binding_init (s_binding *binding, const s_sym *name,
{
assert(binding);
binding->name = name;
- tag_copy(value, &binding->value);
+ tag_init_copy(&binding->value, value);
binding->next = next;
return binding;
}
diff --git a/libc3/bool.c b/libc3/bool.c
index 83b8988..4f4bf9c 100644
--- a/libc3/bool.c
+++ b/libc3/bool.c
@@ -14,7 +14,7 @@
#include "buf.h"
#include "buf_inspect.h"
-bool * bool_copy (const bool *src, bool *dest)
+bool * bool_init_copy (bool *dest, const bool *src)
{
*dest = *src;
return dest;
diff --git a/libc3/bool.h b/libc3/bool.h
index e6a382d..0cf2999 100644
--- a/libc3/bool.h
+++ b/libc3/bool.h
@@ -21,8 +21,10 @@
#include "types.h"
+/* Stack-allocation compatible functions */
+bool * bool_init_copy (bool *dest, const bool *src);
+
/* Observers */
-bool * bool_copy (const bool *src, bool *dest);
s_str * bool_inspect (bool *b, s_str *dest);
#endif /* LIBC3_BOOL_H */
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index 46dec06..cb18d76 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -1534,7 +1534,7 @@ sw buf_inspect_str_reserved (s_buf *buf, const s_str *str)
goto clean;
}
result += r;
- str_init_str(&s, str);
+ s = *str;
while (r) {
if ((r = str_read_character_utf8(&s, &c)) < 0)
goto restore;
@@ -1575,7 +1575,7 @@ sw buf_inspect_str_reserved_size (const s_str *str)
s_str s;
r = strlen("\"");
result += r;
- str_init_str(&s, str);
+ s = *str;
while (r) {
if ((r = str_read_character_utf8(&s, &c)) < 0)
goto restore;
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 939638c..7c4d029 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -643,7 +643,7 @@ sw buf_parse_call_op_rec (s_buf *buf, s_call *dest, u8 min_precedence)
bzero(&tmp3, sizeof(s_call));
left = &tmp.arguments->tag;
right = &list_next(tmp.arguments)->tag;
- tag_copy(&dest->arguments->tag, left);
+ tag_init_copy(left, &dest->arguments->tag);
if ((r = buf_parse_ident_peek(buf, &next_op)) <= 0)
goto restore;
if (! operator_resolve(&next_op, 2, &next_op) ||
diff --git a/libc3/call.c b/libc3/call.c
index 3b195bb..8e43d8c 100644
--- a/libc3/call.c
+++ b/libc3/call.c
@@ -36,17 +36,6 @@ void call_clean (s_call *call)
fn_delete(call->fn);
}
-s_call * call_copy (const s_call *src, s_call *dest)
-{
- assert(src);
- assert(dest);
- ident_copy(&src->ident, &dest->ident);
- list_copy((const s_list **) &src->arguments, &dest->arguments);
- dest->cfn = src->cfn;
- dest->fn = src->fn;
- return dest;
-}
-
bool call_get (s_call *call, s_facts *facts)
{
s_facts_cursor cursor;
@@ -223,6 +212,17 @@ s_call * call_init_cast (s_call *call, const s_sym *type,
return call;
}
+s_call * call_init_copy (s_call *call, const s_call *src)
+{
+ assert(src);
+ assert(call);
+ ident_init_copy(&call->ident, &src->ident);
+ list_init_copy(&call->arguments, (const s_list **) &src->arguments);
+ call->cfn = src->cfn;
+ call->fn = src->fn;
+ return call;
+}
+
s_call * call_init_op (s_call *call)
{
assert(call);
diff --git a/libc3/call.h b/libc3/call.h
index 40b9101..fb44aad 100644
--- a/libc3/call.h
+++ b/libc3/call.h
@@ -21,6 +21,7 @@ s_call * call_init (s_call *call);
s_call * call_init_1 (s_call *call, const s8 *p);
s_call * call_init_cast (s_call *call, const s_sym *type,
const s_tag *tag);
+s_call * call_init_copy (s_call *call, const s_call *src);
s_call * call_init_op (s_call *call);
s_call * call_init_op_unary (s_call *call);
@@ -28,7 +29,6 @@ s_call * call_init_op_unary (s_call *call);
bool call_get (s_call *call, s_facts *facts);
/* Observers */
-s_call * call_copy (const s_call *src, s_call *dest);
s_str * call_inspect (const s_call *call, s_str *dest);
#endif /* LIBC3_CALL_H */
diff --git a/libc3/cfn.c b/libc3/cfn.c
index 8cae70c..6b8cb68 100644
--- a/libc3/cfn.c
+++ b/libc3/cfn.c
@@ -116,26 +116,26 @@ void cfn_clean (s_cfn *cfn)
free(cfn->cif.arg_types);
}
-s_cfn * cfn_copy (const s_cfn *cfn, s_cfn *dest)
+s_cfn * cfn_init_copy (s_cfn *cfn, const s_cfn *src)
{
+ assert(src);
assert(cfn);
- assert(dest);
- dest->name = cfn->name;
- dest->arg_result = cfn->arg_result;
- list_copy((const s_list **) &cfn->arg_types, &dest->arg_types);
- dest->arity = cfn->arity;
- dest->cif = cfn->cif;
- if (cfn->arity) {
- dest->cif.arg_types = calloc(cfn->cif.nargs + 1,
+ cfn->name = src->name;
+ cfn->arg_result = src->arg_result;
+ list_init_copy(&cfn->arg_types, (const s_list **) &src->arg_types);
+ cfn->arity = src->arity;
+ cfn->cif = src->cif;
+ if (src->arity) {
+ cfn->cif.arg_types = calloc(src->cif.nargs + 1,
sizeof(ffi_type *));
- memcpy(dest->cif.arg_types, cfn->cif.arg_types,
- (cfn->cif.nargs + 1) * sizeof(ffi_type *));
+ memcpy(cfn->cif.arg_types, src->cif.arg_types,
+ (src->cif.nargs + 1) * sizeof(ffi_type *));
}
- dest->result_type = cfn->result_type;
- dest->ptr = cfn->ptr;
- dest->macro = cfn->macro;
- dest->special_operator = cfn->special_operator;
- return dest;
+ cfn->result_type = src->result_type;
+ cfn->ptr = src->ptr;
+ cfn->macro = src->macro;
+ cfn->special_operator = src->special_operator;
+ return cfn;
}
void cfn_delete (s_cfn *cfn)
@@ -181,7 +181,7 @@ s_cfn * cfn_new_copy (const s_cfn *src)
errx(1, "cfn_new_copy: out of memory");
return NULL;
}
- cfn_copy(src, cfn);
+ cfn_init_copy(cfn, src);
return cfn;
}
diff --git a/libc3/cfn.h b/libc3/cfn.h
index 1a8b23f..5f07881 100644
--- a/libc3/cfn.h
+++ b/libc3/cfn.h
@@ -15,20 +15,20 @@
#include "types.h"
-/* stack-allocation compatible functions */
+/* Stack-allocation compatible functions, call cfn_clean after use. */
+void cfn_clean (s_cfn *cfn);
s_cfn * cfn_init (s_cfn *cfn, const s_sym *name, s_list *arg_types,
const s_sym *result_type);
-void cfn_clean (s_cfn *cfn);
+s_cfn * cfn_init_copy (s_cfn *cfn, const s_cfn *src);
-/* constructor, destructor */
+/* Heap-allocation functions, call cfn_delete after use. */
void cfn_delete (s_cfn *cfn);
s_cfn * cfn_new_copy (const s_cfn *src);
-/* observers */
+/* Observers */
s_tag * cfn_apply (s_cfn *cfn, s_list *args, s_tag *dest);
-s_cfn * cfn_copy (const s_cfn *cfn, s_cfn *dest);
-/* modifiers */
+/* Modifiers */
s_cfn * cfn_link (s_cfn *cfn);
s_cfn * cfn_prep_cif (s_cfn *cfn);
diff --git a/libc3/character.c b/libc3/character.c
index 86db852..f4d3c71 100644
--- a/libc3/character.c
+++ b/libc3/character.c
@@ -25,12 +25,12 @@ character character_1 (const s8 *p)
return c;
}
-character * character_copy (const character *src, character *dest)
+character * character_init_copy (character *c, const character *src)
{
+ assert(c);
assert(src);
- assert(dest);
- *dest = *src;
- return dest;
+ *c = *src;
+ return c;
}
bool character_is_digit (character c)
diff --git a/libc3/character.h b/libc3/character.h
index 3bb2e7e..5805fd2 100644
--- a/libc3/character.h
+++ b/libc3/character.h
@@ -17,8 +17,8 @@
#include "types.h"
character character_1 (const s8 *p);
-character * character_copy (const character *src, character *dest);
void character_hash_update (character c, t_hash *hash);
+character * character_init_copy (character *c, const character *src);
bool character_is_digit (character c);
bool character_is_lowercase (character c);
bool character_is_printable (character c);
diff --git a/libc3/env.c b/libc3/env.c
index 1e386e7..258a84d 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -88,7 +88,7 @@ void env_error_tag (s_env *env, const s_tag *tag)
assert(tag);
error_handler = env->error_handler;
if (error_handler) {
- tag_copy(tag, &error_handler->tag);
+ tag_init_copy(&error_handler->tag, tag);
error_handler->backtrace = env->backtrace;
env_longjmp(env, &error_handler->jmp_buf);
/* never reached */
@@ -112,7 +112,7 @@ bool env_eval_array (s_env *env, const s_array *array, s_array *dest)
assert(env);
assert(array);
assert(dest);
- array_copy(array, &tmp);
+ array_init_copy(&tmp, array);
item_size = tmp.dimensions[tmp.dimension - 1].item_size;
if (tmp.data) {
*dest = tmp;
@@ -182,7 +182,7 @@ bool env_eval_call (s_env *env, const s_call *call, s_tag *dest)
assert(env);
assert(call);
assert(dest);
- call_copy(call, &c);
+ call_init_copy(&c, call);
env_eval_call_resolve(env, &c);
if (c.cfn)
result = env_eval_call_cfn(env, &c, dest);
@@ -334,11 +334,11 @@ bool env_eval_equal_map (s_env *env, const s_map *a,
assert(b);
assert(dest);
if (! a->count) {
- map_copy(b, dest);
+ map_init_copy(dest, b);
return true;
}
if (! b->count) {
- map_copy(a, dest);
+ map_init_copy(dest, a);
return true;
}
if (a->count > b->count) {
@@ -364,8 +364,7 @@ bool env_eval_equal_map (s_env *env, const s_map *a,
next:
i++;
}
- if (dest)
- map_copy(b, dest);
+ map_init_copy(dest, b);
return true;
}
@@ -431,7 +430,7 @@ bool env_eval_equal_tag (s_env *env, const s_tag *a, const s_tag *b,
if (compare_tag(a, b)) {
return false;
}
- tag_copy(a, dest);
+ tag_init_copy(dest, a);
return true;
default:
break;
@@ -477,7 +476,7 @@ bool env_eval_equal_tag (s_env *env, const s_tag *a, const s_tag *b,
warnx("env_eval_compare_tag: value mismatch");
return false;
}
- tag_copy(a, dest);
+ tag_init_copy(dest, a);
return true;
default:
break;
@@ -575,7 +574,7 @@ bool env_eval_ident (s_env *env, const s_ident *ident, s_tag *dest)
s_ident tmp_ident;
assert(env);
assert(ident);
- ident_copy(ident, &tmp_ident);
+ ident_init_copy(&tmp_ident, ident);
ident_resolve_module(&tmp_ident, env);
if (! ((tag = frame_get(env->frame, tmp_ident.sym)) ||
(tag = ident_get(&tmp_ident, &env->facts, &tmp)))) {
@@ -584,7 +583,7 @@ bool env_eval_ident (s_env *env, const s_ident *ident, s_tag *dest)
tmp_ident.sym->str.ptr.ps8);
return false;
}
- tag_copy(tag, dest);
+ tag_init_copy(dest, tag);
return true;
}
@@ -663,7 +662,7 @@ bool env_eval_quote(s_env *env, const s_quote *quote, s_tag *dest)
assert(quote);
assert(dest);
(void) env;
- if (! tag_copy(quote->tag, dest))
+ if (! tag_init_copy(dest, quote->tag))
return false;
return true;
}
@@ -711,7 +710,7 @@ bool env_eval_tag (s_env *env, const s_tag *tag, s_tag *dest)
case TAG_U64:
case TAG_UW:
case TAG_VAR:
- tag_copy(tag, dest);
+ tag_init_copy(dest, tag);
return true;
}
assert(! "env_eval_tag: unknown tag type");
diff --git a/libc3/f32.c b/libc3/f32.c
index e789cca..d41b968 100644
--- a/libc3/f32.c
+++ b/libc3/f32.c
@@ -81,10 +81,10 @@ f32 f32_cast (s_tag *tag)
return 0;
}
-f32 * f32_copy (const f32 *src, f32 *dest)
+f32 * f32_init_copy (f32 *x, const f32 *src)
{
assert(src);
- assert(dest);
- *dest = *src;
- return dest;
+ assert(x);
+ *x = *src;
+ return x;
}
diff --git a/libc3/f32.h b/libc3/f32.h
index 7a8c749..0235a84 100644
--- a/libc3/f32.h
+++ b/libc3/f32.h
@@ -15,7 +15,7 @@
#include "types.h"
-f32 f32_cast (s_tag *tag);
-f32 * f32_copy (const f32 *src, f32 *dest);
+f32 f32_cast (s_tag *tag);
+f32 * f32_init_copy (f32 *x, const f32 *src);
#endif /* LIBC3_F32_H */
diff --git a/libc3/f64.c b/libc3/f64.c
index 1e45af7..3e24354 100644
--- a/libc3/f64.c
+++ b/libc3/f64.c
@@ -82,12 +82,12 @@ f64 f64_cast (s_tag *tag)
return 0;
}
-f64 * f64_copy (const f64 *src, f64 *dest)
+f64 * f64_init_copy (f64 *x, const f64 *src)
{
assert(src);
- assert(dest);
- *dest = *src;
- return dest;
+ assert(x);
+ *x = *src;
+ return x;
}
f64 * f64_random (f64 *dest)
diff --git a/libc3/f64.h b/libc3/f64.h
index 6feefac..8d18ebc 100644
--- a/libc3/f64.h
+++ b/libc3/f64.h
@@ -16,7 +16,7 @@
#include "types.h"
f64 f64_cast (s_tag *tag);
-f64 * f64_copy (const f64 *src, f64 *dest);
+f64 * f64_init_copy (f64 *x, const f64 *src);
f64 * f64_random (f64 *dest);
#endif /* LIBC3_F64_H */
diff --git a/libc3/fact.c b/libc3/fact.c
index bcd2e46..5f9df74 100644
--- a/libc3/fact.c
+++ b/libc3/fact.c
@@ -18,14 +18,6 @@
#include "fact.h"
#include "tag.h"
-s_fact * fact_copy (const s_fact *src, s_fact *dest)
-{
- assert(src);
- assert(dest);
- *dest = *src;
- return dest;
-}
-
uw fact_hash_uw (const s_fact *fact)
{
t_hash hash;
@@ -46,6 +38,14 @@ s_fact * fact_init (s_fact *fact, const s_tag *subject,
return fact;
}
+s_fact * fact_init_copy (s_fact *fact, const s_fact *src)
+{
+ assert(src);
+ assert(fact);
+ *fact = *src;
+ return fact;
+}
+
s_str * fact_inspect (const s_fact *fact, s_str *dest)
{
s_buf buf;
diff --git a/libc3/fact.h b/libc3/fact.h
index fc85a1a..8e952c3 100644
--- a/libc3/fact.h
+++ b/libc3/fact.h
@@ -19,9 +19,9 @@
#define fact_clean(fact) do {} while(0)
s_fact * fact_init (s_fact *fact, const s_tag *subject,
const s_tag *predicate, const s_tag *object);
+s_fact * fact_init_copy (s_fact *fact, const s_fact *src);
/* Observers */
-s_fact * fact_copy (const s_fact *src, s_fact *dest);
uw fact_hash_uw (const s_fact *x);
s_str * fact_inspect (const s_fact *fact, s_str *dest);
s_fact * fact_r (const s_fact_w *fact);
diff --git a/libc3/fn.c b/libc3/fn.c
index 64ae4f2..688fccb 100644
--- a/libc3/fn.c
+++ b/libc3/fn.c
@@ -29,14 +29,6 @@ void fn_clean (s_fn *fn)
fn_clause_delete_all(fn->clauses);
}
-s_fn * fn_copy (const s_fn *src, s_fn *dest)
-{
- fn_clause_copy(src->clauses, &dest->clauses);
- dest->macro = src->macro;
- dest->special_operator = src->special_operator;
- return dest;
-}
-
void fn_delete (s_fn *fn)
{
fn_clean(fn);
@@ -62,6 +54,14 @@ s_fn * fn_init_1 (s_fn *fn, s8 *p)
return fn;
}
+s_fn * fn_init_copy (s_fn *fn, const s_fn *src)
+{
+ fn_clause_copy(src->clauses, &fn->clauses);
+ fn->macro = src->macro;
+ fn->special_operator = src->special_operator;
+ return fn;
+}
+
s_fn * fn_new (void)
{
s_fn *fn;
@@ -71,11 +71,11 @@ s_fn * fn_new (void)
return fn;
}
-s_fn * fn_new_copy (const s_fn *fn)
+s_fn * fn_new_copy (const s_fn *src)
{
- s_fn *tmp;
- assert(fn);
- tmp = fn_new();
- fn_copy(fn, tmp);
- return tmp;
+ s_fn *fn;
+ assert(src);
+ if (! (fn = calloc(1, sizeof(s_fn))))
+ err(1, "fn_new_copy: calloc");
+ return fn_init_copy(fn, src);
}
diff --git a/libc3/fn.h b/libc3/fn.h
index 616a122..abda44e 100644
--- a/libc3/fn.h
+++ b/libc3/fn.h
@@ -21,19 +21,15 @@
#include "types.h"
-/* stack-allocation compatible functions */
+/* Stack-allocation compatible functions, call fn_clean after use. */
void fn_clean (s_fn *fn);
s_fn * fn_init (s_fn *fn);
s_fn * fn_init_1 (s_fn *fn, s8 *p);
+s_fn * fn_init_copy (s_fn *fn, const s_fn *src);
-/* constructors */
+/* Heap-allocation functions, call fn_delete after use. */
+void fn_delete (s_fn *fn);
s_fn * fn_new (void);
s_fn * fn_new_copy (const s_fn *fn);
-/* destructors */
-void fn_delete (s_fn *fn);
-
-/* observers */
-s_fn * fn_copy (const s_fn *src, s_fn *dest);
-
#endif /* LIBC3_FN_H */
diff --git a/libc3/fn_clause.c b/libc3/fn_clause.c
index 5378f7f..5006cec 100644
--- a/libc3/fn_clause.c
+++ b/libc3/fn_clause.c
@@ -33,8 +33,8 @@ s_fn_clause * fn_clause_copy (const s_fn_clause *src, s_fn_clause **dest)
while (src) {
*tail = fn_clause_new(NULL);
(*tail)->arity = src->arity;
- list_copy((const s_list **) &src->pattern, &(*tail)->pattern);
- list_copy((const s_list **) &src->algo, &(*tail)->algo);
+ list_init_copy(&(*tail)->pattern, (const s_list **) &src->pattern);
+ list_init_copy(&(*tail)->algo, (const s_list **) &src->algo);
src = src->next_clause;
tail = &(*tail)->next_clause;
}
diff --git a/libc3/ident.c b/libc3/ident.c
index 00b94a8..2b6e8ff 100644
--- a/libc3/ident.c
+++ b/libc3/ident.c
@@ -37,13 +37,6 @@ bool ident_character_is_reserved (character c)
c == '}');
}
-s_ident * ident_copy (const s_ident *src, s_ident *dest)
-{
- dest->module = src->module;
- dest->sym = src->sym;
- return dest;
-}
-
bool ident_first_character_is_reserved (character c)
{
return (character_is_digit(c) ||
@@ -195,6 +188,13 @@ s_ident * ident_init_1 (s_ident *ident, const s8 *p)
return ident;
}
+s_ident * ident_init_copy (s_ident *ident, const s_ident *src)
+{
+ ident->module = src->module;
+ ident->sym = src->sym;
+ return ident;
+}
+
s_str * ident_inspect (const s_ident *ident, s_str *dest)
{
sw r;
diff --git a/libc3/ident.h b/libc3/ident.h
index a39b33a..3c74304 100644
--- a/libc3/ident.h
+++ b/libc3/ident.h
@@ -23,6 +23,7 @@
s_ident * ident_init (s_ident *ident, const s_sym *module,
const s_sym *sym);
s_ident * ident_init_1 (s_ident *ident, const s8 *p);
+s_ident * ident_init_copy (s_ident *ident, const s_ident *src);
/* Modifiers */
s_ident * ident_resolve_module (s_ident *ident, const s_env *env);
@@ -32,8 +33,6 @@ s_ident * ident_resolve_module (s_ident *ident, const s_env *env);
/* Returns true iff c is an ident reserved character. */
bool ident_character_is_reserved (character c);
-s_ident * ident_copy (const s_ident *src, s_ident *dest);
-
/* Returns true iff c is an ident reserved character as first. */
bool ident_first_character_is_reserved (character c);
diff --git a/libc3/list.c b/libc3/list.c
index 712b593..913a27c 100644
--- a/libc3/list.c
+++ b/libc3/list.c
@@ -55,38 +55,12 @@ s_list ** list_cast (const s_tag *tag, s_list **list)
{
assert(tag);
if (tag->type == TAG_LIST) {
- list_copy((const s_list **) &tag->data.list, list);
+ list_init_copy(list, (const s_list **) &tag->data.list);
return list;
}
return NULL;
}
-/* FIXME: does not work on circular lists */
-s_list ** list_copy (const s_list **src, s_list **dest)
-{
- s_list **i;
- s_list *next;
- const s_list *s;
- assert(src);
- assert(dest);
- i = dest;
- *i = NULL;
- s = *src;
- while (s) {
- *i = list_new(NULL);
- tag_copy(&s->tag, &(*i)->tag);
- if ((next = list_next(s))) {
- s = next;
- i = &(*i)->next.data.list;
- }
- else {
- tag_copy(&s->next, &(*i)->next);
- break;
- }
- }
- return dest;
-}
-
s_list * list_delete (s_list *list)
{
s_list *next = NULL;
@@ -115,12 +89,39 @@ s_list * list_init (s_list *list, s_list *next)
return list;
}
-s_list * list_init_copy (s_list *list, const s_tag *tag, s_list *next)
+/* FIXME: does not work on circular lists */
+s_list ** list_init_copy (s_list **list, const s_list **src)
+{
+ s_list **i;
+ s_list *next;
+ const s_list *s;
+ assert(src);
+ assert(list);
+ i = list;
+ *i = NULL;
+ s = *src;
+ while (s) {
+ *i = list_new(NULL);
+ tag_init_copy(&(*i)->tag, &s->tag);
+ if ((next = list_next(s))) {
+ s = next;
+ i = &(*i)->next.data.list;
+ }
+ else {
+ tag_init_copy(&(*i)->next, &s->next);
+ break;
+ }
+ }
+ return list;
+}
+
+s_list * list_init_copy_tag (s_list *list, const s_tag *tag, s_list *next)
{
assert(list);
assert(tag);
list_init(list, next);
- tag_copy(tag, &list->tag);
+ if (! tag_init_copy(&list->tag, tag))
+ return NULL;
return list;
}
@@ -163,54 +164,66 @@ s_list * list_next (const s_list *list)
s_list * list_new (s_list *next)
{
- s_list *list;
- if (! (list = calloc(1, sizeof(s_list)))) {
+ s_list *dest;
+ if (! (dest = calloc(1, sizeof(s_list)))) {
warnx("list_new: out of memory");
return NULL;
}
- return list_init(list, next);
+ return list_init(dest, next);
}
-s_list * list_new_copy (const s_tag *tag, s_list *next)
+s_list * list_new_copy (const s_tag *x, s_list *next)
{
- s_list *list;
- if ((list = list_new(next))) {
- if (! tag_copy(tag, &list->tag)) {
- free(list);
+ s_list *dest;
+ if ((dest = list_new(next))) {
+ if (! tag_init_copy(&dest->tag, x)) {
+ free(dest);
return NULL;
}
}
- return list;
+ return dest;
}
s_list * list_new_f64 (f64 x, s_list *next)
{
- s_list *list;
- if ((list = list_new(next))) {
- if (! tag_init_f64(&list->tag, x)) {
- free(list);
+ s_list *dest;
+ if ((dest = list_new(next))) {
+ if (! tag_init_f64(&dest->tag, x)) {
+ free(dest);
return NULL;
}
}
- return list;
+ return dest;
}
-s_list * list_new_str_1 (s8 *free_, const s8 *p, s_list *next)
+s_list * list_new_list (s_list *x, s_list *next)
{
- s_list *list;
- if ((list = list_new(next))) {
- if (! tag_init_str_1(&list->tag, free_, p)) {
- free(list);
+ s_list *dest;
+ if ((dest = list_new(next))) {
+ if (! tag_init_list(&dest->tag, x)) {
+ free(dest);
return NULL;
}
}
- return list;
+ return dest;
+}
+
+s_list * list_new_str_1 (s8 *x_free, const s8 *x, s_list *next)
+{
+ s_list *dest;
+ if ((dest = list_new(next))) {
+ if (! tag_init_str_1(&dest->tag, x_free, x)) {
+ free(dest);
+ return NULL;
+ }
+ }
+ return dest;
}
s_array * list_to_array (s_list *list, const s_sym *type,
s_array *dest)
{
- f_copy copy;
+ f_init_copy init_copy;
s8 *data;
void *data_list;
s_list *l;
@@ -230,11 +243,11 @@ 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");
- copy = array_type_to_copy(type);
+ init_copy = array_type_to_init_copy(type);
l = list;
while (l) {
data_list = tag_to_pointer(&l->tag, type);
- copy(data_list, data);
+ init_copy(data, data_list);
data += size;
l = list_next(l);
}
diff --git a/libc3/list.h b/libc3/list.h
index c0f247a..8b7bb6b 100644
--- a/libc3/list.h
+++ b/libc3/list.h
@@ -25,15 +25,17 @@
#include "types.h"
/* Stack allocation compatible functions, do not use */
-void list_clean (s_list **list);
-s_list * list_init (s_list *list, s_list *next);
-s_list * list_init_copy (s_list *list, const s_tag *tag, s_list *next);
+void list_clean (s_list **list);
+s_list * list_init (s_list *list, s_list *next);
+s_list ** list_init_copy (s_list **list, const s_list **src);
+s_list * list_init_copy_tag (s_list *list, const s_tag *tag, s_list *next);
/* Constructors, call list_delete after use */
s_list * list_1 (const s8 *p);
s_list * list_new (s_list *next);
s_list * list_new_f64 (f64 x, s_list *next);
s_list * list_new_copy (const s_tag *tag, s_list *next);
+s_list * list_new_list (s_list *list, s_list *next);
s_list * list_new_str_1 (s8 *free, const s8 *p, s_list *next);
/* Destructor */
@@ -42,13 +44,12 @@ void list_delete_all (s_list *list);
/* Observers */
s_list ** list_cast (const s_tag *tag, s_list **list);
-s_list ** list_copy (const s_list **src, s_list **dest);
sw list_length (const s_list *list);
-s_list * list_next (const s_list *list);
+s_list * list_next (const s_list *list);
s_array * list_to_array (s_list *list, const s_sym *type,
s_array *dest);
s_tuple * list_to_tuple_reverse (const s_list *list, s_tuple *dest);
/* Call str_delete after use. */
-s_str * list_inspect (const s_list *list, s_str *dest);
+s_str * list_inspect (const s_list *list, s_str *dest);
#endif /* LIBC3_LIST_H */
diff --git a/libc3/map.c b/libc3/map.c
index 4d65142..c136e48 100644
--- a/libc3/map.c
+++ b/libc3/map.c
@@ -38,7 +38,7 @@ s_map * map_cast (const s_tag *tag, s_map *map)
{
assert(tag);
if (tag->type == TAG_MAP) {
- map_copy(&tag->data.map, map);
+ map_init_copy(map, &tag->data.map);
return map;
}
return NULL;
@@ -57,20 +57,6 @@ void map_clean (s_map *map)
free(map->values);
}
-s_map * map_copy (const s_map *src, s_map *dest)
-{
- uw i = 0;
- assert(src);
- assert(dest);
- map_init(dest, src->count);
- while (i < src->count) {
- tag_copy(src->keys + i, dest->keys + i);
- tag_copy(src->values + i, dest->values + i);
- i++;
- }
- return dest;
-}
-
void map_delete (s_map *map)
{
assert(map);
@@ -83,7 +69,7 @@ s_tag * map_get (const s_map *map, const s_tag *key, s_tag *value)
uw i = 0;
while (i < map->count) {
if (compare_tag(key, map->keys + i) == 0)
- return tag_copy(map->values + i, value);
+ return tag_init_copy(value, map->values + i);
i++;
}
return NULL;
@@ -115,6 +101,20 @@ s_map * map_init_1 (s_map *map, const s8 *p)
return map;
}
+s_map * map_init_copy (s_map *map, const s_map *src)
+{
+ uw i = 0;
+ assert(src);
+ assert(map);
+ map_init(map, src->count);
+ while (i < src->count) {
+ tag_init_copy(map->keys + i, src->keys + i);
+ tag_init_copy(map->values + i, src->values + i);
+ i++;
+ }
+ return map;
+}
+
s_map * map_init_from_lists (s_map *map, const s_list *keys,
const s_list *values)
{
@@ -131,8 +131,8 @@ s_map * map_init_from_lists (s_map *map, const s_list *keys,
k = keys;
v = values;
while (i < len) {
- if (! tag_copy(&k->tag, map->keys + i) ||
- ! tag_copy(&v->tag, map->values + i))
+ if (! tag_init_copy(map->keys + i, &k->tag) ||
+ ! tag_init_copy(map->values + i, &v->tag))
goto ko;
k = list_next(k);
v = list_next(v);
@@ -209,7 +209,7 @@ s_map * map_set (s_map *map, const s_tag *key, const s_tag *value)
uw i = 0;
while (i < map->count) {
if (compare_tag(key, map->keys + i) == 0) {
- if (! tag_copy(value, map->values + i))
+ if (! tag_init_copy(map->values + i, value))
return NULL;
return map;
}
@@ -249,10 +249,10 @@ s_map * map_update (const s_map *map, const s_tag *key,
{
s_map tmp;
uw i = 0;
- map_copy(map, &tmp);
+ map_init_copy(&tmp, map);
while (i < map->count) {
if (compare_tag(key, map->keys + i) == 0) {
- if (! tag_copy(value, map->values + i))
+ if (! tag_init_copy(map->values + i, value))
goto ko;
*dest = tmp;
return dest;
@@ -269,7 +269,7 @@ s_map * map_update_list (const s_map *map, const s_list *alist, s_map *dest)
const s_list *i;
s_map tmp;
assert(map);
- map_copy(map, &tmp);
+ map_init_copy(&tmp, map);
i = alist;
while (i) {
assert(i->tag.type == TAG_TUPLE && i->tag.data.tuple.count == 2);
diff --git a/libc3/map.h b/libc3/map.h
index 31ebd1f..8a539bf 100644
--- a/libc3/map.h
+++ b/libc3/map.h
@@ -19,6 +19,7 @@
void map_clean (s_map *map);
s_map * map_init (s_map *map, uw size);
s_map * map_init_1 (s_map *map, const s8 *p);
+s_map * map_init_copy (s_map *map, const s_map *src);
s_map * map_init_from_lists (s_map *map, const s_list *keys,
const s_list *values);
@@ -32,9 +33,6 @@ s_map * map_new_from_lists (const s_list *keys, const s_list *values);
s_map * map_set (s_map *map, const s_tag *key, const s_tag *value);
s_map * map_sort (s_map *map);
-/* Observers */
-s_map * map_copy (const s_map *src, s_map *dest);
-
/* Operators */
s_tag * map_access (const s_map *map, const s_tag *key, s_tag *value);
s_map * map_cast (const s_tag *tag, s_map *map);
diff --git a/libc3/ptag.c b/libc3/ptag.c
index cdcfb14..944e042 100644
--- a/libc3/ptag.c
+++ b/libc3/ptag.c
@@ -14,7 +14,7 @@
#include <err.h>
#include "ptag.h"
-p_tag * ptag_copy (const p_tag *src, p_tag *dest)
+p_tag * ptag_init_copy (p_tag *dest, const p_tag *src)
{
assert(src);
assert(dest);
diff --git a/libc3/ptag.h b/libc3/ptag.h
index 7400414..9198fef 100644
--- a/libc3/ptag.h
+++ b/libc3/ptag.h
@@ -15,6 +15,6 @@
#include "types.h"
-p_tag * ptag_copy (const p_tag *src, p_tag *dest);
+p_tag * ptag_init_copy (p_tag *dest, const p_tag *src);
#endif /* LIBC3_PTAG_H */
diff --git a/libc3/quote.c b/libc3/quote.c
index 6ba7a82..21c1bbf 100644
--- a/libc3/quote.c
+++ b/libc3/quote.c
@@ -21,14 +21,14 @@ void quote_clean (s_quote *quote)
tag_delete(quote->tag);
}
-s_quote * quote_copy (const s_quote *src, s_quote *dest)
+s_quote * quote_init (s_quote *quote, const s_tag *tag)
{
- dest->tag = tag_new_copy(src->tag);
- return dest;
+ quote->tag = tag_new_copy(tag);
+ return quote;
}
-s_quote * quote_init (s_quote *quote, const s_tag *tag)
+s_quote * quote_init_copy (s_quote *quote, const s_quote *src)
{
- quote->tag = tag_new_copy(tag);
+ quote->tag = tag_new_copy(src->tag);
return quote;
}
diff --git a/libc3/quote.h b/libc3/quote.h
index 4f195f9..9ad70fa 100644
--- a/libc3/quote.h
+++ b/libc3/quote.h
@@ -15,7 +15,10 @@
#include "types.h"
+/* Stack-allocation compatible functions, call quote_clean after use. */
void quote_clean (s_quote *quote);
-s_quote * quote_copy (const s_quote *src, s_quote *dest);
+s_quote * quote_init (s_quote *quote, const s_tag *tag);
+s_quote * quote_init_1 (s_quote *quote, const s8 *p);
+s_quote * quote_init_copy (s_quote *quote, const s_quote *src);
#endif /* LIBC3_QUOTE_H */
diff --git a/libc3/s.c.in b/libc3/s.c.in
index ea7f372..3aba9d8 100644
--- a/libc3/s.c.in
+++ b/libc3/s.c.in
@@ -98,7 +98,7 @@ s_bits$ * s_bits$_cast (s_tag *tag, s_bits$ *dest)
return 0;
}
-s_bits$ * s_bits$_copy (const s_bits$ *src, s_bits$ *dest)
+s_bits$ * s_bits$_init_copy (s_bits$ *dest, const s_bits$ *src)
{
assert(src);
assert(dest);
diff --git a/libc3/s.h.in b/libc3/s.h.in
index 8086284..e64d08b 100644
--- a/libc3/s.h.in
+++ b/libc3/s.h.in
@@ -17,6 +17,6 @@
#include "types.h"
s_bits$ * s_bits$_cast (s_tag *tag, s_bits$ *dest);
-s_bits$ * s_bits$_copy (const s_bits$ *src, s_bits$ *dest);
+s_bits$ * s_bits$_init_copy (s_bits$ *dest, const s_bits$ *src);
#endif /* LIBC3_S_BITS$_H */
diff --git a/libc3/s16.c b/libc3/s16.c
index e73d109..e9feb3e 100644
--- a/libc3/s16.c
+++ b/libc3/s16.c
@@ -98,7 +98,7 @@ s16 * s16_cast (s_tag *tag, s16 *dest)
return 0;
}
-s16 * s16_copy (const s16 *src, s16 *dest)
+s16 * s16_init_copy (s16 *dest, const s16 *src)
{
assert(src);
assert(dest);
diff --git a/libc3/s16.h b/libc3/s16.h
index 6b29aa4..4becf01 100644
--- a/libc3/s16.h
+++ b/libc3/s16.h
@@ -17,6 +17,6 @@
#include "types.h"
s16 * s16_cast (s_tag *tag, s16 *dest);
-s16 * s16_copy (const s16 *src, s16 *dest);
+s16 * s16_init_copy (s16 *dest, const s16 *src);
#endif /* LIBC3_S16_H */
diff --git a/libc3/s32.c b/libc3/s32.c
index 2c8aa5b..343e105 100644
--- a/libc3/s32.c
+++ b/libc3/s32.c
@@ -98,7 +98,7 @@ s32 * s32_cast (s_tag *tag, s32 *dest)
return 0;
}
-s32 * s32_copy (const s32 *src, s32 *dest)
+s32 * s32_init_copy (s32 *dest, const s32 *src)
{
assert(src);
assert(dest);
diff --git a/libc3/s32.h b/libc3/s32.h
index 6d2de36..aa3758b 100644
--- a/libc3/s32.h
+++ b/libc3/s32.h
@@ -17,6 +17,6 @@
#include "types.h"
s32 * s32_cast (s_tag *tag, s32 *dest);
-s32 * s32_copy (const s32 *src, s32 *dest);
+s32 * s32_init_copy (s32 *dest, const s32 *src);
#endif /* LIBC3_S32_H */
diff --git a/libc3/s64.c b/libc3/s64.c
index 604ab1c..3d28bd6 100644
--- a/libc3/s64.c
+++ b/libc3/s64.c
@@ -98,7 +98,7 @@ s64 * s64_cast (s_tag *tag, s64 *dest)
return 0;
}
-s64 * s64_copy (const s64 *src, s64 *dest)
+s64 * s64_init_copy (s64 *dest, const s64 *src)
{
assert(src);
assert(dest);
diff --git a/libc3/s64.h b/libc3/s64.h
index 6ca0023..b3c289c 100644
--- a/libc3/s64.h
+++ b/libc3/s64.h
@@ -17,6 +17,6 @@
#include "types.h"
s64 * s64_cast (s_tag *tag, s64 *dest);
-s64 * s64_copy (const s64 *src, s64 *dest);
+s64 * s64_init_copy (s64 *dest, const s64 *src);
#endif /* LIBC3_S64_H */
diff --git a/libc3/s8.c b/libc3/s8.c
index 7618723..0e457f1 100644
--- a/libc3/s8.c
+++ b/libc3/s8.c
@@ -98,7 +98,7 @@ s8 * s8_cast (s_tag *tag, s8 *dest)
return 0;
}
-s8 * s8_copy (const s8 *src, s8 *dest)
+s8 * s8_init_copy (s8 *dest, const s8 *src)
{
assert(src);
assert(dest);
diff --git a/libc3/s8.h b/libc3/s8.h
index 8a33544..b5a253d 100644
--- a/libc3/s8.h
+++ b/libc3/s8.h
@@ -17,6 +17,6 @@
#include "types.h"
s8 * s8_cast (s_tag *tag, s8 *dest);
-s8 * s8_copy (const s8 *src, s8 *dest);
+s8 * s8_init_copy (s8 *dest, const s8 *src);
#endif /* LIBC3_S8_H */
diff --git a/libc3/set_item.c.in b/libc3/set_item.c.in
index 04e2a7e..312e28b 100644
--- a/libc3/set_item.c.in
+++ b/libc3/set_item.c.in
@@ -23,7 +23,7 @@ set_item_new___NAME$ (const _TYPE$ *data, uw hash, s_set_item___NAME$ *next)
s_set_item___NAME$ *item;
if (! (item = malloc(sizeof(s_set_item___NAME$))))
errx(1, "set_item_new___NAME$: out of memory");
- _NAME$_copy(data, &item->data);
+ _NAME$_init_copy(&item->data, data);
item->hash = hash;
item->next = next;
item->usage = 0;
diff --git a/libc3/set_item__fact.c b/libc3/set_item__fact.c
index 0c284b2..da1643d 100644
--- a/libc3/set_item__fact.c
+++ b/libc3/set_item__fact.c
@@ -23,7 +23,7 @@ set_item_new__fact (const s_fact *data, uw hash, s_set_item__fact *next)
s_set_item__fact *item;
if (! (item = malloc(sizeof(s_set_item__fact))))
errx(1, "set_item_new__fact: out of memory");
- fact_copy(data, &item->data);
+ fact_init_copy(&item->data, data);
item->hash = hash;
item->next = next;
item->usage = 0;
diff --git a/libc3/set_item__tag.c b/libc3/set_item__tag.c
index 61adb02..95afa4c 100644
--- a/libc3/set_item__tag.c
+++ b/libc3/set_item__tag.c
@@ -23,7 +23,7 @@ set_item_new__tag (const s_tag *data, uw hash, s_set_item__tag *next)
s_set_item__tag *item;
if (! (item = malloc(sizeof(s_set_item__tag))))
errx(1, "set_item_new__tag: out of memory");
- tag_copy(data, &item->data);
+ tag_init_copy(&item->data, data);
item->hash = hash;
item->next = next;
item->usage = 0;
diff --git a/libc3/sources.mk b/libc3/sources.mk
index 7dc8ed7..dd058b8 100644
--- a/libc3/sources.mk
+++ b/libc3/sources.mk
@@ -262,6 +262,10 @@ SOURCES = \
sw.c \
sym.c \
tag.c \
+ tag_add.c \
+ tag_band.c \
+ tag_bor.c \
+ tag_bxor.c \
time.c \
tuple.c \
type.c \
@@ -397,6 +401,10 @@ LO_SOURCES = \
sw.c \
sym.c \
tag.c \
+ tag_add.c \
+ tag_band.c \
+ tag_bor.c \
+ tag_bxor.c \
time.c \
tuple.c \
type.c \
diff --git a/libc3/sources.sh b/libc3/sources.sh
index 69740d7..530f61e 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 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 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 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 '
diff --git a/libc3/str.c b/libc3/str.c
index 39b1fba..61a3a70 100644
--- a/libc3/str.c
+++ b/libc3/str.c
@@ -73,11 +73,6 @@ void str_clean (s_str *str)
free(str->free.p);
}
-s_str * str_copy (const s_str *src, s_str *dest)
-{
- return str_init_dup(dest, src);
-}
-
void str_delete (s_str *str)
{
str_clean(str);
@@ -129,7 +124,7 @@ s_str * str_init_alloc (s_str *str, uw size, const s8 *p)
return str;
}
-s_str * str_init_dup (s_str *str, const s_str *src)
+s_str * str_init_copy (s_str *str, const s_str *src)
{
assert(str);
assert(src);
@@ -140,7 +135,7 @@ s_str * str_init_dup (s_str *str, const s_str *src)
return str;
}
-s_str * str_init_dup_1 (s_str *str, const s8 *src)
+s_str * str_init_copy_1 (s_str *str, const s8 *src)
{
uw len;
assert(str);
@@ -181,14 +176,6 @@ s_str * str_init_vf (s_str *str, const char *fmt, va_list ap)
return str_init(str, s, len, s);
}
-s_str * str_init_str (s_str *str, const s_str *src)
-{
- assert(str);
- assert(src);
- *str = *src;
- return str;
-}
-
s_str * str_inspect (const s_str *src, s_str *dest)
{
s_buf buf;
@@ -233,56 +220,60 @@ s_str * str_new_1 (s8 *free, const s8 *s)
return str;
}
-s_str * str_new_cpy (uw size, const s8 *p)
+s_str * str_new_cpy (const s8 *p, uw size)
{
s8 *a;
s_str *str;
- a = malloc(size);
- if (! a)
- err(1, "out of memory");
+ if (! (a = malloc(size))) {
+ warn("str_new_cpy");
+ return NULL;
+ }
memcpy(a, p, size);
str = str_new(a, size, a);
return str;
}
-s_str * str_new_dup (const s_str *src)
+s_str * str_new_copy (const s_str *src)
{
- s8 *n;
- s_str *str;
+ s8 *a;
+ s_str *dest;
assert(src);
- n = malloc(src->size);
- memcpy(n, src->ptr.p, src->size);
- str = str_new(n, src->size, n);
- return str;
+ if (! (a = malloc(src->size))) {
+ warn("str_new_copy");
+ return NULL;
+ }
+ memcpy(a, src->ptr.p, src->size);
+ dest = str_new(a, src->size, a);
+ return dest;
}
s_str * str_new_empty (void)
{
- s_str *str;
- str = str_new(NULL, 0, NULL);
- return str;
+ s_str *dest;
+ dest = str_new(NULL, 0, "");
+ return dest;
}
s_str * str_new_f (const char *fmt, ...)
{
va_list ap;
- s_str *str;
+ s_str *dest;
va_start(ap, fmt);
- str = str_new_vf(fmt, ap);
+ dest = str_new_vf(fmt, ap);
va_end(ap);
- return str;
+ return dest;
}
s_str * str_new_vf (const char *fmt, va_list ap)
{
int len;
char *s;
- s_str *str;
+ s_str *dest;
len = vasprintf(&s, fmt, ap);
if (len < 0)
err(1, "vasprintf");
- str = str_new(s, len, s);
- return str;
+ dest = str_new(s, len, s);
+ return dest;
}
sw str_peek_character (const s_str *str, character *c)
diff --git a/libc3/str.h b/libc3/str.h
index 95a02ee..5bf695e 100644
--- a/libc3/str.h
+++ b/libc3/str.h
@@ -31,18 +31,17 @@ void str_clean (s_str *str);
s_str * str_init (s_str *str, s8 *free, uw size, const s8 *p);
s_str * str_init_1 (s_str *str, s8 *free, const s8 *p);
s_str * str_init_alloc (s_str *str, uw size, const s8 *p);
-s_str * str_init_dup (s_str *str, const s_str *src);
-s_str * str_init_dup_1 (s_str *str, const s8 *p);
+s_str * str_init_copy (s_str *str, const s_str *src);
+s_str * str_init_copy_1 (s_str *str, const s8 *p);
s_str * str_init_empty (s_str *str);
s_str * str_init_f (s_str *str, const char *fmt, ...);
-s_str * str_init_str (s_str *str, const s_str *src);
s_str * str_init_vf (s_str *str, const char *fmt, va_list ap);
/* Constructors, call str_delete after use */
s_str * str_new (s8 *free, uw size, const s8 *p);
s_str * str_new_1 (s8 *free, const s8 *p);
-s_str * str_new_cpy (uw size, const s8 *p);
-s_str * str_new_dup (const s_str *src);
+s_str * str_new_cpy (const s8 *p, uw size);
+s_str * str_new_copy (const s_str *src);
s_str * str_new_empty (void);
s_str * str_new_f (const char *fmt, ...);
s_str * str_new_vf (const char *fmt, va_list ap);
@@ -51,13 +50,11 @@ s_str * str_new_vf (const char *fmt, va_list ap);
void str_delete (s_str *str);
/* Observers */
-
sw str_character (const s_str *str, uw position,
character *dest);
character str_character_escape (character c);
bool str_character_is_reserved (character c);
sw str_character_position (const s_str *str, character c);
-s_str * str_copy (const s_str *src, s_str *dest);
bool str_has_reserved_characters (const s_str *str);
s_str * str_inspect (const s_str *x, s_str *dest);
sw str_length_utf8 (const s_str *str);
diff --git a/libc3/sw.c b/libc3/sw.c
index bfedad4..645bfb0 100644
--- a/libc3/sw.c
+++ b/libc3/sw.c
@@ -98,7 +98,7 @@ sw * sw_cast (s_tag *tag, sw *dest)
return 0;
}
-sw * sw_copy (const sw *src, sw *dest)
+sw * sw_init_copy (sw *dest, const sw *src)
{
assert(src);
assert(dest);
diff --git a/libc3/sw.h b/libc3/sw.h
index 44ccdfa..b17b069 100644
--- a/libc3/sw.h
+++ b/libc3/sw.h
@@ -17,6 +17,6 @@
#include "types.h"
sw * sw_cast (s_tag *tag, sw *dest);
-sw * sw_copy (const sw *src, sw *dest);
+sw * sw_init_copy (sw *dest, const sw *src);
#endif /* LIBC3_SW_H */
diff --git a/libc3/sym.c b/libc3/sym.c
index eca3f16..c567a05 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -51,14 +51,6 @@ bool sym_character_is_reserved (character c)
c == '}');
}
-const s_sym ** sym_copy (const s_sym **src, const s_sym **dest)
-{
- assert(src);
- assert(dest);
- *dest = *src;
- return dest;
-}
-
void sym_delete (s_sym *sym)
{
str_clean(&sym->str);
@@ -107,6 +99,14 @@ bool sym_has_reserved_characters (const s_sym *sym)
return false;
}
+const s_sym ** sym_init_copy (const s_sym **sym, const s_sym **src)
+{
+ assert(src);
+ assert(sym);
+ *sym = *src;
+ return sym;
+}
+
s_str * sym_inspect (const s_sym *sym, s_str *dest)
{
sw size;
@@ -147,7 +147,7 @@ const s_sym * sym_new (const s_str *src)
sym = malloc(sizeof(s_sym));
if (! sym)
err(1, "out of memory");
- str_init_dup(&sym->str, src);
+ str_init_copy(&sym->str, src);
g_sym_list = sym_list_new(sym, g_sym_list);
return sym;
}
diff --git a/libc3/sym.h b/libc3/sym.h
index 92a02af..50041d2 100644
--- a/libc3/sym.h
+++ b/libc3/sym.h
@@ -33,7 +33,7 @@ const s_sym * sym_1 (const s8 *p);
bool sym_character_is_reserved (character c);
-const s_sym ** sym_copy (const s_sym **src, const s_sym **dest);
+const s_sym ** sym_init_copy (const s_sym **sym, const s_sym **src);
/** @brief Call when exiting program. */
void sym_delete_all (void);
diff --git a/libc3/tag.c b/libc3/tag.c
index 203a31f..3a4bfc2 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -46,2841 +46,69 @@ s_tag * tag_1 (s_tag *tag, const s8 *p)
return tag_init_1(tag, p);
}
-s_tag * tag_add (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(&a->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_SW:
- return tag_init_f32(dest, a->data.f32 + (f32) b->data.sw);
- 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);
- case TAG_UW:
- return tag_init_f32(dest, a->data.f32 + (f32) b->data.uw);
- 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(&a->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_SW:
- return tag_init_f64(dest, a->data.f64 + (f64) b->data.sw);
- 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);
- case TAG_UW:
- return tag_init_f64(dest, a->data.f64 + (f64) b->data.uw);
- default:
- goto ko;
- }
- case TAG_INTEGER:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) 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_add(&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_add(&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_add(&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_add(&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_add(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_SW:
- integer_init_sw(&tmp, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&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_add(&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_add(&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_add(&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_add(&a->data.integer, &tmp, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_UW:
- integer_init_uw(&tmp, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- if (a->data.s8 < S8_MIN - b->data.s8 ||
- a->data.s8 > S8_MAX - b->data.s8)
- return tag_init_s16(dest, (s16) a->data.s8 + (s16) b->data.s8);
- else
- return tag_init_s8(dest, a->data.s8 + b->data.s8);
- case TAG_S16:
- if (a->data.s8 < S16_MIN - b->data.s16 ||
- a->data.s8 > S16_MAX - b->data.s16)
- return tag_init_s32(dest, (s32) a->data.s8 + (s32) b->data.s16);
- else
- return tag_init_s16(dest, (s16) a->data.s8 + b->data.s16);
- case TAG_S32:
- if (a->data.s8 < S32_MIN - b->data.s32 ||
- a->data.s8 > S32_MAX - b->data.s32)
- return tag_init_s64(dest, (s64) a->data.s8 + (s64) b->data.s32);
- else
- return tag_init_s32(dest, (s32) a->data.s8 + b->data.s32);
- case TAG_S64:
- if (a->data.s8 < S64_MIN - b->data.s64 ||
- a->data.s8 > S64_MAX - b->data.s64) {
- integer_init_s8(&tmp, a->data.s8);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, (s64) a->data.s8 + b->data.s64);
- case TAG_SW:
- if (a->data.s8 < SW_MIN - b->data.sw ||
- a->data.s8 > SW_MAX - b->data.sw) {
- integer_init_s8(&tmp, a->data.s8);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, (sw) a->data.s8 + b->data.sw);
- case TAG_U8:
- if (a->data.s8 < S8_MIN - b->data.u8 ||
- a->data.s8 > S8_MAX - b->data.u8)
- return tag_init_s16(dest, (s16) a->data.s8 + (s16) b->data.u8);
- else
- return tag_init_s8(dest, a->data.s8 + (s8) b->data.u8);
- case TAG_U16:
- if (a->data.s8 < S16_MIN - b->data.u16 ||
- a->data.s8 > S16_MAX - b->data.u16)
- return tag_init_s32(dest, (s32) a->data.s8 + (s32) b->data.u16);
- else
- return tag_init_s16(dest, (s16) a->data.s8 + (s16) b->data.u16);
- case TAG_U32:
- if (a->data.s8 < (s64) S32_MIN - (s64) b->data.u32 ||
- a->data.s8 > (s64) S32_MAX - (s64) b->data.u32)
- return tag_init_s64(dest, (s64) a->data.s8 + (s64) b->data.u32);
- else
- return tag_init_s32(dest, (s32) a->data.s8 + (s32) 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_add(&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_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- if (a->data.s16 < S16_MIN - b->data.s8 ||
- a->data.s16 > S16_MAX - b->data.s8)
- return tag_init_s32(dest, (s32) a->data.s16 + (s32) b->data.s8);
- else
- return tag_init_s16(dest, a->data.s16 + (s16) b->data.s8);
- case TAG_S16:
- if (a->data.s16 < S16_MIN - b->data.s16 ||
- a->data.s16 > S16_MAX - b->data.s16)
- return tag_init_s32(dest, (s32) a->data.s16 + (s32) b->data.s16);
- else
- return tag_init_s16(dest, a->data.s16 + b->data.s16);
- case TAG_S32:
- if (a->data.s16 < S32_MIN - b->data.s32 ||
- a->data.s16 > S32_MAX - b->data.s32)
- return tag_init_s64(dest, (s64) a->data.s16 + (s64) b->data.s32);
- else
- return tag_init_s32(dest, (s32) a->data.s16 + b->data.s32);
- case TAG_S64:
- if (a->data.s16 < S64_MIN - b->data.s64 ||
- a->data.s16 > S64_MAX - b->data.s64) {
- integer_init_s16(&tmp, a->data.s16);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, (s64) a->data.s16 + b->data.s64);
- case TAG_SW:
- if (a->data.s16 < SW_MIN - b->data.sw ||
- a->data.s16 > SW_MAX - b->data.sw) {
- integer_init_s16(&tmp, a->data.s16);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, (s64) a->data.s16 + b->data.s64);
- case TAG_U8:
- if (a->data.s16 > S16_MAX - b->data.u8)
- return tag_init_s32(dest, (s32) a->data.s16 + (s32) b->data.u8);
- else
- return tag_init_s16(dest, a->data.s16 + (s16) b->data.u8);
- case TAG_U16:
- if (a->data.s16 > S16_MAX - b->data.u16)
- return tag_init_s32(dest, (s32) a->data.s16 + (s32) b->data.u16);
- else
- return tag_init_s16(dest, a->data.s16 + (s16) 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_add(&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_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- if (a->data.s32 < S32_MIN - b->data.s8 ||
- a->data.s32 > S32_MAX - b->data.s8)
- return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.s8);
- else
- return tag_init_s32(dest, a->data.s32 + (s32) b->data.s8);
- case TAG_S16:
- if (a->data.s32 < S32_MIN - b->data.s16 ||
- a->data.s32 > S32_MAX - b->data.s16)
- return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.s16);
- else
- return tag_init_s32(dest, a->data.s32 + (s32) b->data.s16);
- case TAG_S32:
- if (a->data.s32 < S32_MIN - b->data.s32 ||
- a->data.s32 > S32_MAX - b->data.s32)
- return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.s32);
- else
- return tag_init_s32(dest, a->data.s32 + b->data.s32);
- case TAG_S64:
- if (a->data.s32 < S64_MIN - b->data.s64 ||
- a->data.s32 > S64_MAX - b->data.s64) {
- integer_init_s32(&tmp, a->data.s32);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, (s64) a->data.s32 + b->data.s64);
- case TAG_SW:
- if (a->data.s32 < SW_MIN - b->data.sw ||
- a->data.s32 > SW_MAX - b->data.sw) {
- integer_init_s32(&tmp, a->data.s32);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, (sw) a->data.s32 + b->data.sw);
- case TAG_U8:
- if (a->data.s32 > S32_MAX - b->data.u8)
- return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.u8);
- else
- return tag_init_s32(dest, a->data.s32 + (s32) b->data.u8);
- case TAG_U16:
- if (a->data.s32 > S32_MAX - b->data.u16)
- return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.u16);
- else
- return tag_init_s32(dest, a->data.s32 + (s32) b->data.u16);
- case TAG_U32:
- if (a->data.s32 > (s64) S32_MAX - (s64) b->data.u32)
- return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.u32);
- else
- return tag_init_s32(dest, a->data.s32 + (s32) 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_add(&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_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- if (a->data.s64 < S64_MIN - b->data.s8 ||
- a->data.s64 > S64_MAX - b->data.s8) {
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s8(&tmp2, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, a->data.s64 + (s64) b->data.s8);
- case TAG_S16:
- if (a->data.s64 < S64_MIN - b->data.s16 ||
- a->data.s64 > S64_MAX - b->data.s16) {
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s16(&tmp2, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, a->data.s64 + (s64) b->data.s16);
- case TAG_S32:
- if (a->data.s64 < S64_MIN - b->data.s32 ||
- a->data.s64 > S64_MAX - b->data.s32) {
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s32(&tmp2, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, a->data.s64 + (s64) b->data.s32);
- case TAG_S64:
- if (a->data.s64 < S64_MIN - b->data.s64 ||
- a->data.s64 > S64_MAX - b->data.s64) {
- integer_init_s64(&tmp, a->data.s64);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, a->data.s64 + b->data.s64);
- case TAG_SW:
- if (a->data.s64 < S64_MIN - (s64) b->data.sw ||
- a->data.s64 > S64_MAX - (s64) b->data.sw) {
- integer_init_s64(&tmp, a->data.s64);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, a->data.s64 + b->data.s64);
- case TAG_U8:
- if (a->data.s64 > S64_MAX - b->data.u8) {
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u8(&tmp2, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, a->data.s64 + (s64) b->data.u8);
- case TAG_U16:
- if (a->data.s64 > S64_MAX - b->data.u16) {
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u16(&tmp2, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, a->data.s64 + (s64) b->data.u16);
- case TAG_U32:
- if (a->data.s64 > S64_MAX - b->data.u32) {
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u32(&tmp2, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, a->data.s64 + (s64) b->data.u32);
- case TAG_U64:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_add(&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_add(&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_f32(dest, (f32) a->data.sw + b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.sw + b->data.f64);
- case TAG_INTEGER:
- integer_init_sw(&tmp, a->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- if (a->data.sw < SW_MIN - b->data.s8 ||
- a->data.sw > SW_MAX - b->data.s8) {
- integer_init_sw(&tmp, a->data.sw);
- integer_init_s8(&tmp2, b->data.s8);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, a->data.sw + (sw) b->data.s8);
- case TAG_S16:
- if (a->data.sw < SW_MIN - b->data.s16 ||
- a->data.sw > SW_MAX - b->data.s16) {
- integer_init_sw(&tmp, a->data.sw);
- integer_init_s16(&tmp2, b->data.s16);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, a->data.sw + (sw) b->data.s16);
- case TAG_S32:
- if (a->data.sw < SW_MIN - b->data.s32 ||
- a->data.sw > SW_MAX - b->data.s32) {
- integer_init_sw(&tmp, a->data.sw);
- integer_init_s32(&tmp2, b->data.s32);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, a->data.sw + (sw) b->data.s32);
- case TAG_S64:
- if (a->data.sw < S64_MIN - b->data.s64 ||
- a->data.sw > S64_MAX - b->data.s64) {
- integer_init_sw(&tmp, a->data.sw);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, (s64) a->data.sw + b->data.s64);
- case TAG_SW:
- if (a->data.sw < SW_MIN - b->data.sw ||
- a->data.sw > SW_MAX - b->data.sw) {
- integer_init_sw(&tmp, a->data.sw);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, a->data.sw + b->data.sw);
- case TAG_U8:
- if (a->data.sw > SW_MAX - b->data.u8) {
- integer_init_sw(&tmp, a->data.sw);
- integer_init_u8(&tmp2, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, a->data.sw + (sw) b->data.u8);
- case TAG_U16:
- if (a->data.sw > SW_MAX - b->data.u16) {
- integer_init_sw(&tmp, a->data.sw);
- integer_init_u16(&tmp2, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, a->data.sw + (sw) b->data.u16);
- case TAG_U32:
- if (a->data.sw > SW_MAX - b->data.u32) {
- integer_init_sw(&tmp, a->data.sw);
- integer_init_u32(&tmp2, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, a->data.sw + (sw) b->data.u32);
- case TAG_U64:
- integer_init_sw(&tmp, a->data.sw);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_add(&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_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- if (a->data.u8 > S8_MAX - b->data.s8)
- return tag_init_s16(dest, (s16) a->data.u8 + (s16) b->data.s8);
- else
- return tag_init_s8(dest, (s8) a->data.u8 + b->data.s8);
- case TAG_S16:
- if (a->data.u8 > S16_MAX - b->data.s16)
- return tag_init_s32(dest, (s32) a->data.u8 + (s32) b->data.s16);
- else
- return tag_init_s16(dest, (s16) a->data.u8 + b->data.s16);
- case TAG_S32:
- if (a->data.u8 > S32_MAX - b->data.s32)
- return tag_init_s64(dest, (s64) a->data.u8 + (s64) b->data.s32);
- else
- return tag_init_s32(dest, (s32) a->data.u8 + b->data.s32);
- case TAG_S64:
- if (a->data.u8 > S64_MAX - b->data.s64) {
- integer_init_u8(&tmp, a->data.u8);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, (s64) a->data.u8 + b->data.s64);
- case TAG_SW:
- if (a->data.u8 > SW_MAX - b->data.sw) {
- integer_init_u8(&tmp, a->data.u8);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, (s64) a->data.u8 + b->data.s64);
- case TAG_U8:
- if (a->data.u8 > U8_MAX - b->data.u8)
- return tag_init_u16(dest, (u16) a->data.u8 + (u16) b->data.u8);
- else
- return tag_init_u8(dest, a->data.u8 + b->data.u8);
- case TAG_U16:
- if (a->data.u8 > U16_MAX - b->data.u16)
- return tag_init_u32(dest, (u32) a->data.u8 + (u32) b->data.u16);
- else
- return tag_init_u16(dest, (u16) a->data.u8 + b->data.u16);
- case TAG_U32:
- if (a->data.u8 > U32_MAX - b->data.u32)
- return tag_init_u64(dest, (u64) a->data.u8 + (u64) b->data.u32);
- else
- return tag_init_u32(dest, (u32) a->data.u8 + b->data.u32);
- case TAG_U64:
- if (a->data.u8 > U64_MAX - b->data.u64) {
- integer_init_u8(&tmp, a->data.u8);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_u64(dest, (u64) a->data.u8 + b->data.u64);
- case TAG_UW:
- if (a->data.u8 > UW_MAX - b->data.uw) {
- integer_init_u8(&tmp, a->data.u8);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_uw(dest, (uw) a->data.u8 + b->data.uw);
- 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_add(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- if (a->data.u16 > S16_MAX - b->data.s8)
- return tag_init_s32(dest, (s32) a->data.u16 + (s32) b->data.s8);
- else
- return tag_init_s16(dest, (s16) a->data.u16 + (s16) b->data.s8);
- case TAG_S16:
- if (a->data.u16 > S16_MAX - b->data.s16)
- return tag_init_s32(dest, (s32) a->data.u16 + (s32) b->data.s16);
- else
- return tag_init_s16(dest, (s16) a->data.u16 + b->data.s16);
- case TAG_S32:
- if (a->data.u16 > S32_MAX - b->data.s32)
- return tag_init_s64(dest, (s64) a->data.u16 + (s64) b->data.s32);
- else
- return tag_init_s32(dest, (s32) a->data.u16 + b->data.s32);
- case TAG_S64:
- if (a->data.u16 > S64_MAX - b->data.s64) {
- integer_init_u16(&tmp, a->data.u16);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, (s64) a->data.u16 + b->data.s64);
- case TAG_SW:
- if (a->data.u16 > SW_MAX - b->data.sw) {
- integer_init_u16(&tmp, a->data.u16);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, (sw) a->data.u16 + b->data.sw);
- case TAG_U8:
- if (a->data.u16 > U16_MAX - b->data.u8)
- return tag_init_u32(dest, (u32) a->data.u16 + (u32) b->data.u8);
- else
- return tag_init_u16(dest, a->data.u16 + (u16) b->data.u8);
- case TAG_U16:
- if (a->data.u16 > U16_MAX - b->data.u16)
- return tag_init_u32(dest, (u32) a->data.u16 + (u32) b->data.u16);
- else
- return tag_init_u16(dest, a->data.u16 + b->data.u16);
- case TAG_U32:
- if (a->data.u16 > U32_MAX - b->data.u32)
- return tag_init_u64(dest, (u64) a->data.u16 + (u64) b->data.u32);
- else
- return tag_init_u32(dest, (u32) a->data.u16 + b->data.u32);
- case TAG_U64:
- if (a->data.u16 > U64_MAX - b->data.u64) {
- integer_init_u32(&tmp, (u32) a->data.u16);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_u64(dest, (u64) a->data.u16 + b->data.u64);
- case TAG_UW:
- if (a->data.u16 > UW_MAX - b->data.uw) {
- integer_init_u16(&tmp, a->data.u16);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_uw(dest, (uw) a->data.u16 + b->data.uw);
- 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_add(&tmp, &b->data.integer, &dest->data.integer);
- integer_clean(&tmp);
- return dest;
- case TAG_S8:
- if ((s64) a->data.u32 > S32_MAX - b->data.s8)
- return tag_init_s64(dest, (s64) a->data.u32 + (s64) b->data.s8);
- else
- return tag_init_s32(dest, (s32) a->data.u32 + (s32) b->data.s8);
- case TAG_S16:
- if ((s64) a->data.u32 > S32_MAX - b->data.s16)
- return tag_init_s64(dest, (s64) a->data.u32 + (s64) b->data.s16);
- else
- return tag_init_s32(dest, (s32) a->data.u32 + (s32) b->data.s16);
- case TAG_S32:
- if ((s64) a->data.u32 > S32_MAX - b->data.s32)
- return tag_init_s64(dest, (s64) a->data.u32 + (s64) b->data.s32);
- else
- return tag_init_s32(dest, (s32) a->data.u32 + b->data.s32);
- case TAG_S64:
- if (a->data.u32 > S64_MAX - b->data.s64) {
- integer_init_u32(&tmp, a->data.u32);
- integer_init_s64(&tmp2, b->data.s64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_s64(dest, (s64) a->data.u32 + b->data.s64);
- case TAG_SW:
- if (a->data.u32 > SW_MAX - b->data.sw) {
- integer_init_u32(&tmp, a->data.u32);
- integer_init_sw(&tmp2, b->data.sw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_sw(dest, (sw) a->data.u32 + b->data.sw);
- case TAG_U8:
- if (a->data.u32 > U32_MAX - b->data.u8)
- return tag_init_u64(dest, (u64) a->data.u32 + (u64) b->data.u8);
- else
- return tag_init_u32(dest, a->data.u32 + (u32) b->data.u8);
- case TAG_U16:
- if (a->data.u32 > U32_MAX - b->data.u16)
- return tag_init_u64(dest, (u64) a->data.u32 + (u64) b->data.u16);
- else
- return tag_init_u32(dest, a->data.u32 + (u32) b->data.u16);
- case TAG_U32:
- if (a->data.u32 > U32_MAX - b->data.u32)
- return tag_init_u64(dest, (u64) a->data.u32 + (u64) b->data.u32);
- else
- return tag_init_u32(dest, a->data.u32 + b->data.u32);
- case TAG_U64:
- if (a->data.u32 > U64_MAX - b->data.u64) {
- integer_init_u32(&tmp, a->data.u32);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_u64(dest, (u64) a->data.u32 + b->data.u64);
- case TAG_UW:
- if (a->data.u32 > UW_MAX - b->data.uw) {
- integer_init_u32(&tmp, a->data.u32);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_uw(dest, (uw) a->data.u32 + b->data.uw);
- 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_add(&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_add(&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_add(&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_add(&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_add(&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_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- if (a->data.u64 > U64_MAX - b->data.u8) {
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u8(&tmp2, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_u64(dest, a->data.u64 + (u64) b->data.u8);
- case TAG_U16:
- if (a->data.u64 > U64_MAX - b->data.u16) {
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u16(&tmp2, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_u64(dest, a->data.u64 + (u64) b->data.u16);
- case TAG_U32:
- if (a->data.u64 > U64_MAX - b->data.u32) {
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u32(&tmp2, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_u64(dest, a->data.u64 + (u64) b->data.u32);
- case TAG_U64:
- if (a->data.u64 > U64_MAX - b->data.u64) {
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_u64(dest, a->data.u64 + b->data.u64);
- case TAG_UW:
- if (a->data.u64 > U64_MAX - b->data.uw) {
- integer_init_u64(&tmp, a->data.u64);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_u64(dest, a->data.u64 + b->data.uw);
- default:
- goto ko;
- }
- case TAG_UW:
- switch (b->type) {
- case TAG_F32:
- return tag_init_f32(dest, (f32) a->data.uw + b->data.f32);
- case TAG_F64:
- return tag_init_f64(dest, (f64) a->data.uw + b->data.f64);
- case TAG_INTEGER:
- integer_init_uw(&tmp, a->data.uw);
- dest->type = TAG_INTEGER;
- integer_add(&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_add(&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_add(&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_add(&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_add(&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_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- case TAG_U8:
- if (a->data.uw > UW_MAX - b->data.u8) {
- integer_init_uw(&tmp, a->data.uw);
- integer_init_u8(&tmp2, b->data.u8);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_uw(dest, a->data.uw + (uw) b->data.u8);
- case TAG_U16:
- if (a->data.uw > UW_MAX - b->data.u16) {
- integer_init_uw(&tmp, a->data.uw);
- integer_init_u16(&tmp2, b->data.u16);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_uw(dest, a->data.uw + (uw) b->data.u16);
- case TAG_U32:
- if (a->data.uw > UW_MAX - b->data.u32) {
- integer_init_uw(&tmp, a->data.uw);
- integer_init_u32(&tmp2, b->data.u32);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_uw(dest, a->data.uw + (uw) b->data.u32);
- case TAG_U64:
- if (a->data.uw > U64_MAX - b->data.u64) {
- integer_init_uw(&tmp, a->data.uw);
- integer_init_u64(&tmp2, b->data.u64);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_u64(dest, (u64) a->data.uw + b->data.u64);
- case TAG_UW:
- if (a->data.uw > UW_MAX - b->data.uw) {
- integer_init_uw(&tmp, a->data.uw);
- integer_init_uw(&tmp2, b->data.uw);
- dest->type = TAG_INTEGER;
- integer_add(&tmp, &tmp2, &dest->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return dest;
- }
- else
- return tag_init_uw(dest, a->data.uw + b->data.uw);
- default:
- goto ko;
- }
- default:
- goto ko;
- }
- ko:
- errx(1, "cannot add %s to %s",
- tag_type_to_string(a->type),
- tag_type_to_string(b->type));
-}
-
-bool * tag_and (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_array (s_tag *tag, const s_array *a)
-{
- assert(tag);
- assert(a);
- tag_clean(tag);
- return tag_init_array(tag, a);
-}
-
-s_tag * tag_band (const s_tag *a, const s_tag *b, s_tag *result)
-{
- s_integer tmp;
- s_integer tmp2;
- assert(a);
- assert(b);
- assert(result);
- switch (a->type) {
- case TAG_INTEGER:
- switch (b->type) {
- case TAG_INTEGER:
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &b->data.integer,
- &result->data.integer);
- return result;
- case TAG_SW:
- integer_init_sw(&tmp, b->data.sw);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S64:
- integer_init_s64(&tmp, b->data.s64);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S32:
- integer_init_s32(&tmp, b->data.s32);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S16:
- integer_init_s16(&tmp, b->data.s16);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S8:
- integer_init_s8(&tmp, b->data.s8);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U8:
- integer_init_u8(&tmp, b->data.u8);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U16:
- integer_init_u16(&tmp, b->data.u16);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U32:
- integer_init_u32(&tmp, b->data.u32);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U64:
- integer_init_u64(&tmp, b->data.u64);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_UW:
- integer_init_uw(&tmp, b->data.uw);
- result->type = TAG_INTEGER;
- integer_band(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_SW:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_sw(&tmp, a->data.sw);
- integer_band(&tmp, &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_INTEGER:
- integer_init_s64(&tmp, a->data.s64);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- 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:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S32:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s32(&tmp, a->data.s32);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, a->data.s32 & b->data.sw);
- case TAG_S64:
- return tag_init_s64(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_s64(result, a->data.s32 & b->data.u32);
- case TAG_U64:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S16:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s16(&tmp, a->data.s16);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, a->data.s16 & b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, a->data.s16 & b->data.s64);
- case TAG_S32:
- return tag_init_s32(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_s32(result, a->data.s16 & b->data.u16);
- case TAG_U32:
- return tag_init_s64(result, a->data.s16 & b->data.u32);
- case TAG_U64:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S8:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s8(&tmp, a->data.s8);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, a->data.s8 & b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, a->data.s8 & b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, a->data.s8 & b->data.s32);
- case TAG_S16:
- return tag_init_s16(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_s16(result, a->data.s8 & b->data.u8);
- case TAG_U16:
- return tag_init_s32(result, a->data.s8 & b->data.u16);
- case TAG_U32:
- return tag_init_s64(result, a->data.s8 & b->data.u32);
- case TAG_U64:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_band(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_U8:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_u8(&tmp, a->data.u8);
- integer_band(&tmp, &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_INTEGER:
- integer_init_u16(&tmp, a->data.u16);
- integer_band(&tmp, &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_INTEGER:
- integer_init_u32(&tmp, a->data.u32);
- integer_band(&tmp, &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_INTEGER:
- integer_init_u64(&tmp, a->data.u64);
- integer_band(&tmp, &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_INTEGER:
- integer_init_uw(&tmp, a->data.uw);
- integer_band(&tmp, &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_band: invalid tag type: %s & %s",
- tag_type_to_string(a->type),
- tag_type_to_string(b->type));
- return NULL;
-}
-
-s_tag * tag_bnot (const s_tag *tag, s_tag *result)
-{
- assert(tag);
- assert(result);
- switch (tag->type) {
- case TAG_INTEGER:
- result->type = TAG_INTEGER;
- integer_bnot(&tag->data.integer, &result->data.integer);
- return result;
- case TAG_SW:
- return tag_init_sw(result, ~tag->data.sw);
- case TAG_S64:
- return tag_init_s64(result, ~tag->data.s64);
- case TAG_S32:
- return tag_init_s32(result, ~tag->data.s32);
- case TAG_S16:
- return tag_init_s16(result, ~tag->data.s16);
- case TAG_S8:
- return tag_init_s8(result, ~tag->data.s8);
- case TAG_U8:
- return tag_init_u8(result, ~tag->data.u8);
- case TAG_U16:
- return tag_init_u16(result, ~tag->data.u16);
- case TAG_U32:
- return tag_init_u32(result, ~tag->data.u32);
- case TAG_U64:
- return tag_init_u64(result, ~tag->data.u64);
- case TAG_UW:
- return tag_init_uw(result, ~tag->data.uw);
- default:
- warnx("tag_bnot: invalid tag type: %s",
- tag_type_to_string(tag->type));
- }
- return NULL;
-}
-
-s_tag * tag_bool (s_tag *tag, bool b)
-{
- assert(tag);
- tag_clean(tag);
- return tag_init_bool(tag, b);
-}
-
-s_tag * tag_bor (const s_tag *a, const s_tag *b, s_tag *result)
-{
- s_integer tmp;
- s_integer tmp2;
- assert(a);
- assert(b);
- assert(result);
- switch (a->type) {
- case TAG_INTEGER:
- switch (b->type) {
- case TAG_INTEGER:
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &b->data.integer,
- &result->data.integer);
- return result;
- case TAG_SW:
- integer_init_sw(&tmp, b->data.sw);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S64:
- integer_init_s64(&tmp, b->data.s64);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S32:
- integer_init_s32(&tmp, b->data.s32);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S16:
- integer_init_s16(&tmp, b->data.s16);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S8:
- integer_init_s8(&tmp, b->data.s8);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U8:
- integer_init_u8(&tmp, b->data.u8);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U16:
- integer_init_u16(&tmp, b->data.u16);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U32:
- integer_init_u32(&tmp, b->data.u32);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U64:
- integer_init_u64(&tmp, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_UW:
- integer_init_uw(&tmp, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_SW:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_sw(&tmp, a->data.sw);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- 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:
- integer_init_sw(&tmp, a->data.sw);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_sw(&tmp, a->data.sw);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S64:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s64(&tmp, a->data.s64);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- 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:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S32:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s32(&tmp, a->data.s32);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.s32 | b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) 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_s64(result, (s64) a->data.s32 | b->data.u32);
- case TAG_U64:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S16:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s16(&tmp, a->data.s16);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.s16 | b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.s16 | b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, (s32) 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_s32(result, (s32) a->data.s16 | b->data.u16);
- case TAG_U32:
- return tag_init_s64(result, (s64) a->data.s16 | b->data.u32);
- case TAG_U64:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S8:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s8(&tmp, a->data.s8);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.s8 | b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.s8 | b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, (s32) a->data.s8 | b->data.s32);
- case TAG_S16:
- return tag_init_s16(result, (s16) 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_s16(result, (s16) a->data.s8 | b->data.u8);
- case TAG_U16:
- return tag_init_s32(result, (s32) a->data.s8 | b->data.u16);
- case TAG_U32:
- return tag_init_s64(result, (s64) a->data.s8 | b->data.u32);
- case TAG_U64:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- 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_u32(result, a->data.u8 | b->data.character);
- case TAG_INTEGER:
- integer_init_u8(&tmp, a->data.u8);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.u8 | b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.u8 | b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, (s32) a->data.u8 | b->data.s32);
- case TAG_S16:
- return tag_init_s16(result, (s16) a->data.u8 | b->data.s16);
- case TAG_S8:
- return tag_init_s16(result, (s16) 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_u16(result, (u16) a->data.u8 | b->data.u16);
- case TAG_U32:
- return tag_init_u32(result, (u32) a->data.u8 | b->data.u32);
- case TAG_U64:
- return tag_init_u64(result, (u64) a->data.u8 | b->data.u64);
- case TAG_UW:
- return tag_init_uw(result, (uw) 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_u32(result, a->data.u16 | b->data.character);
- case TAG_INTEGER:
- integer_init_u16(&tmp, a->data.u16);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.u16 | b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.u16 | b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, (s32) a->data.u16 | b->data.s32);
- case TAG_S16:
- return tag_init_s32(result, (s32) a->data.u16 | b->data.s16);
- case TAG_S8:
- return tag_init_s32(result, (s32) 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, (u16) a->data.u16 | b->data.u16);
- case TAG_U32:
- return tag_init_u32(result, (u32) a->data.u16 | b->data.u32);
- case TAG_U64:
- return tag_init_u64(result, (u64) a->data.u16 | b->data.u64);
- case TAG_UW:
- return tag_init_uw(result, (uw) 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);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_s64(result, (s64) a->data.u32 | b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.u32 | b->data.s64);
- case TAG_S32:
- return tag_init_s64(result, (s64) a->data.u32 | b->data.s32);
- case TAG_S16:
- return tag_init_s64(result, (s64) a->data.u32 | b->data.s16);
- case TAG_S8:
- return tag_init_s64(result, (s64) 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, (u32) a->data.u32 | b->data.u16);
- case TAG_U32:
- return tag_init_u32(result, (u32) a->data.u32 | b->data.u32);
- case TAG_U64:
- return tag_init_u64(result, (u64) a->data.u32 | b->data.u64);
- case TAG_UW:
- return tag_init_uw(result, (uw) 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);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_sw(&tmp2, b->data.sw);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_S64:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s64(&tmp2, b->data.s64);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_S32:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s32(&tmp2, b->data.s32);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_S16:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s16(&tmp2, b->data.s16);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_S8:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s8(&tmp2, b->data.s8);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_U8:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u8(&tmp2, b->data.u8);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_U16:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u16(&tmp2, b->data.u16);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_U32:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u32(&tmp2, b->data.u32);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_U64:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- 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_bor(&tmp, &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_bor: invalid tag type: %s | %s",
- tag_type_to_string(a->type),
- tag_type_to_string(b->type));
- return NULL;
-}
-s_tag * tag_bxor (const s_tag *a, const s_tag *b, s_tag *result)
+bool * tag_and (const s_tag *a, const s_tag *b, bool *dest)
{
- s_integer tmp;
- s_integer tmp2;
+ s_tag f;
assert(a);
assert(b);
- assert(result);
- switch (a->type) {
- case TAG_INTEGER:
- switch (b->type) {
- case TAG_INTEGER:
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &b->data.integer,
- &result->data.integer);
- return result;
- case TAG_SW:
- integer_init_sw(&tmp, b->data.sw);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S64:
- integer_init_s64(&tmp, b->data.s64);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S32:
- integer_init_s32(&tmp, b->data.s32);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S16:
- integer_init_s16(&tmp, b->data.s16);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_S8:
- integer_init_s8(&tmp, b->data.s8);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U8:
- integer_init_u8(&tmp, b->data.u8);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U16:
- integer_init_u16(&tmp, b->data.u16);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U32:
- integer_init_u32(&tmp, b->data.u32);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_U64:
- integer_init_u64(&tmp, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_UW:
- integer_init_uw(&tmp, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bxor(&a->data.integer, &tmp, &result->data.integer);
- integer_clean(&tmp);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_SW:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_sw(&tmp, a->data.sw);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, a->data.sw ^ b->data.sw);
- case TAG_S64:
- return tag_init_s64(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_s64(result, a->data.sw ^ b->data.u32);
- case TAG_U64:
- integer_init_sw(&tmp, a->data.sw);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_sw(&tmp, a->data.sw);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S64:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s64(&tmp, a->data.s64);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- 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:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s64(&tmp, a->data.s64);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S32:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s32(&tmp, a->data.s32);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.s32 ^ b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) 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_s64(result, (s64) a->data.s32 ^ b->data.u32);
- case TAG_U64:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s32(&tmp, a->data.s32);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
- case TAG_S16:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s16(&tmp, a->data.s16);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.s16 ^ b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.s16 ^ b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, (s32) 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_s32(result, (s32) a->data.s16 ^ b->data.u16);
- case TAG_U32:
- return tag_init_s64(result, (s64) a->data.s16 ^ b->data.u32);
- case TAG_U64:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s16(&tmp, a->data.s16);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
+ 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_array (s_tag *tag, const s_array *a)
+{
+ assert(tag);
+ assert(a);
+ tag_clean(tag);
+ return tag_init_array(tag, a);
+}
+
+s_tag * tag_bnot (const s_tag *tag, s_tag *result)
+{
+ assert(tag);
+ assert(result);
+ switch (tag->type) {
+ case TAG_INTEGER:
+ result->type = TAG_INTEGER;
+ integer_bnot(&tag->data.integer, &result->data.integer);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, ~tag->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, ~tag->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, ~tag->data.s32);
+ case TAG_S16:
+ return tag_init_s16(result, ~tag->data.s16);
case TAG_S8:
- switch (b->type) {
- case TAG_INTEGER:
- integer_init_s8(&tmp, a->data.s8);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.s8 ^ b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.s8 ^ b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, (s32) a->data.s8 ^ b->data.s32);
- case TAG_S16:
- return tag_init_s16(result, (s16) 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_s16(result, (s16) a->data.s8 ^ b->data.u8);
- case TAG_U16:
- return tag_init_s32(result, (s32) a->data.s8 ^ b->data.u16);
- case TAG_U32:
- return tag_init_s64(result, (s64) a->data.s8 ^ b->data.u32);
- case TAG_U64:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_s8(&tmp, a->data.s8);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
+ return tag_init_s8(result, ~tag->data.s8);
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_u32(result, a->data.u8 ^ b->data.character);
- case TAG_INTEGER:
- integer_init_u8(&tmp, a->data.u8);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.u8 ^ b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.u8 ^ b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, (s32) a->data.u8 ^ b->data.s32);
- case TAG_S16:
- return tag_init_s16(result, (s16) a->data.u8 ^ b->data.s16);
- case TAG_S8:
- return tag_init_s16(result, (s16) 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_u16(result, (u16) a->data.u8 ^ b->data.u16);
- case TAG_U32:
- return tag_init_u32(result, (u32) a->data.u8 ^ b->data.u32);
- case TAG_U64:
- return tag_init_u64(result, (u64) a->data.u8 ^ b->data.u64);
- case TAG_UW:
- return tag_init_uw(result, (uw) a->data.u8 ^ b->data.uw);
- default:
- goto error;
- }
- goto error;
+ return tag_init_u8(result, ~tag->data.u8);
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_u32(result, a->data.u16 ^ b->data.character);
- case TAG_INTEGER:
- integer_init_u16(&tmp, a->data.u16);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_sw(result, (sw) a->data.u16 ^ b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.u16 ^ b->data.s64);
- case TAG_S32:
- return tag_init_s32(result, (s32) a->data.u16 ^ b->data.s32);
- case TAG_S16:
- return tag_init_s32(result, (s32) a->data.u16 ^ b->data.s16);
- case TAG_S8:
- return tag_init_s32(result, (s32) 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, (u16) a->data.u16 ^ b->data.u16);
- case TAG_U32:
- return tag_init_u32(result, (u32) a->data.u16 ^ b->data.u32);
- case TAG_U64:
- return tag_init_u64(result, (u64) a->data.u16 ^ b->data.u64);
- case TAG_UW:
- return tag_init_uw(result, (uw) a->data.u16 ^ b->data.uw);
- default:
- goto error;
- }
- goto error;
+ return tag_init_u16(result, ~tag->data.u16);
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);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- return tag_init_s64(result, (s64) a->data.u32 ^ b->data.sw);
- case TAG_S64:
- return tag_init_s64(result, (s64) a->data.u32 ^ b->data.s64);
- case TAG_S32:
- return tag_init_s64(result, (s64) a->data.u32 ^ b->data.s32);
- case TAG_S16:
- return tag_init_s64(result, (s64) a->data.u32 ^ b->data.s16);
- case TAG_S8:
- return tag_init_s64(result, (s64) 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, (u32) a->data.u32 ^ b->data.u16);
- case TAG_U32:
- return tag_init_u32(result, (u32) a->data.u32 ^ b->data.u32);
- case TAG_U64:
- return tag_init_u64(result, (u64) a->data.u32 ^ b->data.u64);
- case TAG_UW:
- return tag_init_uw(result, (uw) a->data.u32 ^ b->data.uw);
- default:
- goto error;
- }
- goto error;
+ return tag_init_u32(result, ~tag->data.u32);
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);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &b->data.integer, &result->data.integer);
- integer_clean(&tmp);
- return result;
- case TAG_SW:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_sw(&tmp2, b->data.sw);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_S64:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s64(&tmp2, b->data.s64);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_S32:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s32(&tmp2, b->data.s32);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_S16:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s16(&tmp2, b->data.s16);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_S8:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_s8(&tmp2, b->data.s8);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_U8:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u8(&tmp2, b->data.u8);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_U16:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u16(&tmp2, b->data.u16);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_U32:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u32(&tmp2, b->data.u32);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_U64:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_u64(&tmp2, b->data.u64);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- case TAG_UW:
- integer_init_u64(&tmp, a->data.u64);
- integer_init_uw(&tmp2, b->data.uw);
- result->type = TAG_INTEGER;
- integer_bxor(&tmp, &tmp2, &result->data.integer);
- integer_clean(&tmp);
- integer_clean(&tmp2);
- return result;
- default:
- goto error;
- }
- goto error;
+ return tag_init_u64(result, ~tag->data.u64);
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_bxor(&tmp, &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;
+ return tag_init_uw(result, ~tag->data.uw);
default:
- goto error;
+ warnx("tag_bnot: invalid tag type: %s",
+ tag_type_to_string(tag->type));
}
- error:
- warnx("tag_bxor: invalid tag type: %s ^ %s",
- tag_type_to_string(a->type),
- tag_type_to_string(b->type));
return NULL;
}
+s_tag * tag_bool (s_tag *tag, bool b)
+{
+ assert(tag);
+ tag_clean(tag);
+ return tag_init_bool(tag, b);
+}
+
s_tag * tag_cast_integer_to_s8 (s_tag *tag)
{
s8 i;
@@ -3020,45 +248,45 @@ s_tag * tag_brackets (s_tag *tag, const s_tag *address,
return NULL;
}
-s_tag * tag_copy (const s_tag *src, s_tag *dest)
+s_tag * tag_init_copy (s_tag *tag, const s_tag *src)
{
+ assert(tag);
assert(src);
- assert(dest);
- switch (src->type) {
+ switch (tag->type) {
case TAG_VAR:
- tag_init_var(dest);
+ tag_init_var(tag);
break;
case TAG_VOID:
break;
case TAG_ARRAY:
- array_copy(&src->data.array, &dest->data.array);
+ array_init_copy(&tag->data.array, &src->data.array);
break;
case TAG_CALL:
- call_copy(&src->data.call, &dest->data.call);
+ call_init_copy(&tag->data.call, &src->data.call);
break;
case TAG_CFN:
- cfn_copy(&src->data.cfn, &dest->data.cfn);
+ cfn_init_copy(&tag->data.cfn, &src->data.cfn);
break;
case TAG_FN:
- fn_copy(&src->data.fn, &dest->data.fn);
+ fn_init_copy(&tag->data.fn, &src->data.fn);
break;
case TAG_INTEGER:
- integer_copy(&src->data.integer, &dest->data.integer);
+ integer_init_copy(&tag->data.integer, &src->data.integer);
break;
case TAG_LIST:
- list_copy((const s_list **) &src->data.list, &dest->data.list);
+ list_init_copy(&tag->data.list, (const s_list **) &src->data.list);
break;
case TAG_MAP:
- map_copy(&src->data.map, &dest->data.map);
+ map_init_copy(&tag->data.map, &src->data.map);
break;
case TAG_QUOTE:
- quote_copy(&src->data.quote, &dest->data.quote);
+ quote_init_copy(&tag->data.quote, &src->data.quote);
break;
case TAG_STR:
- str_copy(&src->data.str, &dest->data.str);
+ str_init_copy(&tag->data.str, &src->data.str);
break;
case TAG_TUPLE:
- tuple_copy(&src->data.tuple, &dest->data.tuple);
+ tuple_init_copy(&tag->data.tuple, &src->data.tuple);
break;
case TAG_BOOL:
case TAG_CHARACTER:
@@ -3079,10 +307,10 @@ s_tag * tag_copy (const s_tag *src, s_tag *dest)
case TAG_U32:
case TAG_U64:
case TAG_UW:
- dest->data = src->data;
+ tag->data = src->data;
}
- dest->type = src->type;
- return dest;
+ tag->type = src->type;
+ return tag;
}
void tag_delete (s_tag *tag)
@@ -3656,7 +884,7 @@ s_tag * tag_init_array (s_tag *tag, const s_array *a)
assert(tag);
assert(a);
tag->type = TAG_ARRAY;
- array_copy(a, &tag->data.array);
+ array_init_copy(&tag->data.array, a);
return tag;
}
@@ -3729,8 +957,7 @@ s_tag * tag_init_integer (s_tag *tag, const s_integer *i)
assert(tag);
bzero(tag, sizeof(s_tag));
tag->type = TAG_INTEGER;
- integer_init(&tag->data.integer);
- integer_copy(i, &tag->data.integer);
+ integer_init_copy(&tag->data.integer, i);
return tag;
}
@@ -5532,7 +2759,7 @@ 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_copy(src, dest);
+ return tag_init_copy(dest, src);
}
s_tag * tag_new_var (void)
@@ -5576,7 +2803,7 @@ s_tag * tag_paren (const s_tag *tag, s_tag *dest)
{
assert(tag);
assert(dest);
- return tag_copy(tag, dest);
+ return tag_init_copy(dest, tag);
}
s_tag * tag_s8 (s_tag *tag, s8 x)
diff --git a/libc3/tag.h b/libc3/tag.h
index 84ef805..6fa3326 100644
--- a/libc3/tag.h
+++ b/libc3/tag.h
@@ -37,6 +37,7 @@ s_tag * tag_init_array (s_tag *tag, const s_array *a);
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);
+s_tag * tag_init_copy (s_tag *tag, const s_tag *src);
s_tag * tag_init_ident (s_tag *tag, const s_ident *ident);
s_tag * tag_init_ident_1 (s_tag *tag, const s8 *p);
s_tag * tag_init_integer (s_tag *tag, const s_integer *i);
@@ -130,7 +131,6 @@ 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_copy (const s_tag *src, s_tag *dest);
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);
diff --git a/libc3/tag_add.c b/libc3/tag_add.c
new file mode 100644
index 0000000..87f8656
--- /dev/null
+++ b/libc3/tag_add.c
@@ -0,0 +1,1217 @@
+/* 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_add (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(&a->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_SW:
+ return tag_init_f32(dest, a->data.f32 + (f32) b->data.sw);
+ 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);
+ case TAG_UW:
+ return tag_init_f32(dest, a->data.f32 + (f32) b->data.uw);
+ 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(&a->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_SW:
+ return tag_init_f64(dest, a->data.f64 + (f64) b->data.sw);
+ 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);
+ case TAG_UW:
+ return tag_init_f64(dest, a->data.f64 + (f64) b->data.uw);
+ default:
+ goto ko;
+ }
+ case TAG_INTEGER:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) 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_add(&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_add(&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_add(&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_add(&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_add(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_SW:
+ integer_init_sw(&tmp, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&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_add(&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_add(&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_add(&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_add(&a->data.integer, &tmp, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_UW:
+ integer_init_uw(&tmp, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ if (a->data.s8 < S8_MIN - b->data.s8 ||
+ a->data.s8 > S8_MAX - b->data.s8)
+ return tag_init_s16(dest, (s16) a->data.s8 + (s16) b->data.s8);
+ else
+ return tag_init_s8(dest, a->data.s8 + b->data.s8);
+ case TAG_S16:
+ if (a->data.s8 < S16_MIN - b->data.s16 ||
+ a->data.s8 > S16_MAX - b->data.s16)
+ return tag_init_s32(dest, (s32) a->data.s8 + (s32) b->data.s16);
+ else
+ return tag_init_s16(dest, (s16) a->data.s8 + b->data.s16);
+ case TAG_S32:
+ if (a->data.s8 < S32_MIN - b->data.s32 ||
+ a->data.s8 > S32_MAX - b->data.s32)
+ return tag_init_s64(dest, (s64) a->data.s8 + (s64) b->data.s32);
+ else
+ return tag_init_s32(dest, (s32) a->data.s8 + b->data.s32);
+ case TAG_S64:
+ if (a->data.s8 < S64_MIN - b->data.s64 ||
+ a->data.s8 > S64_MAX - b->data.s64) {
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, (s64) a->data.s8 + b->data.s64);
+ case TAG_SW:
+ if (a->data.s8 < SW_MIN - b->data.sw ||
+ a->data.s8 > SW_MAX - b->data.sw) {
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, (sw) a->data.s8 + b->data.sw);
+ case TAG_U8:
+ if (a->data.s8 < S8_MIN - b->data.u8 ||
+ a->data.s8 > S8_MAX - b->data.u8)
+ return tag_init_s16(dest, (s16) a->data.s8 + (s16) b->data.u8);
+ else
+ return tag_init_s8(dest, a->data.s8 + (s8) b->data.u8);
+ case TAG_U16:
+ if (a->data.s8 < S16_MIN - b->data.u16 ||
+ a->data.s8 > S16_MAX - b->data.u16)
+ return tag_init_s32(dest, (s32) a->data.s8 + (s32) b->data.u16);
+ else
+ return tag_init_s16(dest, (s16) a->data.s8 + (s16) b->data.u16);
+ case TAG_U32:
+ if (a->data.s8 < (s64) S32_MIN - (s64) b->data.u32 ||
+ a->data.s8 > (s64) S32_MAX - (s64) b->data.u32)
+ return tag_init_s64(dest, (s64) a->data.s8 + (s64) b->data.u32);
+ else
+ return tag_init_s32(dest, (s32) a->data.s8 + (s32) 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_add(&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_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ if (a->data.s16 < S16_MIN - b->data.s8 ||
+ a->data.s16 > S16_MAX - b->data.s8)
+ return tag_init_s32(dest, (s32) a->data.s16 + (s32) b->data.s8);
+ else
+ return tag_init_s16(dest, a->data.s16 + (s16) b->data.s8);
+ case TAG_S16:
+ if (a->data.s16 < S16_MIN - b->data.s16 ||
+ a->data.s16 > S16_MAX - b->data.s16)
+ return tag_init_s32(dest, (s32) a->data.s16 + (s32) b->data.s16);
+ else
+ return tag_init_s16(dest, a->data.s16 + b->data.s16);
+ case TAG_S32:
+ if (a->data.s16 < S32_MIN - b->data.s32 ||
+ a->data.s16 > S32_MAX - b->data.s32)
+ return tag_init_s64(dest, (s64) a->data.s16 + (s64) b->data.s32);
+ else
+ return tag_init_s32(dest, (s32) a->data.s16 + b->data.s32);
+ case TAG_S64:
+ if (a->data.s16 < S64_MIN - b->data.s64 ||
+ a->data.s16 > S64_MAX - b->data.s64) {
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, (s64) a->data.s16 + b->data.s64);
+ case TAG_SW:
+ if (a->data.s16 < SW_MIN - b->data.sw ||
+ a->data.s16 > SW_MAX - b->data.sw) {
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, (s64) a->data.s16 + b->data.s64);
+ case TAG_U8:
+ if (a->data.s16 > S16_MAX - b->data.u8)
+ return tag_init_s32(dest, (s32) a->data.s16 + (s32) b->data.u8);
+ else
+ return tag_init_s16(dest, a->data.s16 + (s16) b->data.u8);
+ case TAG_U16:
+ if (a->data.s16 > S16_MAX - b->data.u16)
+ return tag_init_s32(dest, (s32) a->data.s16 + (s32) b->data.u16);
+ else
+ return tag_init_s16(dest, a->data.s16 + (s16) 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_add(&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_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ if (a->data.s32 < S32_MIN - b->data.s8 ||
+ a->data.s32 > S32_MAX - b->data.s8)
+ return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.s8);
+ else
+ return tag_init_s32(dest, a->data.s32 + (s32) b->data.s8);
+ case TAG_S16:
+ if (a->data.s32 < S32_MIN - b->data.s16 ||
+ a->data.s32 > S32_MAX - b->data.s16)
+ return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.s16);
+ else
+ return tag_init_s32(dest, a->data.s32 + (s32) b->data.s16);
+ case TAG_S32:
+ if (a->data.s32 < S32_MIN - b->data.s32 ||
+ a->data.s32 > S32_MAX - b->data.s32)
+ return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.s32);
+ else
+ return tag_init_s32(dest, a->data.s32 + b->data.s32);
+ case TAG_S64:
+ if (a->data.s32 < S64_MIN - b->data.s64 ||
+ a->data.s32 > S64_MAX - b->data.s64) {
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, (s64) a->data.s32 + b->data.s64);
+ case TAG_SW:
+ if (a->data.s32 < SW_MIN - b->data.sw ||
+ a->data.s32 > SW_MAX - b->data.sw) {
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, (sw) a->data.s32 + b->data.sw);
+ case TAG_U8:
+ if (a->data.s32 > S32_MAX - b->data.u8)
+ return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.u8);
+ else
+ return tag_init_s32(dest, a->data.s32 + (s32) b->data.u8);
+ case TAG_U16:
+ if (a->data.s32 > S32_MAX - b->data.u16)
+ return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.u16);
+ else
+ return tag_init_s32(dest, a->data.s32 + (s32) b->data.u16);
+ case TAG_U32:
+ if (a->data.s32 > (s64) S32_MAX - (s64) b->data.u32)
+ return tag_init_s64(dest, (s64) a->data.s32 + (s64) b->data.u32);
+ else
+ return tag_init_s32(dest, a->data.s32 + (s32) 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_add(&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_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ if (a->data.s64 < S64_MIN - b->data.s8 ||
+ a->data.s64 > S64_MAX - b->data.s8) {
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s8(&tmp2, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, a->data.s64 + (s64) b->data.s8);
+ case TAG_S16:
+ if (a->data.s64 < S64_MIN - b->data.s16 ||
+ a->data.s64 > S64_MAX - b->data.s16) {
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s16(&tmp2, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, a->data.s64 + (s64) b->data.s16);
+ case TAG_S32:
+ if (a->data.s64 < S64_MIN - b->data.s32 ||
+ a->data.s64 > S64_MAX - b->data.s32) {
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s32(&tmp2, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, a->data.s64 + (s64) b->data.s32);
+ case TAG_S64:
+ if (a->data.s64 < S64_MIN - b->data.s64 ||
+ a->data.s64 > S64_MAX - b->data.s64) {
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, a->data.s64 + b->data.s64);
+ case TAG_SW:
+ if (a->data.s64 < S64_MIN - (s64) b->data.sw ||
+ a->data.s64 > S64_MAX - (s64) b->data.sw) {
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, a->data.s64 + b->data.s64);
+ case TAG_U8:
+ if (a->data.s64 > S64_MAX - b->data.u8) {
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u8(&tmp2, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, a->data.s64 + (s64) b->data.u8);
+ case TAG_U16:
+ if (a->data.s64 > S64_MAX - b->data.u16) {
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u16(&tmp2, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, a->data.s64 + (s64) b->data.u16);
+ case TAG_U32:
+ if (a->data.s64 > S64_MAX - b->data.u32) {
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u32(&tmp2, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, a->data.s64 + (s64) b->data.u32);
+ case TAG_U64:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_add(&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_add(&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_f32(dest, (f32) a->data.sw + b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.sw + b->data.f64);
+ case TAG_INTEGER:
+ integer_init_sw(&tmp, a->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ if (a->data.sw < SW_MIN - b->data.s8 ||
+ a->data.sw > SW_MAX - b->data.s8) {
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_s8(&tmp2, b->data.s8);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, a->data.sw + (sw) b->data.s8);
+ case TAG_S16:
+ if (a->data.sw < SW_MIN - b->data.s16 ||
+ a->data.sw > SW_MAX - b->data.s16) {
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_s16(&tmp2, b->data.s16);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, a->data.sw + (sw) b->data.s16);
+ case TAG_S32:
+ if (a->data.sw < SW_MIN - b->data.s32 ||
+ a->data.sw > SW_MAX - b->data.s32) {
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_s32(&tmp2, b->data.s32);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, a->data.sw + (sw) b->data.s32);
+ case TAG_S64:
+ if (a->data.sw < S64_MIN - b->data.s64 ||
+ a->data.sw > S64_MAX - b->data.s64) {
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, (s64) a->data.sw + b->data.s64);
+ case TAG_SW:
+ if (a->data.sw < SW_MIN - b->data.sw ||
+ a->data.sw > SW_MAX - b->data.sw) {
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, a->data.sw + b->data.sw);
+ case TAG_U8:
+ if (a->data.sw > SW_MAX - b->data.u8) {
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_u8(&tmp2, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, a->data.sw + (sw) b->data.u8);
+ case TAG_U16:
+ if (a->data.sw > SW_MAX - b->data.u16) {
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_u16(&tmp2, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, a->data.sw + (sw) b->data.u16);
+ case TAG_U32:
+ if (a->data.sw > SW_MAX - b->data.u32) {
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_u32(&tmp2, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, a->data.sw + (sw) b->data.u32);
+ case TAG_U64:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_add(&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_add(&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_add(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ if (a->data.u8 > S8_MAX - b->data.s8)
+ return tag_init_s16(dest, (s16) a->data.u8 + (s16) b->data.s8);
+ else
+ return tag_init_s8(dest, (s8) a->data.u8 + b->data.s8);
+ case TAG_S16:
+ if (a->data.u8 > S16_MAX - b->data.s16)
+ return tag_init_s32(dest, (s32) a->data.u8 + (s32) b->data.s16);
+ else
+ return tag_init_s16(dest, (s16) a->data.u8 + b->data.s16);
+ case TAG_S32:
+ if (a->data.u8 > S32_MAX - b->data.s32)
+ return tag_init_s64(dest, (s64) a->data.u8 + (s64) b->data.s32);
+ else
+ return tag_init_s32(dest, (s32) a->data.u8 + b->data.s32);
+ case TAG_S64:
+ if (a->data.u8 > S64_MAX - b->data.s64) {
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, (s64) a->data.u8 + b->data.s64);
+ case TAG_SW:
+ if (a->data.u8 > SW_MAX - b->data.sw) {
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, (s64) a->data.u8 + b->data.s64);
+ case TAG_U8:
+ if (a->data.u8 > U8_MAX - b->data.u8)
+ return tag_init_u16(dest, (u16) a->data.u8 + (u16) b->data.u8);
+ else
+ return tag_init_u8(dest, a->data.u8 + b->data.u8);
+ case TAG_U16:
+ if (a->data.u8 > U16_MAX - b->data.u16)
+ return tag_init_u32(dest, (u32) a->data.u8 + (u32) b->data.u16);
+ else
+ return tag_init_u16(dest, (u16) a->data.u8 + b->data.u16);
+ case TAG_U32:
+ if (a->data.u8 > U32_MAX - b->data.u32)
+ return tag_init_u64(dest, (u64) a->data.u8 + (u64) b->data.u32);
+ else
+ return tag_init_u32(dest, (u32) a->data.u8 + b->data.u32);
+ case TAG_U64:
+ if (a->data.u8 > U64_MAX - b->data.u64) {
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_u64(dest, (u64) a->data.u8 + b->data.u64);
+ case TAG_UW:
+ if (a->data.u8 > UW_MAX - b->data.uw) {
+ integer_init_u8(&tmp, a->data.u8);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_uw(dest, (uw) a->data.u8 + b->data.uw);
+ 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_add(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ if (a->data.u16 > S16_MAX - b->data.s8)
+ return tag_init_s32(dest, (s32) a->data.u16 + (s32) b->data.s8);
+ else
+ return tag_init_s16(dest, (s16) a->data.u16 + (s16) b->data.s8);
+ case TAG_S16:
+ if (a->data.u16 > S16_MAX - b->data.s16)
+ return tag_init_s32(dest, (s32) a->data.u16 + (s32) b->data.s16);
+ else
+ return tag_init_s16(dest, (s16) a->data.u16 + b->data.s16);
+ case TAG_S32:
+ if (a->data.u16 > S32_MAX - b->data.s32)
+ return tag_init_s64(dest, (s64) a->data.u16 + (s64) b->data.s32);
+ else
+ return tag_init_s32(dest, (s32) a->data.u16 + b->data.s32);
+ case TAG_S64:
+ if (a->data.u16 > S64_MAX - b->data.s64) {
+ integer_init_u16(&tmp, a->data.u16);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, (s64) a->data.u16 + b->data.s64);
+ case TAG_SW:
+ if (a->data.u16 > SW_MAX - b->data.sw) {
+ integer_init_u16(&tmp, a->data.u16);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, (sw) a->data.u16 + b->data.sw);
+ case TAG_U8:
+ if (a->data.u16 > U16_MAX - b->data.u8)
+ return tag_init_u32(dest, (u32) a->data.u16 + (u32) b->data.u8);
+ else
+ return tag_init_u16(dest, a->data.u16 + (u16) b->data.u8);
+ case TAG_U16:
+ if (a->data.u16 > U16_MAX - b->data.u16)
+ return tag_init_u32(dest, (u32) a->data.u16 + (u32) b->data.u16);
+ else
+ return tag_init_u16(dest, a->data.u16 + b->data.u16);
+ case TAG_U32:
+ if (a->data.u16 > U32_MAX - b->data.u32)
+ return tag_init_u64(dest, (u64) a->data.u16 + (u64) b->data.u32);
+ else
+ return tag_init_u32(dest, (u32) a->data.u16 + b->data.u32);
+ case TAG_U64:
+ if (a->data.u16 > U64_MAX - b->data.u64) {
+ integer_init_u32(&tmp, (u32) a->data.u16);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_u64(dest, (u64) a->data.u16 + b->data.u64);
+ case TAG_UW:
+ if (a->data.u16 > UW_MAX - b->data.uw) {
+ integer_init_u16(&tmp, a->data.u16);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_uw(dest, (uw) a->data.u16 + b->data.uw);
+ 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_add(&tmp, &b->data.integer, &dest->data.integer);
+ integer_clean(&tmp);
+ return dest;
+ case TAG_S8:
+ if ((s64) a->data.u32 > S32_MAX - b->data.s8)
+ return tag_init_s64(dest, (s64) a->data.u32 + (s64) b->data.s8);
+ else
+ return tag_init_s32(dest, (s32) a->data.u32 + (s32) b->data.s8);
+ case TAG_S16:
+ if ((s64) a->data.u32 > S32_MAX - b->data.s16)
+ return tag_init_s64(dest, (s64) a->data.u32 + (s64) b->data.s16);
+ else
+ return tag_init_s32(dest, (s32) a->data.u32 + (s32) b->data.s16);
+ case TAG_S32:
+ if ((s64) a->data.u32 > S32_MAX - b->data.s32)
+ return tag_init_s64(dest, (s64) a->data.u32 + (s64) b->data.s32);
+ else
+ return tag_init_s32(dest, (s32) a->data.u32 + b->data.s32);
+ case TAG_S64:
+ if (a->data.u32 > S64_MAX - b->data.s64) {
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_s64(&tmp2, b->data.s64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_s64(dest, (s64) a->data.u32 + b->data.s64);
+ case TAG_SW:
+ if (a->data.u32 > SW_MAX - b->data.sw) {
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_sw(&tmp2, b->data.sw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_sw(dest, (sw) a->data.u32 + b->data.sw);
+ case TAG_U8:
+ if (a->data.u32 > U32_MAX - b->data.u8)
+ return tag_init_u64(dest, (u64) a->data.u32 + (u64) b->data.u8);
+ else
+ return tag_init_u32(dest, a->data.u32 + (u32) b->data.u8);
+ case TAG_U16:
+ if (a->data.u32 > U32_MAX - b->data.u16)
+ return tag_init_u64(dest, (u64) a->data.u32 + (u64) b->data.u16);
+ else
+ return tag_init_u32(dest, a->data.u32 + (u32) b->data.u16);
+ case TAG_U32:
+ if (a->data.u32 > U32_MAX - b->data.u32)
+ return tag_init_u64(dest, (u64) a->data.u32 + (u64) b->data.u32);
+ else
+ return tag_init_u32(dest, a->data.u32 + b->data.u32);
+ case TAG_U64:
+ if (a->data.u32 > U64_MAX - b->data.u64) {
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_u64(dest, (u64) a->data.u32 + b->data.u64);
+ case TAG_UW:
+ if (a->data.u32 > UW_MAX - b->data.uw) {
+ integer_init_u32(&tmp, a->data.u32);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_uw(dest, (uw) a->data.u32 + b->data.uw);
+ 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_add(&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_add(&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_add(&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_add(&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_add(&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_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ if (a->data.u64 > U64_MAX - b->data.u8) {
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u8(&tmp2, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_u64(dest, a->data.u64 + (u64) b->data.u8);
+ case TAG_U16:
+ if (a->data.u64 > U64_MAX - b->data.u16) {
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u16(&tmp2, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_u64(dest, a->data.u64 + (u64) b->data.u16);
+ case TAG_U32:
+ if (a->data.u64 > U64_MAX - b->data.u32) {
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u32(&tmp2, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_u64(dest, a->data.u64 + (u64) b->data.u32);
+ case TAG_U64:
+ if (a->data.u64 > U64_MAX - b->data.u64) {
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_u64(dest, a->data.u64 + b->data.u64);
+ case TAG_UW:
+ if (a->data.u64 > U64_MAX - b->data.uw) {
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_u64(dest, a->data.u64 + b->data.uw);
+ default:
+ goto ko;
+ }
+ case TAG_UW:
+ switch (b->type) {
+ case TAG_F32:
+ return tag_init_f32(dest, (f32) a->data.uw + b->data.f32);
+ case TAG_F64:
+ return tag_init_f64(dest, (f64) a->data.uw + b->data.f64);
+ case TAG_INTEGER:
+ integer_init_uw(&tmp, a->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_add(&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_add(&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_add(&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_add(&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_add(&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_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ case TAG_U8:
+ if (a->data.uw > UW_MAX - b->data.u8) {
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_u8(&tmp2, b->data.u8);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_uw(dest, a->data.uw + (uw) b->data.u8);
+ case TAG_U16:
+ if (a->data.uw > UW_MAX - b->data.u16) {
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_u16(&tmp2, b->data.u16);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_uw(dest, a->data.uw + (uw) b->data.u16);
+ case TAG_U32:
+ if (a->data.uw > UW_MAX - b->data.u32) {
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_u32(&tmp2, b->data.u32);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_uw(dest, a->data.uw + (uw) b->data.u32);
+ case TAG_U64:
+ if (a->data.uw > U64_MAX - b->data.u64) {
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_u64(&tmp2, b->data.u64);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_u64(dest, (u64) a->data.uw + b->data.u64);
+ case TAG_UW:
+ if (a->data.uw > UW_MAX - b->data.uw) {
+ integer_init_uw(&tmp, a->data.uw);
+ integer_init_uw(&tmp2, b->data.uw);
+ dest->type = TAG_INTEGER;
+ integer_add(&tmp, &tmp2, &dest->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return dest;
+ }
+ else
+ return tag_init_uw(dest, a->data.uw + b->data.uw);
+ default:
+ goto ko;
+ }
+ default:
+ goto ko;
+ }
+ ko:
+ errx(1, "cannot add %s to %s",
+ tag_type_to_string(a->type),
+ tag_type_to_string(b->type));
+}
diff --git a/libc3/tag_band.c b/libc3/tag_band.c
new file mode 100644
index 0000000..53275f0
--- /dev/null
+++ b/libc3/tag_band.c
@@ -0,0 +1,479 @@
+/* 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_band (const s_tag *a, const s_tag *b, s_tag *result)
+{
+ s_integer tmp;
+ s_integer tmp2;
+ assert(a);
+ assert(b);
+ assert(result);
+ switch (a->type) {
+ case TAG_INTEGER:
+ switch (b->type) {
+ case TAG_INTEGER:
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &b->data.integer,
+ &result->data.integer);
+ return result;
+ case TAG_SW:
+ integer_init_sw(&tmp, b->data.sw);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S64:
+ integer_init_s64(&tmp, b->data.s64);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S32:
+ integer_init_s32(&tmp, b->data.s32);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S16:
+ integer_init_s16(&tmp, b->data.s16);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S8:
+ integer_init_s8(&tmp, b->data.s8);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U8:
+ integer_init_u8(&tmp, b->data.u8);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U16:
+ integer_init_u16(&tmp, b->data.u16);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U32:
+ integer_init_u32(&tmp, b->data.u32);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U64:
+ integer_init_u64(&tmp, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_UW:
+ integer_init_uw(&tmp, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_band(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_SW:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_band(&tmp, &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_INTEGER:
+ integer_init_s64(&tmp, a->data.s64);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ 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:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S32:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s32(&tmp, a->data.s32);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, a->data.s32 & b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(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_s64(result, a->data.s32 & b->data.u32);
+ case TAG_U64:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S16:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s16(&tmp, a->data.s16);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, a->data.s16 & b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, a->data.s16 & b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(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_s32(result, a->data.s16 & b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(result, a->data.s16 & b->data.u32);
+ case TAG_U64:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S8:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s8(&tmp, a->data.s8);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, a->data.s8 & b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, a->data.s8 & b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, a->data.s8 & b->data.s32);
+ case TAG_S16:
+ return tag_init_s16(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_s16(result, a->data.s8 & b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(result, a->data.s8 & b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(result, a->data.s8 & b->data.u32);
+ case TAG_U64:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_band(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_U8:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, a->data.u8);
+ integer_band(&tmp, &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_INTEGER:
+ integer_init_u16(&tmp, a->data.u16);
+ integer_band(&tmp, &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_INTEGER:
+ integer_init_u32(&tmp, a->data.u32);
+ integer_band(&tmp, &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_INTEGER:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_band(&tmp, &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_INTEGER:
+ integer_init_uw(&tmp, a->data.uw);
+ integer_band(&tmp, &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_band: invalid tag type: %s & %s",
+ tag_type_to_string(a->type),
+ tag_type_to_string(b->type));
+ return NULL;
+}
diff --git a/libc3/tag_bor.c b/libc3/tag_bor.c
new file mode 100644
index 0000000..34ef693
--- /dev/null
+++ b/libc3/tag_bor.c
@@ -0,0 +1,571 @@
+/* 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_bor (const s_tag *a, const s_tag *b, s_tag *result)
+{
+ s_integer tmp;
+ s_integer tmp2;
+ assert(a);
+ assert(b);
+ assert(result);
+ switch (a->type) {
+ case TAG_INTEGER:
+ switch (b->type) {
+ case TAG_INTEGER:
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &b->data.integer,
+ &result->data.integer);
+ return result;
+ case TAG_SW:
+ integer_init_sw(&tmp, b->data.sw);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S64:
+ integer_init_s64(&tmp, b->data.s64);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S32:
+ integer_init_s32(&tmp, b->data.s32);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S16:
+ integer_init_s16(&tmp, b->data.s16);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S8:
+ integer_init_s8(&tmp, b->data.s8);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U8:
+ integer_init_u8(&tmp, b->data.u8);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U16:
+ integer_init_u16(&tmp, b->data.u16);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U32:
+ integer_init_u32(&tmp, b->data.u32);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U64:
+ integer_init_u64(&tmp, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_UW:
+ integer_init_uw(&tmp, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_SW:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_sw(&tmp, a->data.sw);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ 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:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S64:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s64(&tmp, a->data.s64);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ 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:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S32:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s32(&tmp, a->data.s32);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.s32 | b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) 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_s64(result, (s64) a->data.s32 | b->data.u32);
+ case TAG_U64:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S16:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s16(&tmp, a->data.s16);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.s16 | b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.s16 | b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, (s32) 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_s32(result, (s32) a->data.s16 | b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(result, (s64) a->data.s16 | b->data.u32);
+ case TAG_U64:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S8:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s8(&tmp, a->data.s8);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.s8 | b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.s8 | b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, (s32) a->data.s8 | b->data.s32);
+ case TAG_S16:
+ return tag_init_s16(result, (s16) 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_s16(result, (s16) a->data.s8 | b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(result, (s32) a->data.s8 | b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(result, (s64) a->data.s8 | b->data.u32);
+ case TAG_U64:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ 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_u32(result, a->data.u8 | b->data.character);
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, a->data.u8);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.u8 | b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.u8 | b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, (s32) a->data.u8 | b->data.s32);
+ case TAG_S16:
+ return tag_init_s16(result, (s16) a->data.u8 | b->data.s16);
+ case TAG_S8:
+ return tag_init_s16(result, (s16) 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_u16(result, (u16) a->data.u8 | b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(result, (u32) a->data.u8 | b->data.u32);
+ case TAG_U64:
+ return tag_init_u64(result, (u64) a->data.u8 | b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(result, (uw) 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_u32(result, a->data.u16 | b->data.character);
+ case TAG_INTEGER:
+ integer_init_u16(&tmp, a->data.u16);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.u16 | b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.u16 | b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, (s32) a->data.u16 | b->data.s32);
+ case TAG_S16:
+ return tag_init_s32(result, (s32) a->data.u16 | b->data.s16);
+ case TAG_S8:
+ return tag_init_s32(result, (s32) 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, (u16) a->data.u16 | b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(result, (u32) a->data.u16 | b->data.u32);
+ case TAG_U64:
+ return tag_init_u64(result, (u64) a->data.u16 | b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(result, (uw) 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);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_s64(result, (s64) a->data.u32 | b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.u32 | b->data.s64);
+ case TAG_S32:
+ return tag_init_s64(result, (s64) a->data.u32 | b->data.s32);
+ case TAG_S16:
+ return tag_init_s64(result, (s64) a->data.u32 | b->data.s16);
+ case TAG_S8:
+ return tag_init_s64(result, (s64) 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, (u32) a->data.u32 | b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(result, (u32) a->data.u32 | b->data.u32);
+ case TAG_U64:
+ return tag_init_u64(result, (u64) a->data.u32 | b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(result, (uw) 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);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_sw(&tmp2, b->data.sw);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_S64:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s64(&tmp2, b->data.s64);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_S32:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s32(&tmp2, b->data.s32);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_S16:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s16(&tmp2, b->data.s16);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_S8:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s8(&tmp2, b->data.s8);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_U8:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u8(&tmp2, b->data.u8);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_U16:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u16(&tmp2, b->data.u16);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_U32:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u32(&tmp2, b->data.u32);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_U64:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ 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_bor(&tmp, &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_bor: invalid tag type: %s | %s",
+ tag_type_to_string(a->type),
+ tag_type_to_string(b->type));
+ return NULL;
+}
diff --git a/libc3/tag_bxor.c b/libc3/tag_bxor.c
new file mode 100644
index 0000000..0a332f3
--- /dev/null
+++ b/libc3/tag_bxor.c
@@ -0,0 +1,571 @@
+/* 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_bxor (const s_tag *a, const s_tag *b, s_tag *result)
+{
+ s_integer tmp;
+ s_integer tmp2;
+ assert(a);
+ assert(b);
+ assert(result);
+ switch (a->type) {
+ case TAG_INTEGER:
+ switch (b->type) {
+ case TAG_INTEGER:
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &b->data.integer,
+ &result->data.integer);
+ return result;
+ case TAG_SW:
+ integer_init_sw(&tmp, b->data.sw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S64:
+ integer_init_s64(&tmp, b->data.s64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S32:
+ integer_init_s32(&tmp, b->data.s32);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S16:
+ integer_init_s16(&tmp, b->data.s16);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_S8:
+ integer_init_s8(&tmp, b->data.s8);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U8:
+ integer_init_u8(&tmp, b->data.u8);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U16:
+ integer_init_u16(&tmp, b->data.u16);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U32:
+ integer_init_u32(&tmp, b->data.u32);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_U64:
+ integer_init_u64(&tmp, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_UW:
+ integer_init_uw(&tmp, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&a->data.integer, &tmp, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_SW:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_sw(&tmp, a->data.sw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, a->data.sw ^ b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(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_s64(result, a->data.sw ^ b->data.u32);
+ case TAG_U64:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_sw(&tmp, a->data.sw);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S64:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s64(&tmp, a->data.s64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ 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:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s64(&tmp, a->data.s64);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S32:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s32(&tmp, a->data.s32);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.s32 ^ b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) 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_s64(result, (s64) a->data.s32 ^ b->data.u32);
+ case TAG_U64:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s32(&tmp, a->data.s32);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S16:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s16(&tmp, a->data.s16);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.s16 ^ b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.s16 ^ b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, (s32) 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_s32(result, (s32) a->data.s16 ^ b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(result, (s64) a->data.s16 ^ b->data.u32);
+ case TAG_U64:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s16(&tmp, a->data.s16);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ default:
+ goto error;
+ }
+ goto error;
+ case TAG_S8:
+ switch (b->type) {
+ case TAG_INTEGER:
+ integer_init_s8(&tmp, a->data.s8);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.s8 ^ b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.s8 ^ b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, (s32) a->data.s8 ^ b->data.s32);
+ case TAG_S16:
+ return tag_init_s16(result, (s16) 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_s16(result, (s16) a->data.s8 ^ b->data.u8);
+ case TAG_U16:
+ return tag_init_s32(result, (s32) a->data.s8 ^ b->data.u16);
+ case TAG_U32:
+ return tag_init_s64(result, (s64) a->data.s8 ^ b->data.u32);
+ case TAG_U64:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_s8(&tmp, a->data.s8);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ 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_u32(result, a->data.u8 ^ b->data.character);
+ case TAG_INTEGER:
+ integer_init_u8(&tmp, a->data.u8);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.u8 ^ b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.u8 ^ b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, (s32) a->data.u8 ^ b->data.s32);
+ case TAG_S16:
+ return tag_init_s16(result, (s16) a->data.u8 ^ b->data.s16);
+ case TAG_S8:
+ return tag_init_s16(result, (s16) 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_u16(result, (u16) a->data.u8 ^ b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(result, (u32) a->data.u8 ^ b->data.u32);
+ case TAG_U64:
+ return tag_init_u64(result, (u64) a->data.u8 ^ b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(result, (uw) 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_u32(result, a->data.u16 ^ b->data.character);
+ case TAG_INTEGER:
+ integer_init_u16(&tmp, a->data.u16);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_sw(result, (sw) a->data.u16 ^ b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.u16 ^ b->data.s64);
+ case TAG_S32:
+ return tag_init_s32(result, (s32) a->data.u16 ^ b->data.s32);
+ case TAG_S16:
+ return tag_init_s32(result, (s32) a->data.u16 ^ b->data.s16);
+ case TAG_S8:
+ return tag_init_s32(result, (s32) 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, (u16) a->data.u16 ^ b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(result, (u32) a->data.u16 ^ b->data.u32);
+ case TAG_U64:
+ return tag_init_u64(result, (u64) a->data.u16 ^ b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(result, (uw) 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);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ return tag_init_s64(result, (s64) a->data.u32 ^ b->data.sw);
+ case TAG_S64:
+ return tag_init_s64(result, (s64) a->data.u32 ^ b->data.s64);
+ case TAG_S32:
+ return tag_init_s64(result, (s64) a->data.u32 ^ b->data.s32);
+ case TAG_S16:
+ return tag_init_s64(result, (s64) a->data.u32 ^ b->data.s16);
+ case TAG_S8:
+ return tag_init_s64(result, (s64) 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, (u32) a->data.u32 ^ b->data.u16);
+ case TAG_U32:
+ return tag_init_u32(result, (u32) a->data.u32 ^ b->data.u32);
+ case TAG_U64:
+ return tag_init_u64(result, (u64) a->data.u32 ^ b->data.u64);
+ case TAG_UW:
+ return tag_init_uw(result, (uw) 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);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &b->data.integer, &result->data.integer);
+ integer_clean(&tmp);
+ return result;
+ case TAG_SW:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_sw(&tmp2, b->data.sw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_S64:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s64(&tmp2, b->data.s64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_S32:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s32(&tmp2, b->data.s32);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_S16:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s16(&tmp2, b->data.s16);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_S8:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_s8(&tmp2, b->data.s8);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_U8:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u8(&tmp2, b->data.u8);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_U16:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u16(&tmp2, b->data.u16);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_U32:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u32(&tmp2, b->data.u32);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_U64:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_u64(&tmp2, b->data.u64);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ case TAG_UW:
+ integer_init_u64(&tmp, a->data.u64);
+ integer_init_uw(&tmp2, b->data.uw);
+ result->type = TAG_INTEGER;
+ integer_bxor(&tmp, &tmp2, &result->data.integer);
+ integer_clean(&tmp);
+ integer_clean(&tmp2);
+ return result;
+ 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_bxor(&tmp, &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_bxor: invalid tag type: %s ^ %s",
+ tag_type_to_string(a->type),
+ tag_type_to_string(b->type));
+ return NULL;
+}
diff --git a/libc3/tuple.c b/libc3/tuple.c
index b76715e..9b15354 100644
--- a/libc3/tuple.c
+++ b/libc3/tuple.c
@@ -28,19 +28,6 @@ void tuple_clean (s_tuple *tuple)
free(tuple->tag);
}
-s_tuple * tuple_copy (const s_tuple *src, s_tuple *dest)
-{
- uw i = 0;
- assert(src);
- assert(dest);
- tuple_init(dest, src->count);
- while (i < src->count) {
- tag_copy(src->tag + i, dest->tag + i);
- i++;
- }
- return dest;
-}
-
void tuple_delete (s_tuple *tuple)
{
tuple_clean(tuple);
@@ -77,6 +64,19 @@ s_tuple * tuple_init_1 (s_tuple *tuple, const s8 *p)
return tuple;
}
+s_tuple * tuple_init_copy (s_tuple *tuple, const s_tuple *src)
+{
+ uw i = 0;
+ assert(src);
+ assert(tuple);
+ tuple_init(tuple, src->count);
+ while (i < src->count) {
+ tag_init_copy(tuple->tag + i, src->tag + i);
+ i++;
+ }
+ return tuple;
+}
+
s_str * tuple_inspect (const s_tuple *x, s_str *dest)
{
s_buf buf;
diff --git a/libc3/tuple.h b/libc3/tuple.h
index 1ea1b67..8f85878 100644
--- a/libc3/tuple.h
+++ b/libc3/tuple.h
@@ -25,6 +25,7 @@
/* Stack allocation compatible functions */
s_tuple * tuple_init (s_tuple *tuple, uw count);
s_tuple * tuple_init_1 (s_tuple *tuple, const s8 *p);
+s_tuple * tuple_init_copy (s_tuple *tuple, const s_tuple *src);
void tuple_clean (s_tuple *tuple);
/* Constructors, call tuple_delete after use */
@@ -38,7 +39,6 @@ void tuple_delete (s_tuple *tuple);
s_tuple * tuple_1 (s_tuple *tuple, const s8 *p);
/* Observers */
-s_tuple * tuple_copy (const s_tuple *src, s_tuple *dest);
s_list * tuple_to_list (const s_tuple *tuple, s_list **list);
/* Call str_delete after use. */
diff --git a/libc3/types.h b/libc3/types.h
index e5b12c0..3a11620 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -180,7 +180,7 @@ typedef u64 t_skiplist_height;
typedef sw (* f_buf_inspect) (s_buf *buf, const void *x);
typedef sw (* f_buf_inspect_size) (const void *x);
typedef sw (* f_buf_parse) (s_buf *buf, void *dest);
-typedef void * (* f_copy) (const void *a, void *b);
+typedef void * (* f_init_copy) (void *x, const void *src);
typedef bool (* f_sequence_load) (s_sequence *seq, void *window);
typedef bool (* f_sequence_render) (s_sequence *seq, void *window,
void *context);
diff --git a/libc3/u.c.in b/libc3/u.c.in
index 628d87e..5c0388a 100644
--- a/libc3/u.c.in
+++ b/libc3/u.c.in
@@ -98,7 +98,7 @@ u_bits$ * u_bits$_cast (s_tag *tag, u_bits$ *dest)
return 0;
}
-u_bits$ * u_bits$_copy (const u_bits$ *src, u_bits$ *dest)
+u_bits$ * u_bits$_init_copy (u_bits$ *dest, const u_bits$ *src)
{
assert(src);
assert(dest);
diff --git a/libc3/u.h.in b/libc3/u.h.in
index 9accd57..e8d7808 100644
--- a/libc3/u.h.in
+++ b/libc3/u.h.in
@@ -17,6 +17,6 @@
#include "types.h"
u_bits$ * u_bits$_cast (s_tag *tag, u_bits$ *dest);
-u_bits$ * u_bits$_copy (const u_bits$ *src, u_bits$ *dest);
+u_bits$ * u_bits$_init_copy (u_bits$ *u, const u_bits$ *src);
#endif /* LIBC3_U_BITS$_H */
diff --git a/libc3/u16.c b/libc3/u16.c
index 4c5e8a3..d1986ef 100644
--- a/libc3/u16.c
+++ b/libc3/u16.c
@@ -98,7 +98,7 @@ u16 * u16_cast (s_tag *tag, u16 *dest)
return 0;
}
-u16 * u16_copy (const u16 *src, u16 *dest)
+u16 * u16_init_copy (u16 *dest, const u16 *src)
{
assert(src);
assert(dest);
diff --git a/libc3/u16.h b/libc3/u16.h
index 6310e3c..f3c3038 100644
--- a/libc3/u16.h
+++ b/libc3/u16.h
@@ -17,6 +17,6 @@
#include "types.h"
u16 * u16_cast (s_tag *tag, u16 *dest);
-u16 * u16_copy (const u16 *src, u16 *dest);
+u16 * u16_init_copy (u16 *u, const u16 *src);
#endif /* LIBC3_U16_H */
diff --git a/libc3/u32.c b/libc3/u32.c
index 4b2cd8a..486b351 100644
--- a/libc3/u32.c
+++ b/libc3/u32.c
@@ -98,7 +98,7 @@ u32 * u32_cast (s_tag *tag, u32 *dest)
return 0;
}
-u32 * u32_copy (const u32 *src, u32 *dest)
+u32 * u32_init_copy (u32 *dest, const u32 *src)
{
assert(src);
assert(dest);
diff --git a/libc3/u32.h b/libc3/u32.h
index 5b4de99..1229100 100644
--- a/libc3/u32.h
+++ b/libc3/u32.h
@@ -17,6 +17,6 @@
#include "types.h"
u32 * u32_cast (s_tag *tag, u32 *dest);
-u32 * u32_copy (const u32 *src, u32 *dest);
+u32 * u32_init_copy (u32 *u, const u32 *src);
#endif /* LIBC3_U32_H */
diff --git a/libc3/u64.c b/libc3/u64.c
index f4fbb8a..ffe871f 100644
--- a/libc3/u64.c
+++ b/libc3/u64.c
@@ -98,7 +98,7 @@ u64 * u64_cast (s_tag *tag, u64 *dest)
return 0;
}
-u64 * u64_copy (const u64 *src, u64 *dest)
+u64 * u64_init_copy (u64 *dest, const u64 *src)
{
assert(src);
assert(dest);
diff --git a/libc3/u64.h b/libc3/u64.h
index eea1b57..ee8772e 100644
--- a/libc3/u64.h
+++ b/libc3/u64.h
@@ -17,6 +17,6 @@
#include "types.h"
u64 * u64_cast (s_tag *tag, u64 *dest);
-u64 * u64_copy (const u64 *src, u64 *dest);
+u64 * u64_init_copy (u64 *u, const u64 *src);
#endif /* LIBC3_U64_H */
diff --git a/libc3/u8.c b/libc3/u8.c
index 032f337..afd4ca9 100644
--- a/libc3/u8.c
+++ b/libc3/u8.c
@@ -98,7 +98,7 @@ u8 * u8_cast (s_tag *tag, u8 *dest)
return 0;
}
-u8 * u8_copy (const u8 *src, u8 *dest)
+u8 * u8_init_copy (u8 *dest, const u8 *src)
{
assert(src);
assert(dest);
diff --git a/libc3/u8.h b/libc3/u8.h
index 0e85f4f..05c2ae4 100644
--- a/libc3/u8.h
+++ b/libc3/u8.h
@@ -17,6 +17,6 @@
#include "types.h"
u8 * u8_cast (s_tag *tag, u8 *dest);
-u8 * u8_copy (const u8 *src, u8 *dest);
+u8 * u8_init_copy (u8 *u, const u8 *src);
#endif /* LIBC3_U8_H */
diff --git a/libc3/uw.c b/libc3/uw.c
index 4da7755..8c4626f 100644
--- a/libc3/uw.c
+++ b/libc3/uw.c
@@ -98,7 +98,7 @@ uw * uw_cast (s_tag *tag, uw *dest)
return 0;
}
-uw * uw_copy (const uw *src, uw *dest)
+uw * uw_init_copy (uw *dest, const uw *src)
{
assert(src);
assert(dest);
diff --git a/libc3/uw.h b/libc3/uw.h
index bfa925c..20e4b54 100644
--- a/libc3/uw.h
+++ b/libc3/uw.h
@@ -17,6 +17,6 @@
#include "types.h"
uw * uw_cast (s_tag *tag, uw *dest);
-uw * uw_copy (const uw *src, uw *dest);
+uw * uw_init_copy (uw *u, const uw *src);
#endif /* LIBC3_UW_H */
diff --git a/libc3/var.c b/libc3/var.c
index e1834e4..69b8ea8 100644
--- a/libc3/var.c
+++ b/libc3/var.c
@@ -15,11 +15,12 @@
#include "tag.h"
#include "var.h"
-s_tag * var_copy (const s_tag *src, s_tag *dest)
+s_tag * var_init_copy (s_tag *dest, const s_tag *src)
{
assert(src);
assert(dest);
(void) src;
+ /* ?? */
tag_init_void(dest);
return dest;
}
diff --git a/libc3/var.h b/libc3/var.h
index 30cc69a..b2f759f 100644
--- a/libc3/var.h
+++ b/libc3/var.h
@@ -15,6 +15,6 @@
#include "types.h"
-s_tag * var_copy (const s_tag *src, s_tag *dest);
+s_tag * var_init_copy (s_tag *var, const s_tag *src);
#endif /* LIBC3_VAR_H */
diff --git a/libc3/window/cairo/cairo_sprite.c b/libc3/window/cairo/cairo_sprite.c
index 331086e..079fc9a 100644
--- a/libc3/window/cairo/cairo_sprite.c
+++ b/libc3/window/cairo/cairo_sprite.c
@@ -40,10 +40,10 @@ s_cairo_sprite * cairo_sprite_init (s_cairo_sprite *sprite,
uw frame_count)
{
assert(sprite);
- assert(surface);
assert(dim_x);
assert(dim_y);
- sprite->surface = surface;
+ if (! (sprite->surface = surface))
+ return NULL;
sprite->surface_w = cairo_image_surface_get_width(surface);
sprite->surface_h = cairo_image_surface_get_height(surface);
sprite->dim_x = dim_x;
diff --git a/libc3/window/cairo/demo/toasters.c b/libc3/window/cairo/demo/toasters.c
index 78284dc..f7f908b 100644
--- a/libc3/window/cairo/demo/toasters.c
+++ b/libc3/window/cairo/demo/toasters.c
@@ -67,7 +67,9 @@ bool toasters_load (s_sequence *seq,
tag_clean(&seq->tag);
tag_init_list(&seq->tag, NULL);
while (y < window->h - window->w * g_speed_y / g_speed_x) {
- tag_init_list(&seq->tag, list_new_f64(y, seq->tag.data.list));
+ tag_init_list(&seq->tag,
+ list_new_list(list_new_f64(y, NULL),
+ seq->tag.data.list));
y += 100.0;
}
return true;
@@ -96,10 +98,10 @@ bool toasters_render (s_sequence *seq, s_window_cairo *window,
first = list_next(j);
x = 1000.0;
if (first && first->tag.type == TAG_MAP)
- x = j->tag.data.map.values[2].data.f64;
- if (x > 100) {
- i->tag.data.list = list_new(i->tag.data.list);
- toaster_init(&i->tag.data.list->tag, y);
+ x = first->tag.data.map.values[2].data.f64;
+ if (x > 100.0) {
+ first = j->next.data.list = list_new(j->next.data.list);
+ toaster_init(&first->tag, y);
}
j = list_next(j);
while (j) {
diff --git a/libc3/window/cairo/demo/window_cairo_demo.c b/libc3/window/cairo/demo/window_cairo_demo.c
index 7a3b181..9cc904a 100644
--- a/libc3/window/cairo/demo/window_cairo_demo.c
+++ b/libc3/window/cairo/demo/window_cairo_demo.c
@@ -19,6 +19,7 @@
#include "../../window.h"
#include "../window_cairo.h"
#include "../cairo_png.h"
+#include "../cairo_sprite.h"
#include "window_cairo_demo.h"
#include "bg_rect.h"
#include "lightspeed.h"
@@ -78,8 +79,12 @@ bool window_cairo_demo_load (s_window_cairo *window)
window_cairo_sequence_init(window->sequence + 1, 30.0,
"02. Lightspeed",
lightspeed_load, lightspeed_render);
- g_toaster_sprite.surface = cairo_png_1("img/flaps.png");
- g_toast_sprite.surface = cairo_png_1("img/toast.png");
+ if (! cairo_sprite_init(&g_toaster_sprite,
+ cairo_png_1("img/flaps.png"), 4, 1, 4))
+ return false;
+ if (! cairo_sprite_init(&g_toast_sprite, cairo_png_1("img/toast.png"),
+ 1, 1, 1))
+ return false;
window_cairo_sequence_init(window->sequence + 2, 30.0,
"03. Toasters",
toasters_load, toasters_render);
diff --git a/libc3/window/cairo/quartz/demo/Makefile b/libc3/window/cairo/quartz/demo/Makefile
index d1cd6fb..13864b7 100644
--- a/libc3/window/cairo/quartz/demo/Makefile
+++ b/libc3/window/cairo/quartz/demo/Makefile
@@ -19,10 +19,15 @@ CLEANFILES += ${CLEANFILES_COV}
DISTCLEANFILES = ${CLEANFILES} config.mk
+IMG_SOURCES = \
+ ../../../../../img/flaps.png \
+ ../../../../../img/toast.png \
+
build:
${MAKE} ${APP_PROG}
${MAKE} ${APP}/Contents/Frameworks
rsync -aP --delete ../../../../../lib ${APP}/Contents/
+ rsync -aP ${IMG_SOURCES} ${APP}/Contents/img/
all:
${MAKE} build
@@ -34,6 +39,7 @@ asan:
${MAKE} ${APP_PROG_ASAN}
${MAKE} ${APP_ASAN}/Contents/Frameworks
rsync -aP --delete ../../../../../lib ${APP_ASAN}/Contents/
+ rsync -aP ${IMG_SOURCES} ${APP_ASAN}/Contents/img/
clean:
rm -rf ${CLEANFILES}
@@ -45,11 +51,13 @@ cov:
${MAKE} ${APP_PROG_COV}
${MAKE} ${APP_COV}/Contents/Frameworks
rsync -aP --delete ../../../../../lib ${APP_COV}/Contents/
+ rsync -aP ${IMG_SOURCES} ${APP_COV}/Contents/img/
debug:
${MAKE} ${APP_PROG_DEBUG}
${MAKE} ${APP_DEBUG}/Contents/Frameworks
rsync -aP --delete ../../../../../lib ${APP_DEBUG}/Contents/
+ rsync -aP ${IMG_SOURCES} ${APP_DEBUG}/Contents/img/
demo: build
time ${APP_PROG}
diff --git a/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
new file mode 100644
index 0000000..cc3c730
Binary files /dev/null and b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/flaps.png differ
diff --git a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/toast.png b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/toast.png
new file mode 100644
index 0000000..021511b
Binary files /dev/null and b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/toast.png differ
diff --git a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/img/flaps.png b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/img/flaps.png
new file mode 100644
index 0000000..cc3c730
Binary files /dev/null and b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/img/flaps.png differ
diff --git a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/img/toast.png b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/img/toast.png
new file mode 100644
index 0000000..021511b
Binary files /dev/null and b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/img/toast.png differ
diff --git a/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m b/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m
index 0314a3f..4b7d923 100644
--- a/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m
+++ b/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m
@@ -53,8 +53,8 @@
[self.window close];
[self.window release];
[[NSApplication sharedApplication] stop:nil];
+ exit(1);
}
-
[NSTimer scheduledTimerWithTimeInterval:0.01
target:self
selector:@selector(redrawWindow)
diff --git a/sources.mk b/sources.mk
index e49343d..7b02b55 100644
--- a/sources.mk
+++ b/sources.mk
@@ -7,24 +7,24 @@ 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/quartz/configure \
- libc3/window/cairo/quartz/update_sources \
+ libc3/window/cairo/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/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 \
- libc3/window/configure \
- libc3/window/update_sources \
libtommath/configure \
libtommath/update_sources \
test/configure \
@@ -35,17 +35,17 @@ C3_MAKEFILES = \
c3c/Makefile \
c3s/Makefile \
ic3/Makefile \
- libc3/gen.mk \
libc3/Makefile \
- libc3/window/cairo/xcb/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/Makefile \
libc3/window/cairo/quartz/demo/Makefile \
- libc3/window/cairo/demo/Makefile \
- libc3/window/cairo/win32/Makefile \
+ libc3/window/cairo/quartz/Makefile \
libc3/window/cairo/win32/demo/Makefile \
- libc3/window/Makefile \
+ libc3/window/cairo/win32/Makefile \
libtommath/Makefile \
test/Makefile \
ucd2c/Makefile \
@@ -55,378 +55,388 @@ C3_C_SOURCES = \
c3s/buf_readline.c \
c3s/c3s.c \
c3s/buf_readline.h \
- ic3/ic3.c \
- ic3/buf_linenoise.c \
ic3/buf_linenoise.h \
+ ic3/ic3.c \
ic3/linenoise.c \
- libc3/abs.c \
- libc3/buf_inspect_s8.c \
- libc3/buf.c \
- libc3/buf_inspect_s8.h \
- libc3/buf_inspect_s8_binary.c \
- libc3/buf_inspect_s8_binary.h \
- libc3/buf_inspect_s8_octal.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_s8_decimal.h \
- libc3/buf_inspect_s8_hexadecimal.c \
- libc3/array.h \
- libc3/buf_inspect_s16.c \
- libc3/call.c \
- libc3/arg.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/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/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/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/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/file.h \
+ libc3/sw.h \
+ libc3/s32.c \
+ libc3/error_handler.c \
+ libc3/str.c \
libc3/buf_parse.h \
- libc3/buf.h \
- libc3/buf_save.c \
+ libc3/buf_inspect_uw_binary.c \
+ libc3/buf_inspect_uw_decimal.h \
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/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_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/buf_parse_s8.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/sign.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.c \
- 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/s8.h \
- libc3/s16.c \
- libc3/s16.h \
- libc3/s32.c \
- libc3/s32.h \
- libc3/facts_with_cursor.h \
- libc3/float.h \
- libc3/frame.c \
- libc3/frame.h \
- libc3/s64.c \
- libc3/s64.h \
- libc3/types.h \
- libc3/sw.c \
- libc3/sw.h \
- libc3/u8.c \
- libc3/u8.h \
- libc3/u16.c \
- libc3/f64.h \
- libc3/u16.h \
+ libc3/buf_inspect_s_base.h.in \
+ libc3/buf_inspect_u32_octal.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/hash.c \
+ libc3/buf_file.h \
libc3/integer.c \
- libc3/integer.h \
- libc3/io.h \
- libc3/list.h \
- libc3/log.c \
- libc3/log.h \
- libc3/buf_inspect_s.h.in \
- libc3/module.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/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_cursor.c.in \
- libc3/set_cursor.h.in \
- libc3/set_item.c.in \
- libc3/set_item.h.in \
- 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/buf_inspect_s32.c \
libc3/skiplist_node.h.in \
- libc3/str.h \
- libc3/tag.h \
- libc3/ucd.c \
- libc3/sym.h \
- libc3/tuple.c \
- libc3/tuple.h \
+ 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/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/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.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/demo/window.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.h \
libc3/window/cairo/window_cairo.c \
- libc3/window/cairo/quartz/window_cairo_quartz.h \
+ 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_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/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/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/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/win32/window_cairo_win32.h \
- libc3/window/types.h \
+ libc3/window/cairo/cairo_sprite.c \
+ libc3/window/cairo/cairo_png.c \
libc3/window/window.c \
- libc3/window/window.h \
- libc3/buf_parse.c \
- libc3/u.c.in \
- libc3/fn.c \
- libc3/u.h.in \
+ 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/c3.h \
- libc3/fn.h \
- libc3/map.h \
- libc3/facts.c \
- libc3/license.c \
- libc3/operator.c \
- libc3/ptag.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/fn_clause.h \
- libc3/s.c.in \
- libc3/operator.h \
- libc3/sym.c \
+ 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/var.h \
- libc3/var.c \
- libc3/time.c \
- libc3/time.h \
- libc3/file.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 \
+ 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_parse_test_s32.c \
- test/buf_parse_test_s64.c \
- test/buf_parse_test_s8.c \
- test/buf_parse_test_su.h \
+ test/buf_inspect_test.c \
+ test/libc3_test.c \
+ test/fn_test.c \
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/str_test.c \
test/cfn_test.c \
test/character_test.c \
- test/env_test.c \
- test/fact_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/compare_test.c \
- test/compare_test.h \
- test/ident_test.c \
- test/set__fact_test.c \
+ test/call_test.c \
test/set__tag_test.c \
- test/skiplist__fact_test.c \
- test/str_test.c \
- test/sym_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/tag_test.h \
- test/array_test.c \
- test/fn_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 \
- test/types_test.c \
- test/libc3_test.c \
ucd2c/ucd.h \
ucd2c/ucd2c.c \
diff --git a/sources.sh b/sources.sh
index 56e4095..05ca4c1 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/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/configure libtommath/update_sources 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_inspect_s8.c libc3/buf.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/buf_inspect_s8_hexadecimal.c libc3/array.h 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/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.c 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/s8.h libc3/s16.c libc3/s16.h libc3/s32.c libc3/s32.h libc3/facts_with_cursor.h libc3/float.h libc3/frame.c libc3/frame.h libc3/s64.c libc3/s64.h libc3/types.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/io.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_cursor.c.in libc3/set_cursor.h.in libc3/set_item.c.in libc3/set_item.h.in 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/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.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/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/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/facts.c libc3/license.c libc3/operator.c libc3/ptag.h libc3/f32.h libc3/fn_clause.h libc3/s.c.in libc3/operator.h libc3/sym.c libc3/fn_clause.c libc3/ptag.c libc3/var.h libc3/var.c libc3/time.c libc3/time.h libc3/file.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/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/str_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 test/libc3_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/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/demo/window.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 '
diff --git a/test/cfn_test.c b/test/cfn_test.c
index 58a29a5..dc9445d 100644
--- a/test/cfn_test.c
+++ b/test/cfn_test.c
@@ -22,8 +22,8 @@ bool cfn_test_not (bool a);
/* 2 */
TEST_CASE_PROTOTYPE(cfn_apply);
-TEST_CASE_PROTOTYPE(cfn_copy);
TEST_CASE_PROTOTYPE(cfn_init_clean);
+TEST_CASE_PROTOTYPE(cfn_init_copy);
TEST_CASE_PROTOTYPE(cfn_link);
TEST_CASE_PROTOTYPE(cfn_prep_cif);
@@ -33,7 +33,7 @@ void cfn_test (void);
void cfn_test (void)
{
TEST_CASE_RUN(cfn_init_clean);
- TEST_CASE_RUN(cfn_copy);
+ TEST_CASE_RUN(cfn_init_copy);
TEST_CASE_RUN(cfn_link);
TEST_CASE_RUN(cfn_prep_cif);
TEST_CASE_RUN(cfn_apply);
@@ -64,7 +64,7 @@ TEST_CASE(cfn_apply)
}
TEST_CASE_END(cfn_apply)
-TEST_CASE(cfn_copy)
+TEST_CASE(cfn_init_copy)
{
s_cfn a;
s_list *a_arg_types;
@@ -73,7 +73,7 @@ TEST_CASE(cfn_copy)
cfn_init(&a, sym_1("cfn_test_not"),
list_1("(:bool)"),
sym_1("bool"));
- TEST_EQ(cfn_copy(&a, &b), &b);
+ TEST_EQ(cfn_init_copy(&b, &a), &b);
TEST_EQ(a.name, b.name);
TEST_EQ(a.ptr.p, b.ptr.p);
TEST_EQ(a.arity, b.arity);
@@ -98,7 +98,7 @@ TEST_CASE(cfn_copy)
cfn_clean(&b);
cfn_clean(&a);
}
-TEST_CASE_END(cfn_copy)
+TEST_CASE_END(cfn_init_copy)
TEST_CASE(cfn_init_clean)
{
diff --git a/test/str_test.c b/test/str_test.c
index b2355bd..630116e 100644
--- a/test/str_test.c
+++ b/test/str_test.c
@@ -66,13 +66,13 @@
TEST_CASE_PROTOTYPE(str_character_is_reserved);
TEST_CASE_PROTOTYPE(str_init_clean);
-TEST_CASE_PROTOTYPE(str_init_dup);
-TEST_CASE_PROTOTYPE(str_init_dup_1);
+TEST_CASE_PROTOTYPE(str_init_copy);
+TEST_CASE_PROTOTYPE(str_init_copy_1);
TEST_CASE_PROTOTYPE(str_inspect);
TEST_CASE_PROTOTYPE(str_new_1);
TEST_CASE_PROTOTYPE(str_new_cpy);
TEST_CASE_PROTOTYPE(str_new_delete);
-TEST_CASE_PROTOTYPE(str_new_dup);
+TEST_CASE_PROTOTYPE(str_new_copy);
TEST_CASE_PROTOTYPE(str_new_f);
TEST_CASE_PROTOTYPE(str_to_hex);
TEST_CASE_PROTOTYPE(str_to_ident);
@@ -82,11 +82,11 @@ TEST_CASE_PROTOTYPE(str_to_sym);
void str_test (void)
{
TEST_CASE_RUN(str_init_clean);
- TEST_CASE_RUN(str_init_dup);
- TEST_CASE_RUN(str_init_dup_1);
+ TEST_CASE_RUN(str_init_copy);
+ TEST_CASE_RUN(str_init_copy_1);
TEST_CASE_RUN(str_new_delete);
TEST_CASE_RUN(str_new_1);
- TEST_CASE_RUN(str_new_dup);
+ TEST_CASE_RUN(str_new_copy);
TEST_CASE_RUN(str_new_cpy);
TEST_CASE_RUN(str_new_f);
TEST_CASE_RUN(str_character_is_reserved);
@@ -157,7 +157,7 @@ TEST_CASE(str_init_clean)
}
TEST_CASE_END(str_init_clean)
-TEST_CASE(str_init_dup)
+TEST_CASE(str_init_copy)
{
size_t len;
char *m;
@@ -165,7 +165,7 @@ TEST_CASE(str_init_dup)
s_str test;
len = 4;
str_init(&test, NULL, len, "test");
- str_init_dup(&str, &test);
+ str_init_copy(&str, &test);
str_clean(&test);
TEST_EQ(str.size, len);
TEST_STRNCMP(str.ptr.p, "test", len);
@@ -175,21 +175,21 @@ TEST_CASE(str_init_dup)
assert(m);
memcpy(m, "test", len);
str_init(&test, m, len, m);
- str_init_dup(&str, &test);
+ str_init_copy(&str, &test);
str_clean(&test);
TEST_EQ(str.size, len);
TEST_STRNCMP(str.ptr.p, "test", len);
str_clean(&str);
}
-TEST_CASE_END(str_init_dup)
+TEST_CASE_END(str_init_copy)
-TEST_CASE(str_init_dup_1)
+TEST_CASE(str_init_copy_1)
{
size_t len;
char *m;
s_str str;
len = 4;
- str_init_dup_1(&str, "test");
+ str_init_copy_1(&str, "test");
TEST_EQ(str.size, len);
TEST_STRNCMP(str.ptr.p, "test", len);
str_clean(&str);
@@ -197,13 +197,13 @@ TEST_CASE(str_init_dup_1)
m = malloc(len + 1);
assert(m);
memcpy(m, "test", len + 1);
- str_init_dup_1(&str, m);
+ str_init_copy_1(&str, m);
free(m);
TEST_EQ(str.size, len);
TEST_STRNCMP(str.ptr.p, "test", len);
str_clean(&str);
}
-TEST_CASE_END(str_init_dup_1)
+TEST_CASE_END(str_init_copy_1)
TEST_CASE(str_inspect)
{
@@ -287,7 +287,7 @@ TEST_CASE_END(str_new_1)
TEST_CASE(str_new_cpy)
{
s_str *str;
- TEST_ASSERT((str = str_new_cpy(4, "test")));
+ TEST_ASSERT((str = str_new_cpy("test", 4)));
str_delete(str);
}
TEST_CASE_END(str_new_cpy)
@@ -312,7 +312,7 @@ TEST_CASE(str_new_delete)
}
TEST_CASE_END(str_new_delete)
-TEST_CASE(str_new_dup)
+TEST_CASE(str_new_copy)
{
size_t len;
char *m;
@@ -320,7 +320,7 @@ TEST_CASE(str_new_dup)
s_str test;
len = 4;
str_init(&test, NULL, len, "test");
- TEST_ASSERT((str = str_new_dup(&test)));
+ TEST_ASSERT((str = str_new_copy(&test)));
str_clean(&test);
TEST_EQ(str->size, len);
TEST_STRNCMP(str->ptr.p, "test", len);
@@ -329,13 +329,13 @@ TEST_CASE(str_new_dup)
m = malloc(len);
memcpy(m, "test", len);
str_init(&test, m, len, m);
- TEST_ASSERT((str = str_new_dup(&test)));
+ TEST_ASSERT((str = str_new_copy(&test)));
str_clean(&test);
TEST_EQ(str->size, len);
TEST_STRNCMP(str->ptr.p, "test", len);
str_delete(str);
}
-TEST_CASE_END(str_new_dup)
+TEST_CASE_END(str_new_copy)
TEST_CASE(str_new_f)
{