global variable accessors don't require library object
This commit is contained in:
parent
dbf73ecd7a
commit
6b808354c0
|
@ -97,9 +97,9 @@ void pic_gc_arena_restore(pic_state *, int);
|
|||
pic_state *pic_open(int argc, char *argv[], char **envp);
|
||||
void pic_close(pic_state *);
|
||||
|
||||
void pic_define(pic_state *, struct pic_lib *, const char *, pic_value); /* symbol is automatically exported */
|
||||
pic_value pic_ref(pic_state *, struct pic_lib *, const char *);
|
||||
pic_value pic_set(pic_state *, struct pic_lib *, const char *, pic_value);
|
||||
void pic_define(pic_state *, const char *, pic_value); /* symbol is automatically exported */
|
||||
pic_value pic_ref(pic_state *, const char *);
|
||||
void pic_set(pic_state *, const char *, pic_value);
|
||||
|
||||
struct pic_proc *pic_get_proc(pic_state *);
|
||||
int pic_get_args(pic_state *, const char *, ...);
|
||||
|
|
|
@ -932,11 +932,10 @@ pic_codegen(pic_state *pic, pic_value obj)
|
|||
}
|
||||
|
||||
void
|
||||
pic_define(pic_state *pic, struct pic_lib *lib, const char *name, pic_value val)
|
||||
pic_define(pic_state *pic, const char *name, pic_value val)
|
||||
{
|
||||
int idx;
|
||||
pic_sym gsym;
|
||||
struct pic_lib *lib2;
|
||||
|
||||
gsym = pic_gensym(pic, pic_intern_cstr(pic, name));
|
||||
|
||||
|
@ -945,15 +944,10 @@ pic_define(pic_state *pic, struct pic_lib *lib, const char *name, pic_value val)
|
|||
pic->globals[idx] = val;
|
||||
|
||||
/* register to the senv */
|
||||
xh_put(lib->senv->tbl, name, gsym);
|
||||
xh_put(pic->lib->senv->tbl, name, gsym);
|
||||
|
||||
/* export! */
|
||||
lib2 = pic->lib;
|
||||
{
|
||||
pic->lib = lib;
|
||||
pic_export(pic, pic_intern_cstr(pic, name));
|
||||
pic->lib = lib2;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
4
src/vm.c
4
src/vm.c
|
@ -307,7 +307,7 @@ pic_defun(pic_state *pic, const char *name, pic_func_t cfunc)
|
|||
struct pic_proc *proc;
|
||||
|
||||
proc = pic_proc_new(pic, cfunc);
|
||||
pic_define(pic, pic->lib, name, pic_obj_value(proc));
|
||||
pic_define(pic, name, pic_obj_value(proc));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -316,7 +316,7 @@ pic_defvar(pic_state *pic, const char *name, pic_value init)
|
|||
struct pic_var *var;
|
||||
|
||||
var = pic_var_new(pic, init, NULL);
|
||||
pic_define(pic, pic->lib, name, pic_obj_value(pic_wrap_var(pic, var)));
|
||||
pic_define(pic, name, pic_obj_value(pic_wrap_var(pic, var)));
|
||||
}
|
||||
|
||||
pic_value
|
||||
|
|
Loading…
Reference in New Issue