Merge branch 'master' of github.com:picrin-scheme/picrin

This commit is contained in:
Sunrim KIM (keen) 2015-05-31 14:25:22 +09:00
commit 7b26e6cefe
4 changed files with 13 additions and 15 deletions

View File

@ -49,7 +49,7 @@ src/init_contrib.c:
lib/libbenz.a: $(BENZ_OBJS)
$(AR) $(ARFLAGS) $@ $(BENZ_OBJS)
%.o: extlib/benz/include/picrin.h extlib/benz/include/picrin/*.h
$(PICRIN_OBJS) $(CONTRIB_OBJS): extlib/benz/include/picrin.h extlib/benz/include/picrin/*.h
doc: docs/*.rst docs/contrib.rst
$(MAKE) -C docs html

View File

@ -203,13 +203,16 @@ struct pic_proc *pic_compile(pic_state *, pic_value, struct pic_lib *);
pic_value pic_macroexpand(pic_state *, pic_value, struct pic_lib *);
void pic_in_library(pic_state *, pic_value);
struct pic_lib *pic_open_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);
#define pic_deflibrary(pic, spec) \
for (((assert(pic->prev_lib == NULL)), \
(pic->prev_lib = pic->lib), \
(pic->lib = pic_open_library(pic, pic_read_cstr(pic, (spec))))); \
(pic->lib = pic_find_library(pic, pic_read_cstr(pic, (spec)))), \
(pic->lib = pic->lib \
? pic->lib \
: pic_make_library(pic, pic_read_cstr(pic, (spec))))); \
pic->prev_lib != NULL; \
((pic->lib = pic->prev_lib), \
(pic->prev_lib = NULL)))

View File

@ -5,21 +5,14 @@
#include "picrin.h"
struct pic_lib *
pic_open_library(pic_state *pic, pic_value name)
pic_make_library(pic_state *pic, pic_value name)
{
struct pic_lib *lib;
struct pic_env *env;
struct pic_dict *exports;
if ((lib = pic_find_library(pic, name)) != NULL) {
#if DEBUG
printf("* reopen library: ");
pic_debug(pic, name);
puts("");
#endif
return lib;
pic_errorf(pic, "library name already in use: ~s", name);
}
env = pic_null_syntactic_environment(pic);
@ -295,7 +288,9 @@ pic_lib_define_library(pic_state *pic)
pic_get_args(pic, "o*", &spec, &argc, &argv);
pic_open_library(pic, spec);
if (! pic_find_library(pic, spec)) {
pic_make_library(pic, spec);
}
pic_try {
pic_in_library(pic, spec);

View File

@ -322,8 +322,8 @@ pic_open(int argc, char *argv[], char **envp, pic_allocf allocf)
pic->xSTDERR = pic_make_standard_port(pic, xstderr, PIC_PORT_OUT);
/* standard libraries */
pic->PICRIN_BASE = pic_open_library(pic, pic_read_cstr(pic, "(picrin base)"));
pic->PICRIN_USER = pic_open_library(pic, pic_read_cstr(pic, "(picrin user)"));
pic->PICRIN_BASE = pic_make_library(pic, pic_read_cstr(pic, "(picrin base)"));
pic->PICRIN_USER = pic_make_library(pic, pic_read_cstr(pic, "(picrin user)"));
pic->lib = pic->PICRIN_USER;
pic->prev_lib = NULL;