diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-24 15:33:38 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-24 15:33:51 +1000 |
commit | b56f0ec3154d8644ed5c62cd7a4aee7139874c1c (patch) | |
tree | 7214506c89c5ee52e00efdf9d3ae3bb843475433 /src/lvm.js | |
parent | c69b112c04b6905824401be5342b7a581f358f92 (diff) | |
download | fengari-b56f0ec3154d8644ed5c62cd7a4aee7139874c1c.tar.gz fengari-b56f0ec3154d8644ed5c62cd7a4aee7139874c1c.tar.bz2 fengari-b56f0ec3154d8644ed5c62cd7a4aee7139874c1c.zip |
src/lvm.js: Don't modify tvalues on stack in OP_FORPREP
Diffstat (limited to 'src/lvm.js')
-rw-r--r-- | src/lvm.js | 25 |
1 files changed, 7 insertions, 18 deletions
@@ -548,27 +548,16 @@ const luaV_execute = function(L) { plimit.value = forlim.ilimit; init.value = (initv - pstep.value)|0; } else { /* try making all values floats */ - let ninit = tonumber(init); - let nlimit = tonumber(plimit); - let nstep = tonumber(pstep); - - if (nlimit === false) + let nlimit, nstep, ninit; + if ((nlimit = tonumber(plimit)) === false) ldebug.luaG_runerror(L, defs.to_luastring("'for' limit must be a number", true)); - - plimit.type = CT.LUA_TNUMFLT; - plimit.value = nlimit; - - if (nstep === false) + L.stack[ra + 1] = new lobject.TValue(CT.LUA_TNUMFLT, nlimit); + if ((nstep = tonumber(pstep)) === false) ldebug.luaG_runerror(L, defs.to_luastring("'for' step must be a number", true)); - - pstep.type = CT.LUA_TNUMFLT; - pstep.value = nstep; - - if (ninit === false) + L.stack[ra + 2] = new lobject.TValue(CT.LUA_TNUMFLT, nstep); + if ((ninit = tonumber(init)) === false) ldebug.luaG_runerror(L, defs.to_luastring("'for' initial value must be a number", true)); - - init.type = CT.LUA_TNUMFLT; - init.value = ninit - nstep; + L.stack[ra] = new lobject.TValue(CT.LUA_TNUMFLT, ninit - nstep); } ci.l_savedpc += i.sBx; |