use brand new API style of xhash
This commit is contained in:
parent
055a288199
commit
c1e6645086
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
18
src/write.c
18
src/write.c
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue