From 91065a7c25e6363e68898dde59c3c7b66f4514ec Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 21 Mar 2014 08:20:33 +0900 Subject: [PATCH] add commentary to lambda analyzer to avoid regression --- src/codegen.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/codegen.c b/src/codegen.c index 6e396185..45018f0f 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -439,24 +439,25 @@ analyze_lambda(analyze_state *state, pic_value obj) size_t i; xh_iter it; - body = analyze(state, pic_cons(pic, pic_sym_value(pic->sBEGIN), pic_list_tail(pic, obj, 2)), true); - args = pic_nil_value(); for (i = scope->args.size; i > 0; --i) { var = xv_get(&scope->args, i - 1); pic_push(pic, pic_sym_value(*var), args); } + varg = scope->varg + ? pic_true_value() + : pic_false_value(); + + /* To know what kind of local variables are defined, analyze body at first. */ + body = analyze(state, pic_cons(pic, pic_sym_value(pic->sBEGIN), pic_list_tail(pic, obj, 2)), true); + locals = pic_nil_value(); for (i = scope->locals.size; i > 0; --i) { var = xv_get(&scope->locals, i - 1); pic_push(pic, pic_sym_value(*var), locals); } - varg = scope->varg - ? pic_true_value() - : pic_false_value(); - captures = pic_nil_value(); for (xh_begin(scope->captures, &it); ! xh_isend(&it); xh_next(&it)) { if (it.e->val == CAPTURED) {