diff --git a/libc3/hash.c b/libc3/hash.c
index 7fa665c..29102b0 100644
--- a/libc3/hash.c
+++ b/libc3/hash.c
@@ -22,13 +22,13 @@
#include "void.h"
#define HASH_UPDATE_DEF(type) \
- void hash_update_##type (t_hash *hash, const type *x) \
+ bool hash_update_##type (t_hash *hash, const type *x) \
{ \
const s8 t[] = #type; \
assert(hash); \
assert(x); \
- hash_update(hash, t, sizeof(t)); \
- hash_update(hash, x, sizeof(type)); \
+ return hash_update(hash, t, sizeof(t)) && \
+ hash_update(hash, x, sizeof(type)); \
}
void hash_clean (t_hash *hash)
@@ -56,79 +56,86 @@ u64 hash_to_u64 (t_hash *hash)
return *((u64 *) digest);
}
-void hash_update (t_hash *hash, const void *data, uw size)
+bool hash_update (t_hash *hash, const void *data, uw size)
{
assert(hash);
assert(data);
SHA1Update(hash, data, size);
+ return true;
}
-void hash_update_1 (t_hash *hash, const s8 *p)
+bool hash_update_1 (t_hash *hash, const s8 *p)
{
uw len;
const s8 type[] = "s8*";
assert(hash);
assert(p);
- hash_update(hash, type, sizeof(type));
len = strlen(p);
- hash_update(hash, &len, sizeof(len));
- hash_update(hash, p, strlen(p));
+ return hash_update(hash, type, sizeof(type)) &&
+ hash_update(hash, &len, sizeof(len)) &&
+ hash_update(hash, p, strlen(p));
}
-void hash_update_array (t_hash *hash, const s_array *a)
+bool hash_update_array (t_hash *hash, const s_array *a)
{
uw i = 0;
const s8 type[] = "array";
assert(hash);
assert(a);
- hash_update(hash, type, sizeof(type));
- hash_update(hash, &a->dimension, sizeof(a->dimension));
- hash_update(hash, &a->type, sizeof(a->type));
+ if (! hash_update(hash, type, sizeof(type)) ||
+ ! hash_update(hash, &a->dimension, sizeof(a->dimension)) ||
+ ! hash_update(hash, &a->type, sizeof(a->type)))
+ return false;
while (i < a->dimension) {
- hash_update(hash, &a->dimensions[i].count,
- sizeof(a->dimensions[i].count));
+ if (! hash_update(hash, &a->dimensions[i].count,
+ sizeof(a->dimensions[i].count)))
+ return false;
i++;
}
- if (a->data)
- hash_update(hash, a->data, a->size);
+ if (a->data) {
+ if (! hash_update(hash, a->data, a->size))
+ return false;
+ }
else if (a->tags) {
i = 0;
while (i < a->count) {
- hash_update_tag(hash, a->tags + i);
+ if (! hash_update_tag(hash, a->tags + i))
+ return false;
i++;
}
}
+ return true;
}
-void hash_update_bool (t_hash *hash, const bool *x)
+bool hash_update_bool (t_hash *hash, const bool *x)
{
bool b;
const s8 type[] = "bool";
assert(hash);
assert(x);
- hash_update(hash, type, sizeof(type));
b = x ? 1 : 0;
- hash_update(hash, &b, sizeof(b));
+ return hash_update(hash, type, sizeof(type)) &&
+ hash_update(hash, &b, sizeof(b));
}
-void hash_update_call (t_hash *hash, const s_call *call)
+bool hash_update_call (t_hash *hash, const s_call *call)
{
const s8 type[] = "call";
assert(hash);
assert(call);
- hash_update(hash, type, sizeof(type));
- hash_update_ident(hash, &call->ident);
- hash_update_list(hash, (const s_list * const *) &call->arguments);
+ return hash_update(hash, type, sizeof(type)) &&
+ hash_update_ident(hash, &call->ident) &&
+ hash_update_list(hash, (const s_list * const *) &call->arguments);
}
-void hash_update_cfn (t_hash *hash, const s_cfn *cfn)
+bool hash_update_cfn (t_hash *hash, const s_cfn *cfn)
{
const s8 type[] = "cfn";
assert(hash);
assert(cfn);
- hash_update(hash, type, sizeof(type));
- hash_update_sym(hash, &cfn->name);
- hash_update_list(hash, (const s_list * const *) &cfn->arg_types);
+ return hash_update(hash, type, sizeof(type)) &&
+ hash_update_sym(hash, &cfn->name) &&
+ hash_update_list(hash, (const s_list * const *) &cfn->arg_types);
}
HASH_UPDATE_DEF(character)
@@ -137,7 +144,7 @@ HASH_UPDATE_DEF(f32)
HASH_UPDATE_DEF(f64)
-void hash_update_fact (t_hash *hash, const s_fact *fact)
+bool hash_update_fact (t_hash *hash, const s_fact *fact)
{
const s8 type[] = "fact";
assert(hash);
@@ -145,58 +152,67 @@ void hash_update_fact (t_hash *hash, const s_fact *fact)
assert(fact->subject);
assert(fact->predicate);
assert(fact->object);
- hash_update(hash, type, sizeof(type));
- hash_update_tag(hash, fact->subject);
- hash_update_tag(hash, fact->predicate);
- hash_update_tag(hash, fact->object);
+ return hash_update(hash, type, sizeof(type)) &&
+ hash_update_tag(hash, fact->subject) &&
+ hash_update_tag(hash, fact->predicate) &&
+ hash_update_tag(hash, fact->object);
}
-void hash_update_fn (t_hash *hash, const s_fn *fn)
+bool hash_update_fn (t_hash *hash, const s_fn *fn)
{
const s8 type[] = "fn";
assert(hash);
assert(fn);
- hash_update(hash, type, sizeof(type));
- hash_update_bool(hash, &fn->macro);
- hash_update_bool(hash, &fn->special_operator);
- hash_update_fn_clauses(hash, fn->clauses);
+ return hash_update(hash, type, sizeof(type)) &&
+ hash_update_bool(hash, &fn->macro) &&
+ hash_update_bool(hash, &fn->special_operator) &&
+ hash_update_fn_clauses(hash, fn->clauses);
}
-void hash_update_fn_clauses (t_hash *hash, const s_fn_clause *clauses)
+bool hash_update_fn_clauses (t_hash *hash, const s_fn_clause *clauses)
{
uw count = 0;
const s_fn_clause *f;
const s8 type[] = "fn_clauses";
assert(hash);
assert(clauses);
- hash_update(hash, type, sizeof(type));
+ if (! hash_update(hash, type, sizeof(type)))
+ return false;
f = clauses;
while (f) {
count++;
f = f->next_clause;
}
- hash_update_uw(hash, &count);
+ if (! hash_update_uw(hash, &count))
+ return false;
f = clauses;
while (f) {
- hash_update_list(hash, (const s_list * const *) &f->pattern);
- hash_update_list(hash, (const s_list * const *) &f->algo);
+ if (! hash_update_list(hash, (const s_list * const *)
+ &f->pattern) ||
+ ! hash_update_list(hash, (const s_list * const *)
+ &f->algo))
+ return false;
f = f->next_clause;
}
+ return true;
}
-void hash_update_ident (t_hash *hash, const s_ident *ident)
+bool hash_update_ident (t_hash *hash, const s_ident *ident)
{
+ const s8 type[] = "ident";
assert(hash);
assert(ident);
- hash_update_s8(hash, "_");
+ if (! hash_update(hash, type, sizeof(type)))
+ return false;
if (ident->module) {
- hash_update_sym(hash, &ident->module);
- hash_update_s8(hash, ".");
+ if (! hash_update_sym(hash, &ident->module) ||
+ ! hash_update_s8(hash, "."))
+ return false;
}
- hash_update_sym(hash, &ident->sym);
+ return hash_update_sym(hash, &ident->sym);
}
-void hash_update_integer (t_hash *hash, const s_integer *i)
+bool hash_update_integer (t_hash *hash, const s_integer *i)
{
int j = 0;
mp_digit *digit;
@@ -204,17 +220,20 @@ void hash_update_integer (t_hash *hash, const s_integer *i)
assert(hash);
assert(i);
digit = i->mp_int.dp;
- hash_update(hash, type, 7);
- hash_update(hash, &i->mp_int.used, sizeof(i->mp_int.used));
+ if (! hash_update(hash, type, sizeof(type)) ||
+ ! hash_update(hash, &i->mp_int.used, sizeof(i->mp_int.used)))
+ return false;
while (j < i->mp_int.used) {
- hash_update(hash, digit, sizeof(*digit));
+ if (! hash_update(hash, digit, sizeof(*digit)))
+ return false;
digit++;
j++;
}
+ return true;
}
/* FIXME: circular lists */
-void hash_update_list (t_hash *hash, const s_list * const *list)
+bool hash_update_list (t_hash *hash, const s_list * const *list)
{
uw count;
const s_list *l;
@@ -223,62 +242,73 @@ void hash_update_list (t_hash *hash, const s_list * const *list)
assert(hash);
assert(list);
l = *list;
- hash_update(hash, type, sizeof(type));
count = list_length(l);
- hash_update_uw(hash, &count);
+ if (! hash_update(hash, type, sizeof(type)) ||
+ ! hash_update_uw(hash, &count))
+ return false;
if (l) {
while (l) {
- hash_update_tag(hash, &l->tag);
+ if (! hash_update_tag(hash, &l->tag))
+ return false;
last = l;
l = list_next(l);
}
- hash_update_tag(hash, &last->next);
+ if (! hash_update_tag(hash, &last->next))
+ return false;
}
+ return true;
}
-void hash_update_map (t_hash *hash, const s_map *map)
+bool hash_update_map (t_hash *hash, const s_map *map)
{
uw i = 0;
const s8 type[] = "map";
assert(hash);
assert(map);
- hash_update(hash, type, strlen(type));
- hash_update(hash, &map->count, sizeof(map->count));
+ if (! hash_update(hash, type, strlen(type)) ||
+ ! hash_update(hash, &map->count, sizeof(map->count)))
+ return false;
while (i < map->count) {
- hash_update_tag(hash, map->key + i);
- hash_update_tag(hash, map->value + i);
+ if (! hash_update_tag(hash, map->key + i) ||
+ ! hash_update_tag(hash, map->value + i))
+ return false;
i++;
}
+ return true;
}
-void hash_update_ptag (t_hash *hash, const p_tag *ptag)
+bool hash_update_ptag (t_hash *hash, const p_tag *ptag)
{
const s8 type[] = "ptag";
assert(hash);
assert(ptag);
- hash_update(hash, type, sizeof(type));
- hash_update(hash, ptag, sizeof(ptag));
+ if (! hash_update(hash, type, sizeof(type)))
+ return false;
+ return hash_update(hash, ptag, sizeof(ptag));
}
-void hash_update_ptr (t_hash *hash, const u_ptr_w *ptr)
+bool hash_update_ptr (t_hash *hash, const u_ptr_w *ptr)
{
const s8 type[] = "ptr";
- hash_update(hash, type, strlen(type));
- hash_update(hash, &ptr->p, sizeof(void *));
+ if (! hash_update(hash, type, strlen(type)))
+ return false;
+ return hash_update(hash, &ptr->p, sizeof(void *));
}
-void hash_update_ptr_free (t_hash *hash, const u_ptr_w *ptr_free)
+bool hash_update_ptr_free (t_hash *hash, const u_ptr_w *ptr_free)
{
const s8 type[] = "ptr_free";
- hash_update(hash, type, strlen(type));
- hash_update(hash, &ptr_free->p, sizeof(void *));
+ if (! hash_update(hash, type, strlen(type)))
+ return false;
+ return hash_update(hash, &ptr_free->p, sizeof(void *));
}
-void hash_update_quote (t_hash *hash, const s_quote *x)
+bool hash_update_quote (t_hash *hash, const s_quote *x)
{
const s8 type[] = "quote";
- hash_update(hash, type, strlen(type));
- hash_update_tag(hash, x->tag);
+ if (! hash_update(hash, type, strlen(type)))
+ return false;
+ return hash_update_tag(hash, x->tag);
}
HASH_UPDATE_DEF(s8)
@@ -291,17 +321,17 @@ HASH_UPDATE_DEF(s64)
HASH_UPDATE_DEF(sw)
-void hash_update_str (t_hash *hash, const s_str *str)
+bool hash_update_str (t_hash *hash, const s_str *str)
{
s8 type[] = "str";
assert(hash);
assert(str);
- hash_update(hash, type, strlen(type));
- hash_update(hash, &str->size, sizeof(str->size));
- hash_update(hash, str->ptr.p, str->size);
+ return hash_update(hash, type, strlen(type)) &&
+ hash_update(hash, &str->size, sizeof(str->size)) &&
+ hash_update(hash, str->ptr.p, str->size);
}
-void hash_update_struct (t_hash *hash, const s_struct *s)
+bool hash_update_struct (t_hash *hash, const s_struct *s)
{
const void *data;
uw i = 0;
@@ -309,99 +339,113 @@ void hash_update_struct (t_hash *hash, const s_struct *s)
s8 type[] = "struct";
assert(hash);
assert(s);
- hash_update(hash, type, sizeof(type));
- hash_update_sym(hash, &s->type.module);
- hash_update(hash, &s->type.map.count, sizeof(s->type.map.count));
+ if (! hash_update(hash, type, sizeof(type)) ||
+ ! hash_update_sym(hash, &s->type.module) ||
+ ! hash_update(hash, &s->type.map.count,
+ sizeof(s->type.map.count)))
+ return false;
while (i < s->type.map.count) {
- hash_update_tag(hash, s->type.map.key + i);
+ if (! hash_update_tag(hash, s->type.map.key + i))
+ return false;
if (! tag_type(s->type.map.value + i, &sym))
- exit(1);
+ return false;
if (s->data)
data = (s8 *) s->data + s->type.offset[i];
else {
if (s->tag) {
if (! tag_to_const_pointer(s->tag + i, sym, &data))
- exit(1);
+ return false;
}
else {
if (! tag_to_const_pointer(s->type.map.value + i, sym, &data))
- exit(1);
+ return false;
}
}
- void_hash_update(sym, hash, data);
+ if (! void_hash_update(sym, hash, data))
+ return false;
i++;
}
+ return true;
}
-void hash_update_sym (t_hash *hash, const s_sym * const *sym)
+bool hash_update_sym (t_hash *hash, const s_sym * const *sym)
{
s8 type[] = "sym";
assert(hash);
assert(sym);
- hash_update(hash, type, sizeof(type));
- hash_update_str(hash, &(*sym)->str);
+ return hash_update(hash, type, sizeof(type)) &&
+ hash_update_str(hash, &(*sym)->str);
}
-void hash_update_tag (t_hash *hash, const s_tag *tag)
+bool hash_update_tag (t_hash *hash, const s_tag *tag)
{
u8 tag_type;
s8 type[] = "tag";
assert(hash);
assert(tag);
- hash_update(hash, type, strlen(type));
+ if (! hash_update(hash, type, strlen(type)))
+ return false;
tag_type = tag->type;
- hash_update_u8(hash, &tag_type);
+ if (! hash_update_u8(hash, &tag_type))
+ return false;
switch (tag->type) {
- case TAG_ARRAY: hash_update_array(hash, &tag->data.array); break;
- case TAG_BOOL: hash_update_bool(hash, &tag->data.bool); break;
- case TAG_CALL: hash_update_call(hash, &tag->data.call); break;
- case TAG_CFN: hash_update_cfn(hash, &tag->data.cfn); break;
+ case TAG_ARRAY: return hash_update_array(hash, &tag->data.array);
+ case TAG_BOOL: return hash_update_bool(hash, &tag->data.bool);
+ case TAG_CALL: return hash_update_call(hash, &tag->data.call);
+ case TAG_CFN: return hash_update_cfn(hash, &tag->data.cfn);
case TAG_CHARACTER:
- hash_update_character(hash, &tag->data.character); break;
- case TAG_F32: hash_update_f32(hash, &tag->data.f32); break;
- case TAG_F64: hash_update_f64(hash, &tag->data.f64); break;
- case TAG_FACT: hash_update_fact(hash, &tag->data.fact); break;
- case TAG_FN: hash_update_fn(hash, &tag->data.fn); break;
- case TAG_IDENT: hash_update_ident(hash, &tag->data.ident); break;
+ return hash_update_character(hash, &tag->data.character);
+ case TAG_F32: return hash_update_f32(hash, &tag->data.f32);
+ case TAG_F64: return hash_update_f64(hash, &tag->data.f64);
+ case TAG_FACT: return hash_update_fact(hash, &tag->data.fact);
+ case TAG_FN: return hash_update_fn(hash, &tag->data.fn);
+ case TAG_IDENT: return hash_update_ident(hash, &tag->data.ident);
case TAG_INTEGER:
- hash_update_integer(hash, &tag->data.integer); break;
+ return hash_update_integer(hash, &tag->data.integer);
case TAG_LIST:
- hash_update_list(hash, (const s_list * const *) &tag->data.list);
- break;
- case TAG_MAP: hash_update_map(hash, &tag->data.map); break;
- case TAG_PTAG: hash_update_ptag(hash, &tag->data.ptag); break;
- case TAG_PTR: hash_update_ptr(hash, &tag->data.ptr); break;
+ return hash_update_list(hash, (const s_list * const *)
+ &tag->data.list);
+ case TAG_MAP: hash_update_map(hash, &tag->data.map);
+ case TAG_PTAG: hash_update_ptag(hash, &tag->data.ptag);
+ case TAG_PTR: hash_update_ptr(hash, &tag->data.ptr);
case TAG_PTR_FREE:
- hash_update_ptr_free(hash, &tag->data.ptr_free); break;
- case TAG_QUOTE: hash_update_quote(hash, &tag->data.quote); break;
- case TAG_S8: hash_update_s8(hash, &tag->data.s8); break;
- case TAG_S16: hash_update_s16(hash, &tag->data.s16); break;
- case TAG_S32: hash_update_s32(hash, &tag->data.s32); break;
- case TAG_S64: hash_update_s64(hash, &tag->data.s64); break;
- case TAG_SW: hash_update_sw(hash, &tag->data.sw); break;
- case TAG_STR: hash_update_str(hash, &tag->data.str); break;
- case TAG_STRUCT: hash_update_struct(hash, &tag->data.struct_); break;
- case TAG_SYM: hash_update_sym(hash, &tag->data.sym); break;
- case TAG_TUPLE: hash_update_tuple(hash, &tag->data.tuple); break;
- case TAG_U8: hash_update_u8(hash, &tag->data.u8); break;
- case TAG_U16: hash_update_u16(hash, &tag->data.u16); break;
- case TAG_U32: hash_update_u32(hash, &tag->data.u32); break;
- case TAG_U64: hash_update_u64(hash, &tag->data.u64); break;
- case TAG_UW: hash_update_uw(hash, &tag->data.uw); break;
- case TAG_VAR: hash_update_var(hash, NULL); break;
- case TAG_VOID: hash_update_void(hash, NULL); break;
+ hash_update_ptr_free(hash, &tag->data.ptr_free);
+ case TAG_QUOTE: return hash_update_quote(hash, &tag->data.quote);
+ case TAG_S8: return hash_update_s8(hash, &tag->data.s8);
+ case TAG_S16: return hash_update_s16(hash, &tag->data.s16);
+ case TAG_S32: return hash_update_s32(hash, &tag->data.s32);
+ case TAG_S64: return hash_update_s64(hash, &tag->data.s64);
+ case TAG_SW: return hash_update_sw(hash, &tag->data.sw);
+ case TAG_STR: return hash_update_str(hash, &tag->data.str);
+ case TAG_STRUCT:
+ return hash_update_struct(hash, &tag->data.struct_);
+ case TAG_SYM: return hash_update_sym(hash, &tag->data.sym);
+ case TAG_TUPLE: return hash_update_tuple(hash, &tag->data.tuple);
+ case TAG_U8: return hash_update_u8(hash, &tag->data.u8);
+ case TAG_U16: return hash_update_u16(hash, &tag->data.u16);
+ case TAG_U32: return hash_update_u32(hash, &tag->data.u32);
+ case TAG_U64: return hash_update_u64(hash, &tag->data.u64);
+ case TAG_UW: return hash_update_uw(hash, &tag->data.uw);
+ case TAG_VAR: return hash_update_var(hash, NULL);
+ case TAG_VOID: return hash_update_void(hash, NULL);
}
+ warnx("hash_update_tag: unknown tag type: %d", tag->type);
+ assert(! "hash_update_tag: unknown tag type");
+ return false;
}
-void hash_update_tuple (t_hash *hash, const s_tuple *tuple)
+bool hash_update_tuple (t_hash *hash, const s_tuple *tuple)
{
uw i = 0;
assert(tuple);
- hash_update(hash, &tuple->count, sizeof(tuple->count));
+ if (! hash_update(hash, &tuple->count, sizeof(tuple->count)))
+ return false;
while (i < tuple->count) {
- hash_update_tag(hash, tuple->tag + i);
+ if (! hash_update_tag(hash, tuple->tag + i))
+ return false;
i++;
}
+ return true;
}
HASH_UPDATE_DEF(u8)
@@ -410,18 +454,18 @@ HASH_UPDATE_DEF(u32)
HASH_UPDATE_DEF(u64)
HASH_UPDATE_DEF(uw)
-void hash_update_var (t_hash *hash, const void *x)
+bool hash_update_var (t_hash *hash, const void *x)
{
s8 type[] = "var";
(void) x;
assert(hash);
- hash_update(hash, type, strlen(type));
+ return hash_update(hash, type, strlen(type));
}
-void hash_update_void (t_hash *hash, const void *x)
+bool hash_update_void (t_hash *hash, const void *x)
{
s8 type[] = "void";
(void) x;
assert(hash);
- hash_update(hash, type, strlen(type));
+ return hash_update(hash, type, strlen(type));
}
diff --git a/libc3/hash.h b/libc3/hash.h
index 4a9f95d..04c7616 100644
--- a/libc3/hash.h
+++ b/libc3/hash.h
@@ -16,48 +16,48 @@
#include "types.h"
#define HASH_UPDATE_PROTOTYPE(type) \
- void hash_update_##type (t_hash *hash, const type *x)
+ bool hash_update_##type (t_hash *hash, const type *x)
void hash_clean (t_hash *hash);
void hash_init (t_hash *hash);
uw hash_to_uw (t_hash *hash);
u64 hash_to_u64 (t_hash *hash);
-void hash_update (t_hash *hash, const void *data, uw size);
-void hash_update_1 (t_hash *hash, const s8 *p);
-void hash_update_array (t_hash *hash, const s_array *a);
-void hash_update_bool (t_hash *hash, const bool *b);
-void hash_update_call (t_hash *hash, const s_call *call);
-void hash_update_cfn (t_hash *hash, const s_cfn *cfn);
+bool hash_update (t_hash *hash, const void *data, uw size);
+bool hash_update_1 (t_hash *hash, const s8 *p);
+bool hash_update_array (t_hash *hash, const s_array *a);
+bool hash_update_bool (t_hash *hash, const bool *b);
+bool hash_update_call (t_hash *hash, const s_call *call);
+bool hash_update_cfn (t_hash *hash, const s_cfn *cfn);
HASH_UPDATE_PROTOTYPE(character);
HASH_UPDATE_PROTOTYPE(f32);
HASH_UPDATE_PROTOTYPE(f64);
-void hash_update_fact (t_hash *hash, const s_fact *fact);
-void hash_update_fn (t_hash *hash, const s_fn *fn);
-void hash_update_fn_clauses (t_hash *hash, const s_fn_clause *clauses);
-void hash_update_ident (t_hash *hash, const s_ident *ident);
-void hash_update_integer (t_hash *hash, const s_integer *i);
-void hash_update_list (t_hash *hash, const s_list * const *list);
-void hash_update_map (t_hash *hash, const s_map *map);
-void hash_update_ptag (t_hash *hash, const p_tag *ptag);
-void hash_update_ptr (t_hash *hash, const u_ptr_w *ptr);
-void hash_update_ptr_free (t_hash *hash, const u_ptr_w *ptr_free);
-void hash_update_quote (t_hash *hash, const s_quote *x);
+bool hash_update_fact (t_hash *hash, const s_fact *fact);
+bool hash_update_fn (t_hash *hash, const s_fn *fn);
+bool hash_update_fn_clauses (t_hash *hash, const s_fn_clause *clauses);
+bool hash_update_ident (t_hash *hash, const s_ident *ident);
+bool hash_update_integer (t_hash *hash, const s_integer *i);
+bool hash_update_list (t_hash *hash, const s_list * const *list);
+bool hash_update_map (t_hash *hash, const s_map *map);
+bool hash_update_ptag (t_hash *hash, const p_tag *ptag);
+bool hash_update_ptr (t_hash *hash, const u_ptr_w *ptr);
+bool hash_update_ptr_free (t_hash *hash, const u_ptr_w *ptr_free);
+bool hash_update_quote (t_hash *hash, const s_quote *x);
HASH_UPDATE_PROTOTYPE(s8);
HASH_UPDATE_PROTOTYPE(s16);
HASH_UPDATE_PROTOTYPE(s32);
HASH_UPDATE_PROTOTYPE(s64);
HASH_UPDATE_PROTOTYPE(sw);
-void hash_update_str (t_hash *hash, const s_str *str);
-void hash_update_struct (t_hash *hash, const s_struct *s);
-void hash_update_sym (t_hash *hash, const s_sym * const *sym);
-void hash_update_tag (t_hash *hash, const s_tag *tag);
-void hash_update_tuple (t_hash *hash, const s_tuple *tuple);
+bool hash_update_str (t_hash *hash, const s_str *str);
+bool hash_update_struct (t_hash *hash, const s_struct *s);
+bool hash_update_sym (t_hash *hash, const s_sym * const *sym);
+bool hash_update_tag (t_hash *hash, const s_tag *tag);
+bool hash_update_tuple (t_hash *hash, const s_tuple *tuple);
HASH_UPDATE_PROTOTYPE(u8);
HASH_UPDATE_PROTOTYPE(u16);
HASH_UPDATE_PROTOTYPE(u32);
HASH_UPDATE_PROTOTYPE(u64);
HASH_UPDATE_PROTOTYPE(uw);
-void hash_update_var (t_hash *hash, const void *x);
-void hash_update_void (t_hash *hash, const void *x);
+bool hash_update_var (t_hash *hash, const void *x);
+bool hash_update_void (t_hash *hash, const void *x);
#endif /* LIBC3_HASH_H */
diff --git a/libc3/tag_type.c b/libc3/tag_type.c
index 892114d..852ca47 100644
--- a/libc3/tag_type.c
+++ b/libc3/tag_type.c
@@ -464,16 +464,51 @@ bool tag_type_to_init_copy (e_tag_type type, f_init_copy *p)
assert(! "tag_type_to_init_copy: invalid tag type");
return false;
}
+*/
-const s8 * tag_type_to_string (e_tag_type type)
+const s8 * tag_type_to_string (e_tag_type tag_type)
{
- const s_sym *sym;
- if (! (sym = tag_type_to_sym(type)))
- return NULL;
- return sym->str.ptr.ps8;
+ switch (tag_type) {
+ case TAG_VOID: return "Void";
+ case TAG_ARRAY: return "Array";
+ case TAG_BOOL: return "Bool";
+ case TAG_CALL: return "Call";
+ case TAG_CFN: return "Cfn";
+ case TAG_CHARACTER: return "Character";
+ case TAG_F32: return "F32";
+ case TAG_F64: return "F64";
+ case TAG_FACT: return "Fact";
+ case TAG_FN: return "Fn";
+ case TAG_IDENT: return "Ident";
+ case TAG_INTEGER: return "Integer";
+ case TAG_SW: return "Sw";
+ case TAG_S64: return "S64";
+ case TAG_S32: return "S32";
+ case TAG_S16: return "S16";
+ case TAG_S8: return "S8";
+ case TAG_U8: return "U8";
+ case TAG_U16: return "U16";
+ case TAG_U32: return "U32";
+ case TAG_U64: return "U64";
+ case TAG_UW: return "Uw";
+ case TAG_LIST: return "List";
+ case TAG_MAP: return "Map";
+ case TAG_PTAG: return "Ptag";
+ case TAG_PTR: return "Ptr";
+ case TAG_PTR_FREE: return "PtrFree";
+ case TAG_QUOTE: return "Quote";
+ case TAG_STR: return "Str";
+ case TAG_STRUCT: return "Struct";
+ case TAG_SYM: return "Sym";
+ case TAG_TUPLE: return "Tuple";
+ case TAG_VAR: return "Var";
+ }
+ warnx("tag_type_to_string: unknown tag type: %d", tag_type);
+ assert(! "tag_type_to_string: unknown tag type");
+ return NULL;
}
-*/
+/*
const s_sym * tag_type_to_sym (e_tag_type tag_type)
{
switch (tag_type) {
@@ -515,3 +550,4 @@ const s_sym * tag_type_to_sym (e_tag_type tag_type)
errx(1, "tag_type_to_sym: invalid tag type: %d", tag_type);
return NULL;
}
+*/
diff --git a/libc3/void.h b/libc3/void.h
index 142f033..280fde3 100644
--- a/libc3/void.h
+++ b/libc3/void.h
@@ -24,7 +24,7 @@
sw void_buf_inspect (const s_sym *type, s_buf *buf, const void *v);
sw void_buf_inspect_size (const s_sym *type, const void *v);
bool void_clean (const s_sym *type, void *v);
-void void_hash_update (const s_sym *type, t_hash *hash,
+bool void_hash_update (const s_sym *type, t_hash *hash,
const void *s);
void * void_init_cast (const s_sym *type, void *v, const s_tag *src);
void * void_init_copy (const s_sym *type, void *v, const void *src);