use pic_reg to implement pic->macros
This commit is contained in:
parent
5fa24f9767
commit
98662215e1
|
@ -54,26 +54,26 @@ pic_resolve(pic_state *pic, pic_value var, struct pic_env *env)
|
||||||
static void
|
static void
|
||||||
define_macro(pic_state *pic, pic_sym *uid, struct pic_proc *mac)
|
define_macro(pic_state *pic, pic_sym *uid, struct pic_proc *mac)
|
||||||
{
|
{
|
||||||
if (pic_dict_has(pic, pic->macros, uid)) {
|
if (pic_reg_has(pic, pic->macros, uid)) {
|
||||||
pic_warnf(pic, "redefining syntax variable: ~s", pic_obj_value(uid));
|
pic_warnf(pic, "redefining syntax variable: ~s", pic_obj_value(uid));
|
||||||
}
|
}
|
||||||
pic_dict_set(pic, pic->macros, uid, pic_obj_value(mac));
|
pic_reg_set(pic, pic->macros, uid, pic_obj_value(mac));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pic_proc *
|
static struct pic_proc *
|
||||||
find_macro(pic_state *pic, pic_sym *uid)
|
find_macro(pic_state *pic, pic_sym *uid)
|
||||||
{
|
{
|
||||||
if (! pic_dict_has(pic, pic->macros, uid)) {
|
if (! pic_reg_has(pic, pic->macros, uid)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return pic_proc_ptr(pic_dict_ref(pic, pic->macros, uid));
|
return pic_proc_ptr(pic_reg_ref(pic, pic->macros, uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shadow_macro(pic_state *pic, pic_sym *uid)
|
shadow_macro(pic_state *pic, pic_sym *uid)
|
||||||
{
|
{
|
||||||
if (pic_dict_has(pic, pic->macros, uid)) {
|
if (pic_reg_has(pic, pic->macros, uid)) {
|
||||||
pic_dict_del(pic, pic->macros, uid);
|
pic_reg_del(pic, pic->macros, uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ struct pic_state {
|
||||||
khash_t(s) syms; /* name to symbol */
|
khash_t(s) syms; /* name to symbol */
|
||||||
int ucnt;
|
int ucnt;
|
||||||
struct pic_reg *globals;
|
struct pic_reg *globals;
|
||||||
struct pic_dict *macros;
|
struct pic_reg *macros;
|
||||||
pic_value libs;
|
pic_value libs;
|
||||||
struct pic_reg *attrs;
|
struct pic_reg *attrs;
|
||||||
|
|
||||||
|
|
|
@ -408,7 +408,7 @@ pic_open(pic_allocf allocf, void *userdata)
|
||||||
|
|
||||||
/* root tables */
|
/* root tables */
|
||||||
pic->globals = pic_make_reg(pic);
|
pic->globals = pic_make_reg(pic);
|
||||||
pic->macros = pic_make_dict(pic);
|
pic->macros = pic_make_reg(pic);
|
||||||
pic->attrs = pic_make_reg(pic);
|
pic->attrs = pic_make_reg(pic);
|
||||||
|
|
||||||
/* root block */
|
/* root block */
|
||||||
|
|
Loading…
Reference in New Issue