From 942e053cde8c80550e6d49c13cf699ac3f48cb08 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 20 Feb 2014 18:00:30 +0900 Subject: [PATCH] compile values in tail position --- src/codegen.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/codegen.c b/src/codegen.c index d55996c4..d0eab6d2 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -88,6 +88,7 @@ typedef struct analyze_state { pic_sym rCONS, rCAR, rCDR, rNILP; pic_sym rADD, rSUB, rMUL, rDIV; pic_sym rEQ, rLT, rLE, rGT, rGE, rNOT; + pic_sym rVALUES; pic_sym sCALL, sTAILCALL, sREF, sRETURN; } analyze_state; @@ -134,6 +135,7 @@ new_analyze_state(pic_state *pic) register_renamed_symbol(pic, state, rGT, stdlib, ">"); register_renamed_symbol(pic, state, rGE, stdlib, ">="); register_renamed_symbol(pic, state, rNOT, stdlib, "not"); + register_renamed_symbol(pic, state, rVALUES, stdlib, "values"); register_symbol(pic, state, sCALL, "call"); register_symbol(pic, state, sTAILCALL, "tail-call"); @@ -540,6 +542,15 @@ analyze_node(analyze_state *state, pic_value obj, bool tailpos) ARGC_ASSERT(1); return CONSTRUCT_OP1(pic->sNOT); } + else if (sym == state->rVALUES && tailpos) { + pic_value v, seq; + + seq = pic_list(pic, 1, pic_symbol_value(state->sRETURN)); + pic_for_each (v, pic_cdr(pic, obj)) { + seq = pic_cons(pic, analyze(state, v, false), seq); + } + return pic_reverse(pic, seq); + } } return analyze_call(state, obj, tailpos); }