use brand new API style of xhash

This commit is contained in:
Yuichi Nishiwaki 2014-08-01 18:48:14 +09:00
parent 055a288199
commit c1e6645086
3 changed files with 13 additions and 13 deletions

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");
}
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);
}
}
}

View File

@ -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;
}

View File

@ -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);
}
}