Revert "change APIs of library functions"
This reverts commit 0115ede4de.
Conflicts:
include/picrin.h
This commit is contained in:
@@ -4,42 +4,27 @@
|
||||
#include "picrin/macro.h"
|
||||
#include "xhash/xhash.h"
|
||||
|
||||
static pic_value
|
||||
lib_spec(pic_state *pic, const char *name)
|
||||
{
|
||||
pic_value vs;
|
||||
int r;
|
||||
|
||||
r = pic_parse_cstr(pic, name, &vs);
|
||||
if (r != 1) {
|
||||
pic_error(pic, "invalid library spec given");
|
||||
}
|
||||
return pic_car(pic, vs);
|
||||
}
|
||||
|
||||
void
|
||||
pic_make_library(pic_state *pic, const char *name)
|
||||
pic_make_library(pic_state *pic, pic_value name)
|
||||
{
|
||||
struct pic_lib *lib;
|
||||
pic_value spec = lib_spec(pic, name);
|
||||
|
||||
lib = (struct pic_lib *)pic_obj_alloc(pic, sizeof(struct pic_lib), PIC_TT_LIB);
|
||||
lib->senv = pic_core_syntactic_env(pic);
|
||||
lib->exports = xh_new();
|
||||
|
||||
pic->lib_tbl = pic_acons(pic, spec, pic_obj_value(lib), pic->lib_tbl);
|
||||
pic->lib_tbl = pic_acons(pic, name, pic_obj_value(lib), pic->lib_tbl);
|
||||
}
|
||||
|
||||
void
|
||||
pic_in_library(pic_state *pic, const char *name)
|
||||
pic_in_library(pic_state *pic, pic_value name)
|
||||
{
|
||||
pic_value v, spec = lib_spec(pic, name);
|
||||
pic_value v;
|
||||
|
||||
v = pic_assoc(pic, spec, pic->lib_tbl);
|
||||
v = pic_assoc(pic, name, pic->lib_tbl);
|
||||
if (pic_false_p(v)) {
|
||||
pic_error(pic, "library not found");
|
||||
}
|
||||
|
||||
pic->lib = pic_lib_ptr(pic_cdr(pic, v));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -119,8 +119,8 @@ pic_open(int argc, char *argv[], char **envp)
|
||||
pic_gc_arena_restore(pic, ai);
|
||||
|
||||
/* set library */
|
||||
pic_make_library(pic, "user");
|
||||
pic_in_library(pic, "user");
|
||||
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_init_core(pic);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user