From 474a625349d26937f6b9fbc6e012b1bf248abfcf Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 7 Aug 2014 11:06:38 +0900 Subject: [PATCH 1/4] inline push_sym macro --- src/init.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/init.c b/src/init.c index c1b573db..8e9f933e 100644 --- a/src/init.c +++ b/src/init.c @@ -10,6 +10,20 @@ #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; +} + void pic_init_bool(pic_state *); void pic_init_pair(pic_state *); void pic_init_port(pic_state *); @@ -38,23 +52,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 From 7653cb4bb1b0e02009f106bb0814783daaaa7cee Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 7 Aug 2014 11:14:58 +0900 Subject: [PATCH 2/4] add libraries function --- src/init.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/init.c b/src/init.c index 8e9f933e..d9a48cf6 100644 --- a/src/init.c +++ b/src/init.c @@ -24,6 +24,20 @@ pic_features(pic_state *pic) 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 *); @@ -96,10 +110,12 @@ 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); + } + pic_deflibrary (pic, "(picrin library)") { + pic_defun(pic, "libraries", pic_libraries); } } From 97bb9085af036874cb92a07991a03675c333af65 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 7 Aug 2014 11:20:12 +0900 Subject: [PATCH 3/4] import (picrin library) to (picrin user) by default --- piclib/picrin/user.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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))) From d98cb495a372374ec8d7c98e943ad0521121d8db Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 7 Aug 2014 11:20:28 +0900 Subject: [PATCH 4/4] [bugfix] define standard functions before loading piclibs --- src/init.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/init.c b/src/init.c index d9a48cf6..48601882 100644 --- a/src/init.c +++ b/src/init.c @@ -83,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; @@ -111,11 +117,5 @@ pic_init_core(pic_state *pic) pic_load_piclib(pic); DONE; pic_init_contrib(pic); DONE; - - pic_defun(pic, "features", pic_features); - } - - pic_deflibrary (pic, "(picrin library)") { - pic_defun(pic, "libraries", pic_libraries); } }