diff options
-rw-r--r-- | src/lstate.js | 2 | ||||
-rw-r--r-- | src/lvm.js | 2 | ||||
-rw-r--r-- | tests/lvm.js | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/src/lstate.js b/src/lstate.js index ef84e07..b919f0e 100644 --- a/src/lstate.js +++ b/src/lstate.js @@ -1,6 +1,7 @@ /*jshint esversion: 6 */ "use strict"; +const LUA_MULTRET = require('./lua.js').LUA_MULTRET; class CallInfo { @@ -28,6 +29,7 @@ class lua_State { this.top = 1; this.ci = new CallInfo(0, cl, 1, 1, null, null); this.ci.u.l.savedpc = cl.p.code; + this.ci.nresults = LUA_MULTRET; this.ciOff = 0; this.stack = [ cl @@ -70,8 +70,6 @@ class LuaVM { let i = ci.u.l.savedpc[ci.pcOff++]; let ra = this.RA(base, i); - console.log(`Before ${OC.OpCodes[i.opcode]} L.top is ${L.top}`); - switch (OC.OpCodes[i.opcode]) { case "OP_MOVE": { L.stack[ra] = L.stack[this.RB(base, i)]; diff --git a/tests/lvm.js b/tests/lvm.js index 084a9ad..c93b1ed 100644 --- a/tests/lvm.js +++ b/tests/lvm.js @@ -108,7 +108,7 @@ test('Binary op', function (t) { }, "Program executed without errors"); t.deepEqual( - vm.L.stack.slice(vm.L.stack.length - 12).map(function (e) { return e.value; }), + vm.L.stack.slice(vm.L.top - 12, vm.L.top).map(function (e) { return e.value; }), [15, -5, 50, 0.5, 5, 9765625.0, 0, 0, 15, 15, 5120, 0], "Program output is correct" ); |