From 1c19f45c6b537dacfc0d57999d57cd4eef9399e9 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 15 Feb 2017 07:45:45 +0100 Subject: __le, __lt, __eq --- src/ltm.js | 2 +- src/lvm.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ltm.js b/src/ltm.js index 4dc9cc7..f5c34b0 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -79,7 +79,7 @@ const luaT_trybinTM = function(L, p1, p2, res, event) { }; const luaT_callorderTM = function(L, p1, p2, event) { - if (!luaT_callbinTM(L, p2, p2, L.top, event)) + if (!luaT_callbinTM(L, p1, p2, L.top, event)) return -1; else return !L.stack[L.top].l_isfalse() ? 1 : 0; diff --git a/src/lvm.js b/src/lvm.js index cd9548e..815ca2f 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -662,7 +662,7 @@ const luaV_lessthan = function(L, l, r) { else if (l.ttisstring() && r.ttisstring()) return l_strcmp(l, r) < 0; else { - let res = ltm.luatT_callorderTM(L, l, r, TMS.TM_LT); + let res = ltm.luaT_callorderTM(L, l, r, TMS.TM_LT); if (res < 0) throw new Error("TM order error"); // TODO: luaG_ordererror return res; @@ -677,17 +677,17 @@ const luaV_lessequal = function(L, l, r) { else if (l.ttisstring() && r.ttisstring()) return l_strcmp(l, r) <= 0; else { - res = ltm.luatT_callorderTM(L, l, r, TMS.TM_LE); + res = ltm.luaT_callorderTM(L, l, r, TMS.TM_LE); if (res >= 0) return res; } L.ci.callstatus |= lstate.CIST_LEQ; /* mark it is doing 'lt' for 'le' */ - res = ltm.luatT_callorderTM(L, l, r, TMS.TM_LT); + res = ltm.luaT_callorderTM(L, l, r, TMS.TM_LT); L.ci.callstatus ^= lstate.CIST_LEQ; /* clear mark */ if (res < 0) throw new Error("TM order error"); // TODO: luaG_ordererror - return res === 1; + return res !== 1 ? 1 : 0; /* result is negated */ }; const luaV_equalobj = function(L, t1, t2) { @@ -709,11 +709,11 @@ const luaV_equalobj = function(L, t1, t2) { case CT.LUA_TNUMINT: case CT.LUA_TNUMFLT: case CT.LUA_TBOOLEAN: - case CT.LUA_TLIGHTUSERDATA: case CT.LUA_TLCF: case CT.LUA_TSHRSTR: case CT.LUA_TLNGSTR: return t1.value === t2.value ? 1 : 0; + case CT.LUA_TLIGHTUSERDATA: case CT.LUA_TUSERDATA: case CT.LUA_TTABLE: if (t1 === t2) return 1; -- cgit v1.2.3-54-g00ecf