diff --git a/include/picrin.h b/include/picrin.h index 80f7f7e8..7130e470 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -123,8 +123,8 @@ pic_value pic_apply_argv(pic_state *pic, struct pic_proc *, size_t, ...); struct pic_proc *pic_codegen(pic_state *, pic_value); pic_value pic_macroexpand(pic_state *, pic_value); -void pic_make_library(pic_state *, pic_value); void pic_in_library(pic_state *, pic_value); +struct pic_lib *pic_make_library(pic_state *, pic_value); struct pic_lib *pic_find_library(pic_state *, pic_value); void pic_abort(pic_state *, const char *); diff --git a/src/lib.c b/src/lib.c index 3fbcdba4..a99bdf70 100644 --- a/src/lib.c +++ b/src/lib.c @@ -4,7 +4,7 @@ #include "picrin/macro.h" #include "xhash/xhash.h" -void +struct pic_lib * pic_make_library(pic_state *pic, pic_value name) { struct pic_lib *lib; @@ -13,7 +13,10 @@ pic_make_library(pic_state *pic, pic_value name) lib->senv = pic_core_syntactic_env(pic); lib->exports = xh_new(); + /* register! */ pic->lib_tbl = pic_acons(pic, name, pic_obj_value(lib), pic->lib_tbl); + + return lib; } void diff --git a/src/state.c b/src/state.c index 9afa08c1..a75fe04a 100644 --- a/src/state.c +++ b/src/state.c @@ -119,8 +119,8 @@ pic_open(int argc, char *argv[], char **envp) pic_gc_arena_restore(pic, ai); /* set library */ - pic_make_library(pic, pic_symbol_value(pic_intern_cstr(pic, "user"))); - pic_in_library(pic, pic_symbol_value(pic_intern_cstr(pic, "user"))); + pic_make_library(pic, pic_parse(pic, "user")); + pic_in_library(pic, pic_parse(pic, "user")); pic_init_core(pic);