aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/lcode.c b/lcode.c
index 7f240580..25fb0770 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.151 2018/01/27 16:56:33 roberto Exp roberto $ 2** $Id: lcode.c,v 2.152 2018/01/28 15:13:26 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -31,7 +31,7 @@
31 31
32 32
33/* Maximum number of registers in a Lua function (must fit in 8 bits) */ 33/* Maximum number of registers in a Lua function (must fit in 8 bits) */
34#define MAXREGS 255 34#define MAXREGS 254
35 35
36 36
37#define hasjumps(e) ((e)->t != (e)->f) 37#define hasjumps(e) ((e)->t != (e)->f)
@@ -157,17 +157,17 @@ int luaK_jump (FuncState *fs) {
157** Code a 'return' instruction 157** Code a 'return' instruction
158*/ 158*/
159void luaK_ret (FuncState *fs, int first, int nret) { 159void luaK_ret (FuncState *fs, int first, int nret) {
160 switch (nret) { 160 OpCode op;
161 case 0: 161 if (fs->f->is_vararg)
162 luaK_codeABC(fs, OP_RETURN0, 0, 0, 0); 162 op = OP_RETVARARG;
163 break; 163 else {
164 case 1: 164 switch (nret) {
165 luaK_codeABC(fs, OP_RETURN1, first, 0, 0); 165 case 0: op = OP_RETURN0; break;
166 break; 166 case 1: op = OP_RETURN1; break;
167 default: 167 default: op = OP_RETURN; break;
168 luaK_codeABC(fs, OP_RETURN, first, nret + 1, 0); 168 }
169 break;
170 } 169 }
170 luaK_codeABC(fs, op, first, nret + 1, fs->f->numparams);
171} 171}
172 172
173 173
@@ -1647,7 +1647,7 @@ void luaK_finish (FuncState *fs) {
1647 lua_assert(i == 0 || isOT(*(pc - 1)) == isIT(*pc)); 1647 lua_assert(i == 0 || isOT(*(pc - 1)) == isIT(*pc));
1648 switch (GET_OPCODE(*pc)) { 1648 switch (GET_OPCODE(*pc)) {
1649 case OP_RETURN: case OP_RETURN0: case OP_RETURN1: 1649 case OP_RETURN: case OP_RETURN0: case OP_RETURN1:
1650 case OP_TAILCALL: { 1650 case OP_RETVARARG: case OP_TAILCALL: {
1651 if (p->sizep > 0) 1651 if (p->sizep > 0)
1652 SETARG_k(*pc, 1); /* signal that they must close upvalues */ 1652 SETARG_k(*pc, 1); /* signal that they must close upvalues */
1653 break; 1653 break;