back to old-style vararg system (with vararg table collecting extra

arguments)
This commit is contained in:
Roberto Ierusalimschy
2017-05-13 10:04:33 -03:00
parent 7647d5d13d
commit 5c8770f896
7 changed files with 74 additions and 72 deletions

18
lvm.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.279 2017/05/10 17:32:19 roberto Exp roberto $
** $Id: lvm.c,v 2.280 2017/05/11 18:57:46 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -1433,20 +1433,8 @@ void luaV_execute (lua_State *L) {
}
vmcase(OP_VARARG) {
int b = GETARG_B(i) - 1; /* required results */
int j;
int n = cast_int(base - ci->func) - cl->p->numparams - 1;
if (n < 0) /* less arguments than parameters? */
n = 0; /* no vararg arguments */
if (b < 0) { /* B == 0? */
b = n; /* get all var. arguments */
Protect(luaD_checkstack(L, n));
ra = RA(i); /* previous call may change the stack */
L->top = ra + n;
}
for (j = 0; j < b && j < n; j++)
setobjs2s(L, ra + j, base - n + j);
for (; j < b; j++) /* complete required results with nil */
setnilvalue(ra + j);
StkId vtab = base + cl->p->numparams - 1; /* vararg table */
Protect(luaT_getvarargs(L, vtab, ra, b));
vmbreak;
}
vmcase(OP_EXTRAARG) {