diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-29 12:38:41 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-29 12:38:41 -0300 |
commit | 07db10813cb044252c18973688f63b5eac6a90a6 (patch) | |
tree | db08d5c25bbba80af51a719a9092062b5ea408b0 | |
parent | f96497397addca22f22a6ba6eeabc906be43f16b (diff) | |
download | lua-07db10813cb044252c18973688f63b5eac6a90a6.tar.gz lua-07db10813cb044252c18973688f63b5eac6a90a6.tar.bz2 lua-07db10813cb044252c18973688f63b5eac6a90a6.zip |
'OP_VARARG' has the vararg parameter as an operand
-rw-r--r-- | lopcodes.c | 4 | ||||
-rw-r--r-- | lopcodes.h | 6 | ||||
-rw-r--r-- | lparser.c | 5 | ||||
-rw-r--r-- | lvm.c | 4 |
4 files changed, 10 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.c,v 1.57 2017/04/26 17:46:52 roberto Exp roberto $ | 2 | ** $Id: lopcodes.c,v 1.58 2017/04/28 20:57:45 roberto Exp roberto $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -130,7 +130,7 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { | |||
130 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ | 130 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ |
131 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ | 131 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ |
132 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ | 132 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ |
133 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ | 133 | ,opmode(0, 1, OpArgU, OpArgR, iABC) /* OP_VARARG */ |
134 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ | 134 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ |
135 | }; | 135 | }; |
136 | 136 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.h,v 1.153 2017/04/28 20:57:45 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.154 2017/05/08 16:08:01 roberto Exp roberto $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -240,7 +240,7 @@ OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */ | |||
240 | 240 | ||
241 | OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */ | 241 | OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */ |
242 | 242 | ||
243 | OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */ | 243 | OP_VARARG,/* A B C R(A), R(A+1), ..., R(A+B-2) = vararg(C) */ |
244 | 244 | ||
245 | OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | 245 | OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ |
246 | } OpCode; | 246 | } OpCode; |
@@ -257,7 +257,7 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | |||
257 | OP_SETLIST) may use 'top'. | 257 | OP_SETLIST) may use 'top'. |
258 | 258 | ||
259 | (*) In OP_VARARG, if (B == 0) then use actual number of varargs and | 259 | (*) In OP_VARARG, if (B == 0) then use actual number of varargs and |
260 | set top (like in OP_CALL with C == 0). | 260 | set top (like in OP_CALL with C == 0). C is the vararg parameter. |
261 | 261 | ||
262 | (*) In OP_RETURN, if (B == 0) then return up to 'top'. | 262 | (*) In OP_RETURN, if (B == 0) then return up to 'top'. |
263 | 263 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.160 2017/06/27 11:35:31 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.161 2017/06/29 15:06:44 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -970,9 +970,10 @@ static void simpleexp (LexState *ls, expdesc *v) { | |||
970 | } | 970 | } |
971 | case TK_DOTS: { /* vararg */ | 971 | case TK_DOTS: { /* vararg */ |
972 | FuncState *fs = ls->fs; | 972 | FuncState *fs = ls->fs; |
973 | int lastparam = fs->f->numparams - 1; | ||
973 | check_condition(ls, fs->f->is_vararg, | 974 | check_condition(ls, fs->f->is_vararg, |
974 | "cannot use '...' outside a vararg function"); | 975 | "cannot use '...' outside a vararg function"); |
975 | init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); | 976 | init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, lastparam)); |
976 | break; | 977 | break; |
977 | } | 978 | } |
978 | case '{': { /* constructor */ | 979 | case '{': { /* constructor */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.287 2017/06/09 19:16:41 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.288 2017/06/29 15:06:44 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -1444,7 +1444,7 @@ void luaV_execute (lua_State *L) { | |||
1444 | } | 1444 | } |
1445 | vmcase(OP_VARARG) { | 1445 | vmcase(OP_VARARG) { |
1446 | int b = GETARG_B(i) - 1; /* required results */ | 1446 | int b = GETARG_B(i) - 1; /* required results */ |
1447 | TValue *vtab = s2v(base + cl->p->numparams - 1); /* vararg table */ | 1447 | TValue *vtab = vRC(i); /* vararg table */ |
1448 | Protect(luaT_getvarargs(L, vtab, ra, b)); | 1448 | Protect(luaT_getvarargs(L, vtab, ra, b)); |
1449 | vmbreak; | 1449 | vmbreak; |
1450 | } | 1450 | } |