diff --git a/piclib/picrin/user.scm b/piclib/picrin/user.scm index 5121ddc3..fd1190ff 100644 --- a/piclib/picrin/user.scm +++ b/piclib/picrin/user.scm @@ -13,4 +13,5 @@ (scheme time) (picrin macro) (picrin dictionary) - (picrin array))) + (picrin array) + (picrin library))) diff --git a/src/init.c b/src/init.c index c1b573db..48601882 100644 --- a/src/init.c +++ b/src/init.c @@ -10,6 +10,34 @@ #include "picrin/macro.h" #include "picrin/error.h" +static pic_value +pic_features(pic_state *pic) +{ + pic_value features = pic_nil_value(); + + pic_get_args(pic, ""); + + pic_push(pic, pic_sym_value(pic_intern_cstr(pic, "r7rs")), features); + pic_push(pic, pic_sym_value(pic_intern_cstr(pic, "ieee-float")), features); + pic_push(pic, pic_sym_value(pic_intern_cstr(pic, "picrin")), features); + + return features; +} + +static pic_value +pic_libraries(pic_state *pic) +{ + pic_value libs = pic_nil_value(), lib; + + pic_get_args(pic, ""); + + pic_for_each (lib, pic->libs) { + libs = pic_cons(pic, pic_car(pic, lib), libs); + } + + return libs; +} + void pic_init_bool(pic_state *); void pic_init_pair(pic_state *); void pic_init_port(pic_state *); @@ -38,23 +66,6 @@ void pic_init_contrib(pic_state *); void pic_load_piclib(pic_state *); -#define push_sym(pic, name, list) \ - pic_push(pic, pic_symbol_value(pic_intern_cstr(pic, name)), list) - -static pic_value -pic_features(pic_state *pic) -{ - pic_value features = pic_nil_value(); - - pic_get_args(pic, ""); - - push_sym(pic, "r7rs", features); - push_sym(pic, "ieee-float", features); - push_sym(pic, "picrin", features); - - return features; -} - #define DONE pic_gc_arena_restore(pic, ai); void @@ -72,7 +83,13 @@ pic_init_core(pic_state *pic) pic_define_syntactic_keyword(pic, pic->lib->env, pic->sDEFINE_SYNTAX, pic->rDEFINE_SYNTAX); } + pic_deflibrary (pic, "(picrin library)") { + pic_defun(pic, "libraries", pic_libraries); + } + pic_deflibrary (pic, "(scheme base)") { + pic_defun(pic, "features", pic_features); + pic_init_bool(pic); DONE; pic_init_pair(pic); DONE; pic_init_port(pic); DONE; @@ -99,10 +116,6 @@ pic_init_core(pic_state *pic) pic_init_lib(pic); DONE; pic_load_piclib(pic); DONE; - pic_init_contrib(pic); DONE; - - pic_defun(pic, "features", pic_features); - } }