refactor pic_deflib

This commit is contained in:
Yuichi Nishiwaki 2014-03-02 22:23:57 +09:00
parent d168e7e1c8
commit 887b6a9f91
1 changed files with 5 additions and 14 deletions

View File

@ -179,22 +179,13 @@ void pic_in_library(pic_state *, pic_value);
struct pic_lib *pic_make_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); struct pic_lib *pic_find_library(pic_state *, pic_value);
#define PIC_DEFLIBRARY_HELPER2(tmp1, tmp2, tmp3, spec) \ #define pic_deflibrary_helper__(i, prev_lib, spec) \
for (struct pic_lib *tmp1 = pic->lib, \ for (int i = 0; ! i; ) \
*tmp2 = (pic_make_library(pic, pic_read(pic, spec)), \ for (struct pic_lib *prev_lib; ! i; ) \
pic_in_library(pic, pic_read(pic, spec)), \ for ((prev_lib = pic->lib), pic_make_library(pic, pic_read(pic, spec)), pic_in_library(pic, pic_read(pic, spec)); ! i++; pic->lib = prev_lib) \
NULL); \
tmp3 < 1; \
(pic->lib = tmp1), ((void)tmp2), ++tmp3)
#define PIC_DEFLIBRARY_HELPER1(tmp1, tmp2, spec) \
for (int tmp1 = 0, tmp2 = 0; tmp1 < 1; ++tmp1) \
PIC_DEFLIBRARY_HELPER2(GENSYM(pic_deflib_tmp3__), \
GENSYM(pic_deflib_tmp4__), \
tmp2, spec)
#define pic_deflibrary(spec) \ #define pic_deflibrary(spec) \
PIC_DEFLIBRARY_HELPER1(GENSYM(pic_deflib_tmp1__), GENSYM(pic_deflib_tmp2__), spec) pic_deflibrary_helper__(GENSYM(pic_deflib_i__), GENSYM(pic_deflib_prev_lib__), spec)
void pic_import(pic_state *, pic_value); void pic_import(pic_state *, pic_value);
void pic_export(pic_state *, pic_sym); void pic_export(pic_state *, pic_sym);