From aee0f65dea0456635e96b4496f6597188526e647 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 2 Mar 2017 11:31:05 +0100 Subject: [Parsing tests] SETTABUP, GETTABUP --- src/lcode.js | 8 ++++---- src/lua.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lcode.js b/src/lcode.js index 64e890e..9380d1a 100644 --- a/src/lcode.js +++ b/src/lcode.js @@ -487,12 +487,12 @@ const addk = function(fs, key, v) { let idx = fs.ls.h.__index(fs.ls.h, key); /* index scanner table */ if (idx && !idx.ttisnil()) { /* is there an index there? */ /* correct value? (warning: must distinguish floats from integers!) */ - if (f.k[idx].ttype() === v.ttype() && f.k[idx].value === v.value) - return idx; /* reuse index */ + if (f.k[idx.value].ttype() === v.ttype() && f.k[idx.value].value === v.value) + return idx.value; /* reuse index */ } /* constant not found; create a new entry */ let k = fs.nk; - fs.ls.h.__newindex(fs.ls.h, key, k); + fs.ls.h.__newindex(fs.ls.h, key, new TValue(CT.LUA_TNUMINT, k)); f.k[k] = v; fs.nk++; return k; @@ -616,7 +616,7 @@ const luaK_dischargevars = function(fs, e) { op = OpCodesI.OP_GETTABUP; /* 't' is in an upvalue */ } e.u.info = luaK_codeABC(fs, op, 0, e.u.ind.t, e.u.ind.idx); - e.k = OpCodesI.VRELOCABLE; + e.k = ek.VRELOCABLE; break; } case ek.VVARARG: case ek.VCALL: { diff --git a/src/lua.js b/src/lua.js index ef5385c..95d0ef8 100644 --- a/src/lua.js +++ b/src/lua.js @@ -57,8 +57,6 @@ const constant_types = { LUA_NUMTAGS: 9 }; -const CT = constant_types; - constant_types.LUA_TSHRSTR = constant_types.LUA_TSTRING | (0 << 4); /* short strings */ constant_types.LUA_TLNGSTR = constant_types.LUA_TSTRING | (1 << 4); /* long strings */ @@ -69,6 +67,8 @@ constant_types.LUA_TLCL = constant_types.LUA_TFUNCTION | (0 << 4); /* Lua closu constant_types.LUA_TLCF = constant_types.LUA_TFUNCTION | (1 << 4); /* light C function */ constant_types.LUA_TCCL = constant_types.LUA_TFUNCTION | (2 << 4); /* C closure */ +const CT = constant_types; + /* ** Comparison and arithmetic functions */ -- cgit v1.2.3-70-g09d2