diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-02-06 22:45:51 +0100 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-02-06 22:45:51 +0100 |
commit | ed24912b2bfe3666a51760ca4b8e1a29ada12e25 (patch) | |
tree | bf95967cd6284a517ab775abba33b07c3db297a0 /src | |
parent | dfc839625011d6bbc51c9415be4e55a6d4ffe45a (diff) | |
download | fengari-ed24912b2bfe3666a51760ca4b8e1a29ada12e25.tar.gz fengari-ed24912b2bfe3666a51760ca4b8e1a29ada12e25.tar.bz2 fengari-ed24912b2bfe3666a51760ca4b8e1a29ada12e25.zip |
VARARG
Diffstat (limited to 'src')
-rw-r--r-- | src/lvm.js | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -449,6 +449,25 @@ class LuaVM { break; } case "OP_VARARG": { + let b = i.B - 1; + let n = base - ci.funcOff - cl.p.numparams - 1; + let j + + if (n < 0) /* less arguments than parameters? */ + n = 0; /* no vararg arguments */ + + if (b < 0) { + b = n; /* get all var. arguments */ + base = ci.u.l.base; + ra = this.RA(i); /* previous call may change the stack */ + L.top = ra + n; + } + + for (j = 0; j < b && j < n; j++) + L.stack[ra + j] = L.stack[base - n - j]; + + for (; j < b; j++) /* complete required results with nil */ + L.stack[ra + j] = new TValue(CT.LUA_TNIL, null); break; } case "OP_EXTRAARG": { |