use dict for pic->macros

This commit is contained in:
Yuichi Nishiwaki 2017-04-04 02:32:20 +09:00
parent 42f378b20e
commit 889291049f
3 changed files with 8 additions and 8 deletions

View File

@ -133,27 +133,27 @@ pic_set_identifier(pic_state *pic, pic_value id, pic_value uid, pic_value env)
static void
define_macro(pic_state *pic, pic_value uid, pic_value mac)
{
if (pic_weak_has(pic, pic->macros, uid)) {
if (pic_dict_has(pic, pic->macros, uid)) {
pic_warnf(pic, "redefining syntax variable: %s", pic_sym(pic, uid));
}
pic_weak_set(pic, pic->macros, uid, mac);
pic_dict_set(pic, pic->macros, uid, mac);
}
static bool
find_macro(pic_state *pic, pic_value uid, pic_value *mac)
{
if (! pic_weak_has(pic, pic->macros, uid)) {
if (! pic_dict_has(pic, pic->macros, uid)) {
return false;
}
*mac = pic_weak_ref(pic, pic->macros, uid);
*mac = pic_dict_ref(pic, pic->macros, uid);
return true;
}
static void
shadow_macro(pic_state *pic, pic_value uid)
{
if (pic_weak_has(pic, pic->macros, uid)) {
pic_weak_del(pic, pic->macros, uid);
if (pic_dict_has(pic, pic->macros, uid)) {
pic_dict_del(pic, pic->macros, uid);
}
}

View File

@ -212,7 +212,7 @@ pic_open(pic_allocf allocf, void *userdata)
/* root tables */
pic->globals = pic_make_dict(pic);
pic->macros = pic_make_weak(pic);
pic->macros = pic_make_dict(pic);
pic->dyn_env = pic_list(pic, 1, pic_make_weak(pic));
/* turn on GC */

View File

@ -46,7 +46,7 @@ struct pic_state {
khash_t(oblist) oblist; /* string to symbol */
int ucnt;
pic_value globals; /* dict */
pic_value macros; /* weak */
pic_value macros; /* dict */
bool gc_enable;
struct heap *heap;