aboutsummaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-23 17:09:03 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-27 22:14:29 +1000
commitb3c87776e08f546a9994527f7c2c7fc4ec07d9a1 (patch)
treed12ee5c396408d8a0d8e5e2d2cb74f46eb1b1e19 /src/lapi.js
parent51ea4bdd2d2ac1166911b54ba5a1aa6aa8a573dd (diff)
downloadfengari-b3c87776e08f546a9994527f7c2c7fc4ec07d9a1.tar.gz
fengari-b3c87776e08f546a9994527f7c2c7fc4ec07d9a1.tar.bz2
fengari-b3c87776e08f546a9994527f7c2c7fc4ec07d9a1.zip
Introduce setobjs2s
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 92e1612..00e608f 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -163,7 +163,7 @@ const lua_pop = function(L, n) {
const reverse = function(L, from, to) {
for (; from < to; from++, to--) {
let temp = L.stack[from];
- L.stack[from] = L.stack[to];
+ lobject.setobjs2s(L, from, to);
L.stack[to] = temp;
}
};
@@ -892,7 +892,8 @@ const lua_arith = function(L, op) {
assert(2 < L.top - L.ci.funcOff, "not enough elements in the stack"); /* all other operations expect two operands */
else { /* for unary operations, add fake 2nd operand */
assert(1 < L.top - L.ci.funcOff, "not enough elements in the stack");
- L.stack[L.top++] = L.stack[L.top - 1];
+ lobject.setobjs2s(L, L.top, L.top - 1);
+ L.top++;
}
/* 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]);