summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-27 09:08:31 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-27 09:08:31 +0200
commit3e150cbf82243134db25b71a7d90e2a31f8f04e7 (patch)
treeb9e8cfe7c640c9088caa49c4c254873486050a74 /src
parentf2698d4c4d5dd02888a493e3b6919e657c02b49a (diff)
downloadfengari-3e150cbf82243134db25b71a7d90e2a31f8f04e7.tar.gz
fengari-3e150cbf82243134db25b71a7d90e2a31f8f04e7.tar.bz2
fengari-3e150cbf82243134db25b71a7d90e2a31f8f04e7.zip
luaT_trybinTM in luaO_arith needs a stack index
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js2
-rw-r--r--src/lobject.js6
2 files changed, 5 insertions, 3 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 92e1612..27d692a 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -895,7 +895,7 @@ const lua_arith = function(L, op) {
L.stack[L.top++] = L.stack[L.top - 1];
}
/* first operand at top - 2, second at top - 1; result go to top - 2 */
- lobject.luaO_arith(L, op, L.stack[L.top - 2], L.stack[L.top - 1], L.stack[L.top - 2]);
+ lobject.luaO_arith(L, op, L.stack[L.top - 2], L.stack[L.top - 1], L.top - 2);
L.top--; /* remove second operand */
};
diff --git a/src/lobject.js b/src/lobject.js
index b6fd581..d08849c 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -605,7 +605,9 @@ const numarith = function(L, op, v1, v2) {
}
};
-const luaO_arith = function(L, op, p1, p2, res) {
+const luaO_arith = function(L, op, p1, p2, p3) {
+ let res = (typeof p3 === "number") ? L.stack[p3] : p3; /* FIXME */
+
switch (op) {
case defs.LUA_OPBAND: case defs.LUA_OPBOR: case defs.LUA_OPBXOR:
case defs.LUA_OPSHL: case defs.LUA_OPSHR:
@@ -644,7 +646,7 @@ const luaO_arith = function(L, op, p1, p2, res) {
}
/* could not perform raw operation; try metamethod */
assert(L !== null); /* should not fail when folding (compile time) */
- ltm.luaT_trybinTM(L, p1, p2, res, (op - defs.LUA_OPADD) + ltm.TMS.TM_ADD);
+ ltm.luaT_trybinTM(L, p1, p2, p3, (op - defs.LUA_OPADD) + ltm.TMS.TM_ADD);
};