add pic_resolve

This commit is contained in:
Yuichi Nishiwaki 2015-06-19 17:31:47 +09:00
parent 3021e7f2b9
commit 7ec81ab1d5
4 changed files with 7 additions and 6 deletions

View File

@ -110,7 +110,7 @@ internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xhash *
id1 = pic_id_ptr(x); id1 = pic_id_ptr(x);
id2 = pic_id_ptr(y); id2 = pic_id_ptr(y);
return pic_eq_p(pic_expand(pic, id1->var, id1->env), pic_expand(pic, id2->var, id2->env)); return pic_resolve(pic, id1->var, id1->env) == pic_resolve(pic, id2->var, id2->env);
} }
default: default:
return false; return false;

View File

@ -24,8 +24,8 @@ lookup(pic_state PIC_UNUSED(*pic), pic_value var, struct pic_env *env)
return NULL; return NULL;
} }
static pic_sym * pic_sym *
resolve(pic_state *pic, pic_value var, struct pic_env *env) pic_resolve(pic_state *pic, pic_value var, struct pic_env *env)
{ {
pic_sym *uid; pic_sym *uid;
@ -72,7 +72,7 @@ static pic_value expand_lambda(pic_state *, pic_value, struct pic_env *);
static pic_value static pic_value
expand_var(pic_state *pic, pic_value var, struct pic_env *env) expand_var(pic_state *pic, pic_value var, struct pic_env *env)
{ {
return pic_obj_value(resolve(pic, var, env)); return pic_obj_value(pic_resolve(pic, var, env));
} }
static pic_value static pic_value
@ -275,7 +275,7 @@ expand_node(pic_state *pic, pic_value expr, struct pic_env *env, pic_value defer
if (pic_var_p(pic_car(pic, expr))) { if (pic_var_p(pic_car(pic, expr))) {
pic_sym *functor; pic_sym *functor;
functor = resolve(pic, pic_car(pic, expr), env); functor = pic_resolve(pic, pic_car(pic, expr), env);
if (functor == pic->uDEFINE_MACRO) { if (functor == pic->uDEFINE_MACRO) {
return expand_defmacro(pic, expr, env); return expand_defmacro(pic, expr, env);

View File

@ -217,7 +217,6 @@ pic_value pic_apply4(pic_state *, struct pic_proc *, pic_value, pic_value, pic_v
pic_value pic_apply5(pic_state *, struct pic_proc *, pic_value, pic_value, pic_value, pic_value, pic_value); pic_value pic_apply5(pic_state *, struct pic_proc *, pic_value, pic_value, pic_value, pic_value, pic_value);
pic_value pic_apply_trampoline(pic_state *, struct pic_proc *, pic_value); pic_value pic_apply_trampoline(pic_state *, struct pic_proc *, pic_value);
pic_value pic_eval(pic_state *, pic_value, struct pic_env *); pic_value pic_eval(pic_state *, pic_value, struct pic_env *);
pic_value pic_expand(pic_state *, pic_value, struct pic_env *);
struct pic_proc *pic_compile(pic_state *, pic_value, struct pic_env *); struct pic_proc *pic_compile(pic_state *, pic_value, struct pic_env *);
struct pic_lib *pic_make_library(pic_state *, pic_value); struct pic_lib *pic_make_library(pic_state *, pic_value);

View File

@ -78,6 +78,8 @@ struct pic_irep {
size_t clen, ilen, plen, slen; size_t clen, ilen, plen, slen;
}; };
pic_sym *pic_resolve(pic_state *, pic_value, struct pic_env *);
pic_value pic_expand(pic_state *, pic_value, struct pic_env *);
pic_value pic_analyze(pic_state *, pic_value); pic_value pic_analyze(pic_state *, pic_value);
struct pic_irep *pic_codegen(pic_state *, pic_value); struct pic_irep *pic_codegen(pic_state *, pic_value);