This commit is contained in:
Yuichi Nishiwaki 2015-06-22 17:41:17 +09:00
parent e730a314f4
commit aa79797334
1 changed files with 10 additions and 0 deletions

View File

@ -66,6 +66,14 @@ find_macro(pic_state *pic, pic_sym *uid)
return pic_proc_ptr(pic_dict_ref(pic, pic->macros, uid)); return pic_proc_ptr(pic_dict_ref(pic, pic->macros, uid));
} }
static void
shadow_macro(pic_state *pic, pic_sym *uid)
{
if (pic_dict_has(pic, pic->macros, uid)) {
pic_dict_del(pic, pic->macros, uid);
}
}
static pic_value expand(pic_state *, pic_value, struct pic_env *, pic_value); static pic_value expand(pic_state *, pic_value, struct pic_env *, pic_value);
static pic_value expand_lambda(pic_state *, pic_value, struct pic_env *); static pic_value expand_lambda(pic_state *, pic_value, struct pic_env *);
@ -190,6 +198,8 @@ expand_define(pic_state *pic, pic_value expr, struct pic_env *env, pic_value def
} }
if ((uid = pic_find_variable(pic, env, var)) == NULL) { if ((uid = pic_find_variable(pic, env, var)) == NULL) {
uid = pic_add_variable(pic, env, var); uid = pic_add_variable(pic, env, var);
} else {
shadow_macro(pic, uid);
} }
val = expand(pic, pic_list_ref(pic, expr, 2), env, deferred); val = expand(pic, pic_list_ref(pic, expr, 2), env, deferred);