refactor pic_deflibrary macro. don't declare variables in for statements
This commit is contained in:
parent
ec87adb90b
commit
1b637d1763
|
@ -287,6 +287,8 @@ pic_callcc_callcc(pic_state *pic)
|
|||
void
|
||||
pic_init_callcc(pic_state *pic)
|
||||
{
|
||||
pic_redefun(pic, pic->PICRIN_BASE, "call-with-current-continuation", pic_callcc_callcc);
|
||||
pic_redefun(pic, pic->PICRIN_BASE, "call/cc", pic_callcc_callcc);
|
||||
pic_deflibrary (pic, "(scheme base)") {
|
||||
pic_redefun(pic, pic->PICRIN_BASE, "call-with-current-continuation", pic_callcc_callcc);
|
||||
pic_redefun(pic, pic->PICRIN_BASE, "call/cc", pic_callcc_callcc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ typedef struct {
|
|||
|
||||
pic_code *ip;
|
||||
|
||||
struct pic_lib *lib;
|
||||
struct pic_lib *lib, *prev_lib;
|
||||
|
||||
pic_sym *sDEFINE, *sLAMBDA, *sIF, *sBEGIN, *sQUOTE, *sSETBANG;
|
||||
pic_sym *sQUASIQUOTE, *sUNQUOTE, *sUNQUOTE_SPLICING;
|
||||
|
@ -208,11 +208,12 @@ struct pic_lib *pic_open_library(pic_state *, pic_value);
|
|||
struct pic_lib *pic_find_library(pic_state *, pic_value);
|
||||
|
||||
#define pic_deflibrary(pic, spec) \
|
||||
pic_deflibrary_helper_(pic, PIC_GENSYM(i), PIC_GENSYM(prev_lib), spec)
|
||||
#define pic_deflibrary_helper_(pic, i, prev_lib, spec) \
|
||||
for (int i = 0; ! i; ) \
|
||||
for (struct pic_lib *prev_lib; ! i; ) \
|
||||
for ((prev_lib = pic->lib), pic_open_library(pic, pic_read_cstr(pic, spec)), pic_in_library(pic, pic_read_cstr(pic, spec)); ! i++; pic->lib = prev_lib)
|
||||
for (((assert(pic->prev_lib == NULL)), \
|
||||
(pic->prev_lib = pic->lib), \
|
||||
(pic->lib = pic_open_library(pic, pic_read_cstr(pic, (spec))))); \
|
||||
pic->prev_lib != NULL; \
|
||||
((pic->lib = pic->prev_lib), \
|
||||
(pic->prev_lib = NULL)))
|
||||
|
||||
void pic_import(pic_state *, pic_value);
|
||||
void pic_import_library(pic_state *, struct pic_lib *);
|
||||
|
|
|
@ -176,6 +176,7 @@ pic_open(int argc, char *argv[], char **envp)
|
|||
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->lib = pic->PICRIN_USER;
|
||||
pic->prev_lib = NULL;
|
||||
|
||||
/* standard I/O */
|
||||
pic->xSTDIN = pic_make_standard_port(pic, xstdin, PIC_PORT_IN);
|
||||
|
|
|
@ -42,10 +42,10 @@ pic_init_picrin(pic_state *pic)
|
|||
|
||||
pic_deflibrary (pic, "(scheme base)") {
|
||||
pic_defun(pic, "features", pic_features);
|
||||
|
||||
pic_init_contrib(pic);
|
||||
pic_load_piclib(pic);
|
||||
}
|
||||
|
||||
pic_init_contrib(pic);
|
||||
pic_load_piclib(pic);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue