change irep of symbol and identifier
This commit is contained in:
parent
ef26a75d45
commit
1a316a7a69
|
@ -94,14 +94,14 @@ internal_equal_p(pic_state *pic, pic_value x, pic_value y, int depth, khash_t(m)
|
|||
|
||||
switch (pic_type(pic, x)) {
|
||||
case PIC_TYPE_ID: {
|
||||
struct pic_id *id1, *id2;
|
||||
pic_id *id1, *id2;
|
||||
pic_sym *s1, *s2;
|
||||
|
||||
id1 = pic_id_ptr(x);
|
||||
id2 = pic_id_ptr(y);
|
||||
|
||||
s1 = pic_find_identifier(pic, id1->u.id.id, id1->u.id.env);
|
||||
s2 = pic_find_identifier(pic, id2->u.id.id, id2->u.id.env);
|
||||
s1 = pic_find_identifier(pic, id1->u.id, id1->env);
|
||||
s2 = pic_find_identifier(pic, id2->u.id, id2->env);
|
||||
|
||||
return s1 == s2;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ struct heap_page {
|
|||
struct pic_object {
|
||||
union {
|
||||
struct pic_basic basic;
|
||||
struct pic_symbol sym;
|
||||
struct pic_identifier id;
|
||||
struct pic_string str;
|
||||
struct pic_blob blob;
|
||||
struct pic_pair pair;
|
||||
|
@ -29,7 +29,6 @@ struct pic_object {
|
|||
struct pic_weak weak;
|
||||
struct pic_data data;
|
||||
struct pic_record rec;
|
||||
struct pic_id id;
|
||||
struct pic_env env;
|
||||
struct pic_proc proc;
|
||||
struct pic_context cxt;
|
||||
|
@ -333,8 +332,8 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
|
|||
break;
|
||||
}
|
||||
case PIC_TYPE_ID: {
|
||||
gc_mark_object(pic, (struct pic_object *)obj->u.id.u.id.id);
|
||||
LOOP(obj->u.id.u.id.env);
|
||||
gc_mark_object(pic, (struct pic_object *)obj->u.id.u.id);
|
||||
LOOP(obj->u.id.env);
|
||||
break;
|
||||
}
|
||||
case PIC_TYPE_ENV: {
|
||||
|
@ -377,7 +376,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
|
|||
break;
|
||||
}
|
||||
case PIC_TYPE_SYMBOL: {
|
||||
LOOP(obj->u.sym.str);
|
||||
LOOP(obj->u.id.u.str);
|
||||
break;
|
||||
}
|
||||
case PIC_TYPE_WEAK: {
|
||||
|
|
|
@ -57,8 +57,8 @@ struct pic_port;
|
|||
struct pic_error;
|
||||
struct pic_env;
|
||||
|
||||
typedef struct pic_symbol pic_sym;
|
||||
typedef struct pic_id pic_id;
|
||||
typedef struct pic_identifier pic_id;
|
||||
typedef pic_id pic_sym;
|
||||
|
||||
typedef void *(*pic_allocf)(void *userdata, void *ptr, size_t n);
|
||||
|
||||
|
|
|
@ -13,18 +13,13 @@ KHASH_DECLARE(env, pic_id *, pic_sym *)
|
|||
KHASH_DECLARE(dict, pic_sym *, pic_value)
|
||||
KHASH_DECLARE(weak, struct pic_object *, pic_value)
|
||||
|
||||
struct pic_id {
|
||||
struct pic_identifier {
|
||||
PIC_OBJECT_HEADER
|
||||
union {
|
||||
struct pic_symbol {
|
||||
PIC_OBJECT_HEADER
|
||||
struct pic_string *str;
|
||||
} sym;
|
||||
struct {
|
||||
PIC_OBJECT_HEADER
|
||||
struct pic_id *id;
|
||||
struct pic_env *env;
|
||||
} id;
|
||||
struct pic_string *str;
|
||||
struct pic_identifier *id;
|
||||
} u;
|
||||
struct pic_env *env;
|
||||
};
|
||||
|
||||
struct pic_env {
|
||||
|
|
|
@ -88,8 +88,8 @@ pic_find_identifier(pic_state *pic, pic_id *id, struct pic_env *env)
|
|||
if (pic_sym_p(pic, pic_obj_value(id))) {
|
||||
break;
|
||||
}
|
||||
env = id->u.id.env; /* do not overwrite id first */
|
||||
id = id->u.id.id;
|
||||
env = id->env; /* do not overwrite id first */
|
||||
id = id->u.id;
|
||||
}
|
||||
if (uid == NULL) {
|
||||
while (env->up != NULL) {
|
||||
|
|
|
@ -27,8 +27,8 @@ pic_intern(pic_state *pic, pic_value str)
|
|||
|
||||
kh_val(h, it) = pic->sQUOTE; /* dummy */
|
||||
|
||||
sym = (pic_sym *)pic_obj_alloc(pic, sizeof(pic_sym), PIC_TYPE_SYMBOL);
|
||||
sym->str = pic_str_ptr(pic, str);
|
||||
sym = (pic_sym *)pic_obj_alloc(pic, offsetof(pic_sym, env), PIC_TYPE_SYMBOL);
|
||||
sym->u.str = pic_str_ptr(pic, str);
|
||||
kh_val(h, it) = sym;
|
||||
|
||||
return sym;
|
||||
|
@ -40,22 +40,22 @@ pic_make_identifier(pic_state *pic, pic_id *id, struct pic_env *env)
|
|||
pic_id *nid;
|
||||
|
||||
nid = (pic_id *)pic_obj_alloc(pic, sizeof(pic_id), PIC_TYPE_ID);
|
||||
nid->u.id.id = id;
|
||||
nid->u.id.env = env;
|
||||
nid->u.id = id;
|
||||
nid->env = env;
|
||||
return nid;
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_sym_name(pic_state PIC_UNUSED(*pic), pic_sym *sym)
|
||||
{
|
||||
return pic_obj_value(sym->str);
|
||||
return pic_obj_value(sym->u.str);
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_id_name(pic_state *pic, pic_id *id)
|
||||
{
|
||||
while (! pic_sym_p(pic, pic_obj_value(id))) {
|
||||
id = id->u.id.id;
|
||||
id = id->u.id;
|
||||
}
|
||||
|
||||
return pic_sym_name(pic, (pic_sym *)id);
|
||||
|
@ -97,7 +97,7 @@ pic_symbol_symbol_to_string(pic_state *pic)
|
|||
|
||||
pic_get_args(pic, "m", &sym);
|
||||
|
||||
return pic_obj_value(sym->str);
|
||||
return pic_obj_value(sym->u.str);
|
||||
}
|
||||
|
||||
static pic_value
|
||||
|
@ -146,7 +146,7 @@ pic_symbol_identifier_variable(pic_state *pic)
|
|||
pic_errorf(pic, "expected non-symbol identifier, but got symbol ~s", id);
|
||||
}
|
||||
|
||||
return pic_obj_value(pic_id_ptr(id)->u.id.id);
|
||||
return pic_obj_value(pic_id_ptr(id)->u.id);
|
||||
}
|
||||
|
||||
static pic_value
|
||||
|
@ -162,7 +162,7 @@ pic_symbol_identifier_environment(pic_state *pic)
|
|||
pic_errorf(pic, "expected non-symbol identifier, but got symbol ~s", id);
|
||||
}
|
||||
|
||||
return pic_obj_value(pic_id_ptr(id)->u.id.env);
|
||||
return pic_obj_value(pic_id_ptr(id)->env);
|
||||
}
|
||||
|
||||
static pic_value
|
||||
|
|
Loading…
Reference in New Issue