From 201d393d59645c96d8faf163e807378a63831821 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 24 May 2017 16:27:08 +1000 Subject: src/lcode.js: constfolding should not pass lua state to luaO_arith This essentially backs out https://github.com/lua/lua/commit/99ac4a260fc1bf958515c1816d866852194493f2 See lua mailing thread "'constfolding' passes a proper Lua state to 'luaO_arith'" --- src/lcode.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lcode.js b/src/lcode.js index e30e41d..8dbff2b 100644 --- a/src/lcode.js +++ b/src/lcode.js @@ -962,13 +962,13 @@ const validop = function(op, v1, v2) { ** Try to "constant-fold" an operation; return 1 iff successful. ** (In this case, 'e1' has the final result.) */ -const constfolding = function(fs, op, e1, e2) { +const constfolding = function(op, e1, e2) { let ek = lparser.expkind; let v1, v2; if (!(v1 = tonumeral(e1, true)) || !(v2 = tonumeral(e2, true)) || !validop(op, v1, v2)) return 0; /* non-numeric operands or not safe to fold */ let res = new TValue(); /* FIXME */ - lobject.luaO_arith(fs.ls.L, op, v1, v2, res); /* does operation */ + lobject.luaO_arith(null, op, v1, v2, res); /* does operation */ if (res.ttisinteger()) { e1.k = ek.VKINT; e1.u.ival = res.value; @@ -1063,7 +1063,7 @@ const luaK_prefix = function(fs, op, e, line) { ef.f = NO_JUMP; switch (op) { case UnOpr.OPR_MINUS: case UnOpr.OPR_BNOT: /* use 'ef' as fake 2nd operand */ - if (constfolding(fs, op + defs.LUA_OPUNM, e, ef)) + if (constfolding(op + defs.LUA_OPUNM, e, ef)) break; /* FALLTHROUGH */ case UnOpr.OPR_LEN: @@ -1150,7 +1150,7 @@ const luaK_posfix = function(fs, op, e1, e2, line) { case BinOpr.OPR_IDIV: case BinOpr.OPR_MOD: case BinOpr.OPR_POW: case BinOpr.OPR_BAND: case BinOpr.OPR_BOR: case BinOpr.OPR_BXOR: case BinOpr.OPR_SHL: case BinOpr.OPR_SHR: { - if (!constfolding(fs, op + defs.LUA_OPADD, e1, e2)) + if (!constfolding(op + defs.LUA_OPADD, e1, e2)) codebinexpval(fs, op + OpCodesI.OP_ADD, e1, e2, line); break; } -- cgit v1.2.3-54-g00ecf