select library during macroexpanding define-library
This commit is contained in:
parent
7cdcbd4604
commit
0f491adc73
13
src/macro.c
13
src/macro.c
|
@ -236,14 +236,19 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
switch (pic_syntax(car)->kind) {
|
switch (pic_syntax(car)->kind) {
|
||||||
case PIC_STX_DEFLIBRARY: {
|
case PIC_STX_DEFLIBRARY: {
|
||||||
pic_value program;
|
pic_value program;
|
||||||
struct pic_senv *senv;
|
struct pic_lib *prev = pic->lib, *lib;
|
||||||
|
|
||||||
senv = pic_minimal_syntactic_env(pic);
|
|
||||||
|
|
||||||
if (pic_length(pic, expr) < 2) {
|
if (pic_length(pic, expr) < 2) {
|
||||||
pic_error(pic, "syntax error");
|
pic_error(pic, "syntax error");
|
||||||
}
|
}
|
||||||
program = macroexpand_list(pic, pic_cddr(pic, expr), senv);
|
lib = pic_make_library(pic, pic_cadr(pic, expr));
|
||||||
|
|
||||||
|
/* macroexpand in new library */
|
||||||
|
pic_in_library(pic, pic_cadr(pic, expr));
|
||||||
|
{
|
||||||
|
program = macroexpand_list(pic, pic_cddr(pic, expr), lib->senv);
|
||||||
|
}
|
||||||
|
pic_in_library(pic, prev->name);
|
||||||
|
|
||||||
return pic_cons(pic, pic_symbol_value(pic->sBEGIN), program);
|
return pic_cons(pic, pic_symbol_value(pic->sBEGIN), program);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue