diff --git a/extlib/xhash b/extlib/xhash index ddc2ea28..0b5f935a 160000 --- a/extlib/xhash +++ b/extlib/xhash @@ -1 +1 @@ -Subproject commit ddc2ea288b37b3f5de37024ff2648d11aa18811a +Subproject commit 0b5f935aa7a236f1ef1787f81dce7f5ba679e95b diff --git a/include/picrin/value.h b/include/picrin/value.h index 023902a3..4161b403 100644 --- a/include/picrin/value.h +++ b/include/picrin/value.h @@ -13,7 +13,7 @@ extern "C" { * pic_sym is just an alias to unsigned int. */ -typedef unsigned pic_sym; +typedef int pic_sym; /** * `undef` values never seen from user-end: that is, diff --git a/src/bool.c b/src/bool.c index 74018c63..8f8c75f1 100644 --- a/src/bool.c +++ b/src/bool.c @@ -42,10 +42,10 @@ internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xhash * pic_errorf(pic, "Stack overflow in equal\n"); } if (pic_pair_p(x) || pic_vec_p(x)) { - if (xh_get(ht, pic_obj_ptr(x)) != NULL) { + if (xh_get_ptr(ht, pic_obj_ptr(x)) != NULL) { return true; /* `x' was seen already. */ } else { - xh_put(ht, pic_obj_ptr(x), NULL); + xh_put_ptr(ht, pic_obj_ptr(x), NULL); } } } diff --git a/src/symbol.c b/src/symbol.c index 2ea530d5..10fd3822 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -20,13 +20,13 @@ pic_intern(pic_state *pic, const char *str, size_t len) cstr[len] = '\0'; memcpy(cstr, str, len); - e = xh_get(&pic->syms, cstr); + e = xh_get_str(&pic->syms, cstr); if (e) { return xh_val(e, pic_sym); } id = pic->sym_cnt++; - xh_put(&pic->syms, cstr, &id); + xh_put_str(&pic->syms, cstr, &id); xh_put_int(&pic->sym_names, id, &cstr); return id; } diff --git a/src/write.c b/src/write.c index 4122e600..bd13ac44 100644 --- a/src/write.c +++ b/src/write.c @@ -84,14 +84,14 @@ traverse_shared(struct writer_control *p, pic_value obj) switch (pic_type(obj)) { case PIC_TT_PAIR: case PIC_TT_VECTOR: - e = xh_get(&p->labels, pic_obj_ptr(obj)); + e = xh_get_ptr(&p->labels, pic_obj_ptr(obj)); if (e == NULL) { c = -1; - xh_put(&p->labels, pic_obj_ptr(obj), &c); + xh_put_ptr(&p->labels, pic_obj_ptr(obj), &c); } else if (xh_val(e, int) == -1) { c = p->cnt++; - xh_put(&p->labels, pic_obj_ptr(obj), &c); + xh_put_ptr(&p->labels, pic_obj_ptr(obj), &c); break; } else { @@ -130,17 +130,17 @@ write_pair(struct writer_control *p, struct pic_pair *pair) else if (pic_pair_p(pair->cdr)) { /* shared objects */ - if ((e = xh_get(&p->labels, pic_obj_ptr(pair->cdr))) && xh_val(e, int) != -1) { + if ((e = xh_get_ptr(&p->labels, pic_obj_ptr(pair->cdr))) && xh_val(e, int) != -1) { xfprintf(p->file, " . "); - if ((xh_get(&p->visited, pic_obj_ptr(pair->cdr)))) { + if ((xh_get_ptr(&p->visited, pic_obj_ptr(pair->cdr)))) { xfprintf(p->file, "#%d#", xh_val(e, int)); return; } else { xfprintf(p->file, "#%d=", xh_val(e, int)); c = 1; - xh_put(&p->visited, pic_obj_ptr(pair->cdr), &c); + xh_put_ptr(&p->visited, pic_obj_ptr(pair->cdr), &c); } } else { @@ -184,16 +184,16 @@ write_core(struct writer_control *p, pic_value obj) /* shared objects */ if (pic_vtype(obj) == PIC_VTYPE_HEAP - && (e = xh_get(&p->labels, pic_obj_ptr(obj))) + && (e = xh_get_ptr(&p->labels, pic_obj_ptr(obj))) && xh_val(e, int) != -1) { - if ((xh_get(&p->visited, pic_obj_ptr(obj)))) { + if ((xh_get_ptr(&p->visited, pic_obj_ptr(obj)))) { xfprintf(file, "#%d#", xh_val(e, int)); return; } else { xfprintf(file, "#%d=", xh_val(e, int)); c = 1; - xh_put(&p->visited, pic_obj_ptr(obj), &c); + xh_put_ptr(&p->visited, pic_obj_ptr(obj), &c); } }