pic_open_library -> pic_make_library
This commit is contained in:
parent
5092affcfc
commit
15e61d8cd4
2
Makefile
2
Makefile
|
@ -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
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue