Merge branch 'update-xhash'

This commit is contained in:
Yuichi Nishiwaki 2014-08-01 18:52:31 +09:00
commit 48003c2ce1
5 changed files with 15 additions and 15 deletions

@ -1 +1 @@
Subproject commit ddc2ea288b37b3f5de37024ff2648d11aa18811a Subproject commit 0b5f935aa7a236f1ef1787f81dce7f5ba679e95b

View File

@ -13,7 +13,7 @@ extern "C" {
* pic_sym is just an alias to unsigned int. * 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, * `undef` values never seen from user-end: that is,

View File

@ -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"); pic_errorf(pic, "Stack overflow in equal\n");
} }
if (pic_pair_p(x) || pic_vec_p(x)) { 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. */ return true; /* `x' was seen already. */
} else { } else {
xh_put(ht, pic_obj_ptr(x), NULL); xh_put_ptr(ht, pic_obj_ptr(x), NULL);
} }
} }
} }

View File

@ -20,13 +20,13 @@ pic_intern(pic_state *pic, const char *str, size_t len)
cstr[len] = '\0'; cstr[len] = '\0';
memcpy(cstr, str, len); memcpy(cstr, str, len);
e = xh_get(&pic->syms, cstr); e = xh_get_str(&pic->syms, cstr);
if (e) { if (e) {
return xh_val(e, pic_sym); return xh_val(e, pic_sym);
} }
id = pic->sym_cnt++; 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); xh_put_int(&pic->sym_names, id, &cstr);
return id; return id;
} }

View File

@ -84,14 +84,14 @@ traverse_shared(struct writer_control *p, pic_value obj)
switch (pic_type(obj)) { switch (pic_type(obj)) {
case PIC_TT_PAIR: case PIC_TT_PAIR:
case PIC_TT_VECTOR: 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) { if (e == NULL) {
c = -1; 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) { else if (xh_val(e, int) == -1) {
c = p->cnt++; c = p->cnt++;
xh_put(&p->labels, pic_obj_ptr(obj), &c); xh_put_ptr(&p->labels, pic_obj_ptr(obj), &c);
break; break;
} }
else { else {
@ -130,17 +130,17 @@ write_pair(struct writer_control *p, struct pic_pair *pair)
else if (pic_pair_p(pair->cdr)) { else if (pic_pair_p(pair->cdr)) {
/* shared objects */ /* 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, " . "); 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)); xfprintf(p->file, "#%d#", xh_val(e, int));
return; return;
} }
else { else {
xfprintf(p->file, "#%d=", xh_val(e, int)); xfprintf(p->file, "#%d=", xh_val(e, int));
c = 1; c = 1;
xh_put(&p->visited, pic_obj_ptr(pair->cdr), &c); xh_put_ptr(&p->visited, pic_obj_ptr(pair->cdr), &c);
} }
} }
else { else {
@ -184,16 +184,16 @@ write_core(struct writer_control *p, pic_value obj)
/* shared objects */ /* shared objects */
if (pic_vtype(obj) == PIC_VTYPE_HEAP 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) { && 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)); xfprintf(file, "#%d#", xh_val(e, int));
return; return;
} }
else { else {
xfprintf(file, "#%d=", xh_val(e, int)); xfprintf(file, "#%d=", xh_val(e, int));
c = 1; c = 1;
xh_put(&p->visited, pic_obj_ptr(obj), &c); xh_put_ptr(&p->visited, pic_obj_ptr(obj), &c);
} }
} }