From 98662215e1010065ef8d2be3aecd3722abdebe2a Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 5 Aug 2015 09:42:17 +0900 Subject: [PATCH] use pic_reg to implement pic->macros --- extlib/benz/codegen.c | 12 ++++++------ extlib/benz/include/picrin.h | 2 +- extlib/benz/state.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extlib/benz/codegen.c b/extlib/benz/codegen.c index 1cfa5f19..b53b8173 100644 --- a/extlib/benz/codegen.c +++ b/extlib/benz/codegen.c @@ -54,26 +54,26 @@ pic_resolve(pic_state *pic, pic_value var, struct pic_env *env) static void 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_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 * 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 pic_proc_ptr(pic_dict_ref(pic, pic->macros, uid)); + return pic_proc_ptr(pic_reg_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); + if (pic_reg_has(pic, pic->macros, uid)) { + pic_reg_del(pic, pic->macros, uid); } } diff --git a/extlib/benz/include/picrin.h b/extlib/benz/include/picrin.h index f4ef47db..817fc03d 100644 --- a/extlib/benz/include/picrin.h +++ b/extlib/benz/include/picrin.h @@ -120,7 +120,7 @@ struct pic_state { khash_t(s) syms; /* name to symbol */ int ucnt; struct pic_reg *globals; - struct pic_dict *macros; + struct pic_reg *macros; pic_value libs; struct pic_reg *attrs; diff --git a/extlib/benz/state.c b/extlib/benz/state.c index 3cd3c895..8da412cf 100644 --- a/extlib/benz/state.c +++ b/extlib/benz/state.c @@ -408,7 +408,7 @@ pic_open(pic_allocf allocf, void *userdata) /* root tables */ pic->globals = pic_make_reg(pic); - pic->macros = pic_make_dict(pic); + pic->macros = pic_make_reg(pic); pic->attrs = pic_make_reg(pic); /* root block */