diff --git a/include/picrin/macro.h b/include/picrin/macro.h index 75257708..5dcf2c5d 100644 --- a/include/picrin/macro.h +++ b/include/picrin/macro.h @@ -6,6 +6,7 @@ struct pic_senv { struct pic_senv *up; struct xhash *tbl; struct pic_syntax **stx; + size_t xlen, xcapa; }; struct pic_syntax { diff --git a/src/gc.c b/src/gc.c index fc2f38f2..2264d5bc 100644 --- a/src/gc.c +++ b/src/gc.c @@ -287,7 +287,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) if (senv->stx) { int i; - for (i = 0; i < 6; ++i) { + for (i = 0; i < senv->xlen; ++i) { gc_mark_object(pic, (struct pic_object *)senv->stx[i]); } } diff --git a/src/macro.c b/src/macro.c index 84552119..cac35c3d 100644 --- a/src/macro.c +++ b/src/macro.c @@ -292,6 +292,8 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv) in->up = senv; in->tbl = xh_new(); in->stx = NULL; + in->xlen = 0; + in->xcapa = 0; for (a = var; pic_pair_p(a); a = pic_cdr(pic, a)) { pic_sym gen, orig; @@ -395,6 +397,8 @@ pic_macroexpand_2(pic_state *pic, pic_value expr) senv->up = NULL; senv->tbl = pic->var_tbl; senv->stx = pic->stx; + senv->xlen = pic->xlen; + senv->xcapa = pic->xcapa; return macroexpand(pic, expr, senv); }