From 8e19f368c2c40d99a92b39c6f566c7bcb2af6cf7 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Tue, 14 Feb 2017 16:02:21 +0100 Subject: binary op tag methods --- src/ltm.js | 2 +- src/lvm.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ltm.js b/src/ltm.js index c712160..4dc9cc7 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -73,7 +73,7 @@ const luaT_callbinTM = function(L, p1, p2, res, event) { }; const luaT_trybinTM = function(L, p1, p2, res, event) { - if (!luaT_gettmbyobj(L, p1, p2, res, event)) { + if (!luaT_callbinTM(L, p1, p2, res, event)) { throw new Error("TM error"); // TODO: luaG_error } }; diff --git a/src/lvm.js b/src/lvm.js index cd9548e..3f783af 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -169,6 +169,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMFLT, op1.value + op2.value); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_ADD); + debugger; + console.log(`TM_ADD: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -185,6 +187,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMFLT, op1.value - op2.value); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_SUB); + debugger; + console.log(`TM_SUB: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -201,6 +205,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMFLT, k[i.B].value * op2.value); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_MUL); + debugger; + console.log(`TM_MUL: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -217,6 +223,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMFLT, k[i.B].value % op2.value); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_MOD); + debugger; + console.log(`TM_MOD: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -231,6 +239,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMFLT, Math.pow(op1.value, op2.value)); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_POW); + debugger; + console.log(`TM_POW: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -245,6 +255,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMFLT, k[i.B].value / op2.value); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_DIV); + debugger; + console.log(`TM_DIV: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -261,6 +273,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMFLT, (op1.value / op2.value)|0); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_IDIV); + debugger; + console.log(`TM_IDIV: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -275,6 +289,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMINT, (op1.value & op2.value)|0); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_BAND); + debugger; + console.log(`TM_BAND: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -289,6 +305,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMINT, (op1.value | op2.value)|0); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_BOR); + debugger; + console.log(`TM_BOR: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -303,6 +321,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMINT, (op1.value ^ op2.value)|0); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_BXOR); + debugger; + console.log(`TM_BXOR: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -317,6 +337,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMINT, (op1.value << op2.value)|0); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_SHL); + debugger; + console.log(`TM_SHL: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; @@ -331,6 +353,8 @@ const luaV_execute = function(L) { L.stack[ra] = new TValue(CT.LUA_TNUMINT, (op1.value >> op2.value)|0); } else { ltm.luaT_trybinTM(L, op1, op2, ra, TMS.TM_SHR); + debugger; + console.log(`TM_SHR: ${L.stack[ra].value} (${ra})`); base = ci.u.l.base; } break; -- cgit v1.2.3-70-g09d2