From f6bc51d16de097baa8352e1f300901a181cd1f36 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 26 Nov 2013 08:36:58 -0800 Subject: [PATCH] add xlen/xcapa member to pic_senv --- include/picrin/macro.h | 1 + src/gc.c | 2 +- src/macro.c | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) 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); }