From b3c87776e08f546a9994527f7c2c7fc4ec07d9a1 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 23 May 2017 17:09:03 +1000 Subject: Introduce setobjs2s --- src/lapi.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lapi.js') 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]); -- cgit v1.2.3-54-g00ecf