diff --git a/extlib/benz/codegen.c b/extlib/benz/codegen.c index d4f2c187..1cfa5f19 100644 --- a/extlib/benz/codegen.c +++ b/extlib/benz/codegen.c @@ -436,7 +436,7 @@ define_var(pic_state *pic, analyze_scope *scope, pic_sym *sym) int ret; if (search_scope(scope, sym)) { - if (scope->depth > 0 || (pic_dict_has(pic, pic->globals, sym) && ! pic_invalid_p(pic_box_ptr(pic_dict_ref(pic, pic->globals, sym))->value))) { + if (scope->depth > 0 || (pic_reg_has(pic, pic->globals, sym) && ! pic_invalid_p(pic_box_ptr(pic_reg_ref(pic, pic->globals, sym))->value))) { pic_warnf(pic, "redefining variable: ~s", pic_obj_value(sym)); } return; diff --git a/extlib/benz/gc.c b/extlib/benz/gc.c index a7096cca..30c36bab 100644 --- a/extlib/benz/gc.c +++ b/extlib/benz/gc.c @@ -484,6 +484,7 @@ gc_mark_phase(pic_state *pic) M(uDEFINE); M(uLAMBDA); M(uIF); M(uBEGIN); M(uQUOTE); M(uSETBANG); M(uDEFINE_MACRO); M(uDEFINE_LIBRARY); M(uIMPORT); M(uEXPORT); M(uCOND_EXPAND); + M(uCONS); M(uCAR); M(uCDR); M(uNILP); M(uSYMBOLP); M(uPAIRP); M(uADD); M(uSUB); M(uMUL); M(uDIV); M(uEQ); M(uLT); M(uLE); M(uGT); M(uGE); M(uNOT); @@ -491,6 +492,9 @@ gc_mark_phase(pic_state *pic) P(pCONS); P(pCAR); P(pCDR); P(pNILP); P(pSYMBOLP); P(pPAIRP); P(pNOT); P(pADD); P(pSUB); P(pMUL); P(pDIV); P(pEQ); P(pLT); P(pLE); P(pGT); P(pGE); + M(cCONS); M(cCAR); M(cCDR); M(cNILP); M(cSYMBOLP); M(cPAIRP); M(cNOT); + M(cADD); M(cSUB); M(cMUL); M(cDIV); M(cEQ); M(cLT); M(cLE); M(cGT); M(cGE); + /* global variables */ if (pic->globals) { gc_mark_object(pic, (union object *)pic->globals); diff --git a/extlib/benz/include/picrin.h b/extlib/benz/include/picrin.h index 50737ea3..f4ef47db 100644 --- a/extlib/benz/include/picrin.h +++ b/extlib/benz/include/picrin.h @@ -119,7 +119,7 @@ struct pic_state { khash_t(s) syms; /* name to symbol */ int ucnt; - struct pic_dict *globals; + struct pic_reg *globals; struct pic_dict *macros; pic_value libs; struct pic_reg *attrs; diff --git a/extlib/benz/state.c b/extlib/benz/state.c index 86f3d88a..3cd3c895 100644 --- a/extlib/benz/state.c +++ b/extlib/benz/state.c @@ -407,7 +407,7 @@ pic_open(pic_allocf allocf, void *userdata) pic->pGE = pic_invalid_value(); /* root tables */ - pic->globals = pic_make_dict(pic); + pic->globals = pic_make_reg(pic); pic->macros = pic_make_dict(pic); pic->attrs = pic_make_reg(pic); diff --git a/extlib/benz/vm.c b/extlib/benz/vm.c index 2f291111..dda6de12 100644 --- a/extlib/benz/vm.c +++ b/extlib/benz/vm.c @@ -387,15 +387,15 @@ pic_get_args(pic_state *pic, const char *format, ...) } struct pic_box * -pic_vm_gref_slot(pic_state *pic, pic_sym *uid) +pic_vm_gref_slot(pic_state *pic, pic_sym *uid) /* TODO: make this static */ { struct pic_box *box; - if (pic_dict_has(pic, pic->globals, uid)) { - return pic_box_ptr(pic_dict_ref(pic, pic->globals, uid)); + if (pic_reg_has(pic, pic->globals, uid)) { + return pic_box_ptr(pic_reg_ref(pic, pic->globals, uid)); } box = pic_box(pic, pic_invalid_value()); - pic_dict_set(pic, pic->globals, uid, pic_obj_value(box)); + pic_reg_set(pic, pic->globals, uid, pic_obj_value(box)); return box; } @@ -1112,7 +1112,7 @@ pic_define_(pic_state *pic, const char *name, pic_value val) if ((uid = pic_find_variable(pic, pic->lib->env, pic_obj_value(sym))) == NULL) { uid = pic_add_variable(pic, pic->lib->env, pic_obj_value(sym)); } else { - if (pic_dict_has(pic, pic->globals, uid)) { + if (pic_reg_has(pic, pic->globals, uid)) { pic_warnf(pic, "redefining variable: ~s", pic_obj_value(uid)); } }