add pic_define_noexport

This commit is contained in:
Yuichi Nishiwaki 2014-09-16 00:21:24 +09:00
parent 597e000000
commit 7db18677ab
2 changed files with 10 additions and 5 deletions

View File

@ -143,7 +143,8 @@ void pic_close(pic_state *);
void pic_add_feature(pic_state *, const char *); 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_defun(pic_state *, const char *, pic_func_t);
void pic_defvar(pic_state *, const char *, pic_value, struct pic_proc *); void pic_defvar(pic_state *, const char *, pic_value, struct pic_proc *);

12
vm.c
View File

@ -405,7 +405,7 @@ pic_get_args(pic_state *pic, const char *format, ...)
} }
void 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; pic_sym sym, rename;
@ -417,11 +417,15 @@ pic_define(pic_state *pic, const char *name, pic_value val)
pic_warn(pic, "redefining global"); pic_warn(pic, "redefining global");
} }
/* push to the global arena */
xh_put_int(&pic->globals, rename, &val); xh_put_int(&pic->globals, rename, &val);
}
/* export! */ void
pic_export(pic, sym); 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 pic_value