diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-24 16:27:08 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-24 16:27:08 +1000 |
commit | 201d393d59645c96d8faf163e807378a63831821 (patch) | |
tree | 7f8cb777ec2a0c287b78edb6ed341f79621f1fab /src/lcode.js | |
parent | b58e259be7118f3d16cfa7fc9a33755528d1211c (diff) | |
download | fengari-201d393d59645c96d8faf163e807378a63831821.tar.gz fengari-201d393d59645c96d8faf163e807378a63831821.tar.bz2 fengari-201d393d59645c96d8faf163e807378a63831821.zip |
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'"
Diffstat (limited to 'src/lcode.js')
-rw-r--r-- | src/lcode.js | 8 |
1 files changed, 4 insertions, 4 deletions
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; } |