diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lfunc.js | 1 | ||||
-rw-r--r-- | src/lobject.js | 14 | ||||
-rw-r--r-- | src/lundump.js | 18 |
3 files changed, 10 insertions, 23 deletions
diff --git a/src/lfunc.js b/src/lfunc.js index e12816d..69c7581 100644 --- a/src/lfunc.js +++ b/src/lfunc.js @@ -57,7 +57,6 @@ class UpVal { const luaF_newLclosure = function(L, n) { let c = new lobject.LClosure(L, n); - while (n--) c.upvals[n] = null; return c; }; diff --git a/src/lobject.js b/src/lobject.js index 5918a84..784720b 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -7,9 +7,7 @@ const defs = require('./defs.js'); const ljstype = require('./ljstype.js'); const luaconf = require('./luaconf.js'); const llimit = require('./llimit.js'); -const ltable = require('./ltable.js'); const CT = defs.constant_types; -const UpVal = require('./lfunc.js').UpVal; const char = defs.char; let tvalueCount = 0; @@ -206,17 +204,7 @@ class LClosure { constructor(L, n) { this.p = null; this.nupvalues = n; - - let _ENV = new UpVal(L); - _ENV.refcount = 0; - _ENV.v = null; - _ENV.u.open.next = null; - _ENV.u.open.touched = true; - _ENV.u.value = new TValue(CT.LUA_TTABLE, ltable.luaH_new(L)); - - this.upvals = [ - _ENV - ]; + this.upvals = Array(n); } } diff --git a/src/lundump.js b/src/lundump.js index 9162501..1d2d079 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -1,12 +1,12 @@ /*jshint esversion: 6 */ "use strict"; -const assert = require('assert'); +const assert = require('assert'); -const defs = require('./defs.js'); -const lobject = require('./lobject.js'); -const Proto = require('./lfunc.js').Proto; -const OpCodes = require('./lopcodes.js'); +const defs = require('./defs.js'); +const lfunc = require('./lfunc.js'); +const lobject = require('./lobject.js'); +const lopcodes = require('./lopcodes.js'); const LUAI_MAXSHORTLEN = 40; @@ -128,7 +128,7 @@ class BytecodeParser { readCode(f) { let n = this.readInt(); - let o = OpCodes; + let o = lopcodes; let p = BytecodeParser; for (let i = 0; i < n; i++) { @@ -191,7 +191,7 @@ class BytecodeParser { let n = this.readInt(); for (let i = 0; i < n; i++) { - f.p[i] = new Proto(this.L); + f.p[i] = new lfunc.Proto(this.L); this.readFunction(f.p[i], f.source); } } @@ -280,12 +280,12 @@ class BytecodeParser { luaU_undump() { this.checkHeader(); - let cl = new lobject.LClosure(this.L, this.readByte()); + let cl = lfunc.luaF_newLclosure(this.L, this.readByte()); this.L.stack[this.L.top] = new lobject.TValue(defs.CT.LUA_TLCL, cl); this.L.top++; - cl.p = new Proto(); + cl.p = new lfunc.Proto(); this.readFunction(cl.p); |