From 7db18677ab4b3038c66d25f1ad4525c0aef8a18e Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 16 Sep 2014 00:21:24 +0900 Subject: [PATCH] add pic_define_noexport --- include/picrin.h | 3 ++- vm.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/picrin.h b/include/picrin.h index 0a6ce023..e34e7659 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -143,7 +143,8 @@ void pic_close(pic_state *); void pic_add_feature(pic_state *, const char *); -void pic_define(pic_state *, const char *, pic_value); /* automatic export */ +void pic_define(pic_state *, const char *, pic_value); +void pic_define_noexport(pic_state *, const char *, pic_value); void pic_defun(pic_state *, const char *, pic_func_t); void pic_defvar(pic_state *, const char *, pic_value, struct pic_proc *); diff --git a/vm.c b/vm.c index 15d0eb93..72ea96d0 100644 --- a/vm.c +++ b/vm.c @@ -405,7 +405,7 @@ pic_get_args(pic_state *pic, const char *format, ...) } void -pic_define(pic_state *pic, const char *name, pic_value val) +pic_define_noexport(pic_state *pic, const char *name, pic_value val) { pic_sym sym, rename; @@ -417,11 +417,15 @@ pic_define(pic_state *pic, const char *name, pic_value val) pic_warn(pic, "redefining global"); } - /* push to the global arena */ xh_put_int(&pic->globals, rename, &val); +} - /* export! */ - pic_export(pic, sym); +void +pic_define(pic_state *pic, const char *name, pic_value val) +{ + pic_define_noexport(pic, name, val); + + pic_export(pic, pic_intern_cstr(pic, name)); } pic_value