From 1428582c2d88b23f12c87921381796d03b388d9f Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 24 May 2017 16:44:48 +1000 Subject: Use .setclLvalue --- src/lparser.js | 2 +- src/lundump.js | 2 +- src/lvm.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lparser.js b/src/lparser.js index 13f75c9..96bad67 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -1565,7 +1565,7 @@ const luaY_parser = function(L, z, buff, dyd, name, firstchar) { let funcstate = new FuncState(); let cl = lfunc.luaF_newLclosure(L, 1); /* create main closure */ ldo.luaD_inctop(L); - L.stack[L.top-1] = new TValue(defs.CT.LUA_TLCL, cl); + L.stack[L.top-1].setclLvalue(cl); lexstate.h = ltable.luaH_new(L); /* create table for scanner */ ldo.luaD_inctop(L); L.stack[L.top-1] = new TValue(defs.CT.LUA_TTABLE, lexstate.h); diff --git a/src/lundump.js b/src/lundump.js index 4931fe8..5686430 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -265,8 +265,8 @@ const luaU_undump = function(L, Z, name) { let S = new BytecodeParser(L, Z, name); S.checkHeader(); let cl = lfunc.luaF_newLclosure(L, S.readByte()); + L.stack[L.top].setclLvalue(cl); ldo.luaD_inctop(L); - L.stack[L.top-1] = new lobject.TValue(defs.CT.LUA_TLCL, cl); cl.p = new lfunc.Proto(L); S.readFunction(cl.p, null); assert(cl.nupvalues === cl.p.upvalues.length); diff --git a/src/lvm.js b/src/lvm.js index 2786306..e308807 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -943,7 +943,7 @@ const pushclosure = function(L, p, encup, base, ra) { let uv = p.upvalues; let ncl = new lobject.LClosure(L, nup); ncl.p = p; - L.stack[ra] = new lobject.TValue(CT.LUA_TLCL, ncl); + L.stack[ra].setclLvalue(ncl); for (let i = 0; i < nup; i++) { if (uv[i].instack) ncl.upvals[i] = lfunc.luaF_findupval(L, base + uv[i].idx); -- cgit v1.2.3-70-g09d2