From 1b55793f38dcf088c2ab4b5cc9d7e75eb70ed7f7 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Sat, 20 May 2017 17:58:00 +0200 Subject: Use >>> instead of >> --- src/lobject.js | 2 +- src/lvm.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lobject.js b/src/lobject.js index 3ec04f6..05b1fad 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -528,7 +528,7 @@ const intarith = function(L, op, v1, v2) { case defs.LUA_OPBOR: return (v1 | v2); case defs.LUA_OPBXOR: return (v1 ^ v2); case defs.LUA_OPSHL: return (v1 << v2); - case defs.LUA_OPSHR: return (v1 >> v2); + case defs.LUA_OPSHR: return (v1 >>> v2)|0; case defs.LUA_OPUNM: return (0 - v1)|0; case defs.LUA_OPBNOT: return (~0 ^ v1); default: assert(0); diff --git a/src/lvm.js b/src/lvm.js index 35a4a51..6bc5377 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -365,7 +365,8 @@ const luaV_execute = function(L) { let numberop2 = tointeger(op2); if (numberop1 !== false && numberop2 !== false) { - L.stack[ra] = new lobject.TValue(CT.LUA_TNUMINT, (numberop1 >> numberop2)); + // >>> to have same overflow semantic as lua + L.stack[ra] = new lobject.TValue(CT.LUA_TNUMINT, (numberop1 >>> numberop2)|0); } else { ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_SHR); } @@ -386,7 +387,6 @@ const luaV_execute = function(L) { } case OCi.OP_BNOT: { let op = L.stack[RB(L, base, i)]; - let numberop = tonumber(op); if (op.ttisinteger()) { L.stack[ra] = new lobject.TValue(CT.LUA_TNUMINT, ~op.value); -- cgit v1.2.3-70-g09d2