From bb6dc6106cd1d9aedc0e9554928da6d232309a1a Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 24 May 2017 16:38:03 +1000 Subject: Introduce chgfltvalue and chgivalue --- src/lobject.js | 10 ++++++++++ src/lvm.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lobject.js b/src/lobject.js index ee7a51d..54d4de9 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -126,11 +126,21 @@ class TValue { this.value = x; } + chgfltvalue(x) { + assert(this.type == CT.LUA_TNUMFLT); + this.value = x; + } + setivalue(x) { this.type = CT.LUA_TNUMINT; this.value = x; } + chgivalue(x) { + assert(this.type == CT.LUA_TNUMINT); + this.value = x; + } + setnilvalue() { this.type = CT.LUA_TNIL; this.value = void 0; diff --git a/src/lvm.js b/src/lvm.js index b9c2972..2786306 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -520,7 +520,7 @@ const luaV_execute = function(L) { if (0 < step ? idx <= limit : limit <= idx) { ci.l_savedpc += i.sBx; - L.stack[ra].value = idx; + L.stack[ra].chgivalue(idx); /* update internal index... */ L.stack[ra + 3] = new lobject.TValue(CT.LUA_TNUMINT, idx); } } else { /* floating loop */ @@ -530,7 +530,7 @@ const luaV_execute = function(L) { if (0 < step ? idx <= limit : limit <= idx) { ci.l_savedpc += i.sBx; - L.stack[ra].value = idx; + L.stack[ra].chgfltvalue(idx); /* update internal index... */ L.stack[ra + 3] = new lobject.TValue(CT.LUA_TNUMFLT, idx); } } -- cgit v1.2.3-70-g09d2