'OP_VARARG' has the vararg parameter as an operand
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lopcodes.c,v 1.57 2017/04/26 17:46:52 roberto Exp roberto $
|
** $Id: lopcodes.c,v 1.58 2017/04/28 20:57:45 roberto Exp roberto $
|
||||||
** Opcodes for Lua virtual machine
|
** Opcodes for Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -130,7 +130,7 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
|
|||||||
,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */
|
,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */
|
||||||
,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
|
,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
|
||||||
,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
|
,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
|
||||||
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
|
,opmode(0, 1, OpArgU, OpArgR, iABC) /* OP_VARARG */
|
||||||
,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */
|
,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lopcodes.h,v 1.153 2017/04/28 20:57:45 roberto Exp roberto $
|
** $Id: lopcodes.h,v 1.154 2017/05/08 16:08:01 roberto Exp roberto $
|
||||||
** Opcodes for Lua virtual machine
|
** Opcodes for Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -240,7 +240,7 @@ OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
|
|||||||
|
|
||||||
OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */
|
OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */
|
||||||
|
|
||||||
OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */
|
OP_VARARG,/* A B C R(A), R(A+1), ..., R(A+B-2) = vararg(C) */
|
||||||
|
|
||||||
OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
|
OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
|
||||||
} OpCode;
|
} OpCode;
|
||||||
@@ -257,7 +257,7 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
|
|||||||
OP_SETLIST) may use 'top'.
|
OP_SETLIST) may use 'top'.
|
||||||
|
|
||||||
(*) In OP_VARARG, if (B == 0) then use actual number of varargs and
|
(*) In OP_VARARG, if (B == 0) then use actual number of varargs and
|
||||||
set top (like in OP_CALL with C == 0).
|
set top (like in OP_CALL with C == 0). C is the vararg parameter.
|
||||||
|
|
||||||
(*) In OP_RETURN, if (B == 0) then return up to 'top'.
|
(*) In OP_RETURN, if (B == 0) then return up to 'top'.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 2.160 2017/06/27 11:35:31 roberto Exp roberto $
|
** $Id: lparser.c,v 2.161 2017/06/29 15:06:44 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -970,9 +970,10 @@ static void simpleexp (LexState *ls, expdesc *v) {
|
|||||||
}
|
}
|
||||||
case TK_DOTS: { /* vararg */
|
case TK_DOTS: { /* vararg */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
|
int lastparam = fs->f->numparams - 1;
|
||||||
check_condition(ls, fs->f->is_vararg,
|
check_condition(ls, fs->f->is_vararg,
|
||||||
"cannot use '...' outside a vararg function");
|
"cannot use '...' outside a vararg function");
|
||||||
init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
|
init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, lastparam));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '{': { /* constructor */
|
case '{': { /* constructor */
|
||||||
|
|||||||
4
lvm.c
4
lvm.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 2.287 2017/06/09 19:16:41 roberto Exp roberto $
|
** $Id: lvm.c,v 2.288 2017/06/29 15:06:44 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -1444,7 +1444,7 @@ void luaV_execute (lua_State *L) {
|
|||||||
}
|
}
|
||||||
vmcase(OP_VARARG) {
|
vmcase(OP_VARARG) {
|
||||||
int b = GETARG_B(i) - 1; /* required results */
|
int b = GETARG_B(i) - 1; /* required results */
|
||||||
TValue *vtab = s2v(base + cl->p->numparams - 1); /* vararg table */
|
TValue *vtab = vRC(i); /* vararg table */
|
||||||
Protect(luaT_getvarargs(L, vtab, ra, b));
|
Protect(luaT_getvarargs(L, vtab, ra, b));
|
||||||
vmbreak;
|
vmbreak;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user