From 456ab7b69f88859683c60cc2261e70d6dbadd8e8 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 29 Mar 2017 14:39:57 +0200 Subject: 8-bit string internally tests Lexing/Parsing is done on byte rather than js strings --- src/lundump.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/lundump.js') diff --git a/src/lundump.js b/src/lundump.js index 7452c43..36fd674 100644 --- a/src/lundump.js +++ b/src/lundump.js @@ -5,10 +5,8 @@ const fs = require('fs'); const assert = require('assert'); const lua = require('./lua.js'); -const LClosure = require('./lobject.js').LClosure; -const TValue = require('./lobject.js').TValue; +const lobject = require('./lobject.js'); const Proto = require('./lfunc.js').Proto; -const constant_types = require('./lua.js').constant_types; const OpCodes = require('./lopcodes.js'); const LUAI_MAXSHORTLEN = 40; @@ -167,20 +165,20 @@ class BytecodeParser { let t = this.readByte(); switch (t) { - case constant_types.LUA_TNIL: - f.k.push(new TValue(constant_types.LUA_TNIL, null)); + case lua.CT.LUA_TNIL: + f.k.push(new lobject.TValue(lua.CT.LUA_TNIL, null)); break; - case constant_types.LUA_TBOOLEAN: - f.k.push(new TValue(constant_types.LUA_TBOOLEAN, this.readByte())); + case lua.CT.LUA_TBOOLEAN: + f.k.push(new lobject.TValue(lua.CT.LUA_TBOOLEAN, this.readByte())); break; - case constant_types.LUA_TNUMFLT: - f.k.push(new TValue(constant_types.LUA_TNUMFLT, this.readNumber())); + case lua.CT.LUA_TNUMFLT: + f.k.push(new lobject.TValue(lua.CT.LUA_TNUMFLT, this.readNumber())); break; - case constant_types.LUA_TNUMINT: - f.k.push(new TValue(constant_types.LUA_TNUMINT, this.readInteger())); + case lua.CT.LUA_TNUMINT: + f.k.push(new lobject.TValue(lua.CT.LUA_TNUMINT, this.readInteger())); break; - case constant_types.LUA_TSHRSTR: - case constant_types.LUA_TLNGSTR: + case lua.CT.LUA_TSHRSTR: + case lua.CT.LUA_TLNGSTR: f.k.push(this.L.l_G.intern(this.read8bitString())); break; default: @@ -206,7 +204,7 @@ class BytecodeParser { n = this.readInt(); for (let i = 0; i < n; i++) { f.locvars[i] = { - varname: this.readString(), + varname: new lobject.TValue(lua.CT.LUA_TLNGSTR, lua.to_luastring(this.readString())), startpc: this.readInt(), endpc: this.readInt() }; @@ -264,7 +262,7 @@ class BytecodeParser { luaU_undump() { this.checkHeader(); - let cl = new LClosure(this.L, this.readByte()); + let cl = new lobject.LClosure(this.L, this.readByte()); this.L.stack[this.L.top] = cl; this.L.top++; @@ -280,4 +278,4 @@ class BytecodeParser { } -module.exports = BytecodeParser; \ No newline at end of file +module.exports = BytecodeParser; -- cgit v1.2.3-54-g00ecf