From e9ef7ed2d3015ff6083ae51995b153b88837b64d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 21 Mar 2002 17:32:22 -0300 Subject: first implementation for tail call --- lparser.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lparser.c') diff --git a/lparser.c b/lparser.c index f03475e8..5148267d 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 1.170 2002/03/14 18:32:37 roberto Exp roberto $ +** $Id: lparser.c,v 1.171 2002/03/18 14:49:46 roberto Exp roberto $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -1209,6 +1209,10 @@ static void retstat (LexState *ls) { else { nret = explist1(ls, &e); /* optional return values */ if (e.k == VCALL) { + if (nret == 1) { /* tail call? */ + SET_OPCODE(getcode(fs,&e), OP_TAILCALL); + return; + } luaK_setcallreturns(fs, &e, LUA_MULTRET); first = fs->nactloc; nret = LUA_MULTRET; /* return all values */ -- cgit v1.2.3-55-g6feb