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)) {
|
switch (pic_type(pic, x)) {
|
||||||
case PIC_TYPE_ID: {
|
case PIC_TYPE_ID: {
|
||||||
struct pic_id *id1, *id2;
|
pic_id *id1, *id2;
|
||||||
pic_sym *s1, *s2;
|
pic_sym *s1, *s2;
|
||||||
|
|
||||||
id1 = pic_id_ptr(x);
|
id1 = pic_id_ptr(x);
|
||||||
id2 = pic_id_ptr(y);
|
id2 = pic_id_ptr(y);
|
||||||
|
|
||||||
s1 = pic_find_identifier(pic, id1->u.id.id, id1->u.id.env);
|
s1 = pic_find_identifier(pic, id1->u.id, id1->env);
|
||||||
s2 = pic_find_identifier(pic, id2->u.id.id, id2->u.id.env);
|
s2 = pic_find_identifier(pic, id2->u.id, id2->env);
|
||||||
|
|
||||||
return s1 == s2;
|
return s1 == s2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct heap_page {
|
||||||
struct pic_object {
|
struct pic_object {
|
||||||
union {
|
union {
|
||||||
struct pic_basic basic;
|
struct pic_basic basic;
|
||||||
struct pic_symbol sym;
|
struct pic_identifier id;
|
||||||
struct pic_string str;
|
struct pic_string str;
|
||||||
struct pic_blob blob;
|
struct pic_blob blob;
|
||||||
struct pic_pair pair;
|
struct pic_pair pair;
|
||||||
|
@ -29,7 +29,6 @@ struct pic_object {
|
||||||
struct pic_weak weak;
|
struct pic_weak weak;
|
||||||
struct pic_data data;
|
struct pic_data data;
|
||||||
struct pic_record rec;
|
struct pic_record rec;
|
||||||
struct pic_id id;
|
|
||||||
struct pic_env env;
|
struct pic_env env;
|
||||||
struct pic_proc proc;
|
struct pic_proc proc;
|
||||||
struct pic_context cxt;
|
struct pic_context cxt;
|
||||||
|
@ -333,8 +332,8 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PIC_TYPE_ID: {
|
case PIC_TYPE_ID: {
|
||||||
gc_mark_object(pic, (struct pic_object *)obj->u.id.u.id.id);
|
gc_mark_object(pic, (struct pic_object *)obj->u.id.u.id);
|
||||||
LOOP(obj->u.id.u.id.env);
|
LOOP(obj->u.id.env);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PIC_TYPE_ENV: {
|
case PIC_TYPE_ENV: {
|
||||||
|
@ -377,7 +376,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PIC_TYPE_SYMBOL: {
|
case PIC_TYPE_SYMBOL: {
|
||||||
LOOP(obj->u.sym.str);
|
LOOP(obj->u.id.u.str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PIC_TYPE_WEAK: {
|
case PIC_TYPE_WEAK: {
|
||||||
|
|
|
@ -57,8 +57,8 @@ struct pic_port;
|
||||||
struct pic_error;
|
struct pic_error;
|
||||||
struct pic_env;
|
struct pic_env;
|
||||||
|
|
||||||
typedef struct pic_symbol pic_sym;
|
typedef struct pic_identifier pic_id;
|
||||||
typedef struct pic_id pic_id;
|
typedef pic_id pic_sym;
|
||||||
|
|
||||||
typedef void *(*pic_allocf)(void *userdata, void *ptr, size_t n);
|
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(dict, pic_sym *, pic_value)
|
||||||
KHASH_DECLARE(weak, struct pic_object *, pic_value)
|
KHASH_DECLARE(weak, struct pic_object *, pic_value)
|
||||||
|
|
||||||
struct pic_id {
|
struct pic_identifier {
|
||||||
|
PIC_OBJECT_HEADER
|
||||||
union {
|
union {
|
||||||
struct pic_symbol {
|
|
||||||
PIC_OBJECT_HEADER
|
|
||||||
struct pic_string *str;
|
struct pic_string *str;
|
||||||
} sym;
|
struct pic_identifier *id;
|
||||||
struct {
|
|
||||||
PIC_OBJECT_HEADER
|
|
||||||
struct pic_id *id;
|
|
||||||
struct pic_env *env;
|
|
||||||
} id;
|
|
||||||
} u;
|
} u;
|
||||||
|
struct pic_env *env;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pic_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))) {
|
if (pic_sym_p(pic, pic_obj_value(id))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
env = id->u.id.env; /* do not overwrite id first */
|
env = id->env; /* do not overwrite id first */
|
||||||
id = id->u.id.id;
|
id = id->u.id;
|
||||||
}
|
}
|
||||||
if (uid == NULL) {
|
if (uid == NULL) {
|
||||||
while (env->up != NULL) {
|
while (env->up != NULL) {
|
||||||
|
|
|
@ -27,8 +27,8 @@ pic_intern(pic_state *pic, pic_value str)
|
||||||
|
|
||||||
kh_val(h, it) = pic->sQUOTE; /* dummy */
|
kh_val(h, it) = pic->sQUOTE; /* dummy */
|
||||||
|
|
||||||
sym = (pic_sym *)pic_obj_alloc(pic, sizeof(pic_sym), PIC_TYPE_SYMBOL);
|
sym = (pic_sym *)pic_obj_alloc(pic, offsetof(pic_sym, env), PIC_TYPE_SYMBOL);
|
||||||
sym->str = pic_str_ptr(pic, str);
|
sym->u.str = pic_str_ptr(pic, str);
|
||||||
kh_val(h, it) = sym;
|
kh_val(h, it) = sym;
|
||||||
|
|
||||||
return sym;
|
return sym;
|
||||||
|
@ -40,22 +40,22 @@ pic_make_identifier(pic_state *pic, pic_id *id, struct pic_env *env)
|
||||||
pic_id *nid;
|
pic_id *nid;
|
||||||
|
|
||||||
nid = (pic_id *)pic_obj_alloc(pic, sizeof(pic_id), PIC_TYPE_ID);
|
nid = (pic_id *)pic_obj_alloc(pic, sizeof(pic_id), PIC_TYPE_ID);
|
||||||
nid->u.id.id = id;
|
nid->u.id = id;
|
||||||
nid->u.id.env = env;
|
nid->env = env;
|
||||||
return nid;
|
return nid;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
pic_sym_name(pic_state PIC_UNUSED(*pic), pic_sym *sym)
|
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_value
|
||||||
pic_id_name(pic_state *pic, pic_id *id)
|
pic_id_name(pic_state *pic, pic_id *id)
|
||||||
{
|
{
|
||||||
while (! pic_sym_p(pic, pic_obj_value(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);
|
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);
|
pic_get_args(pic, "m", &sym);
|
||||||
|
|
||||||
return pic_obj_value(sym->str);
|
return pic_obj_value(sym->u.str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
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);
|
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
|
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);
|
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
|
static pic_value
|
||||||
|
|
Loading…
Reference in New Issue