diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-03-29 14:39:57 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-03-30 09:57:53 +0200 |
commit | 456ab7b69f88859683c60cc2261e70d6dbadd8e8 (patch) | |
tree | 12baf4ae489e7afd4819ec94bc413c1c2a1db05d /src/lundump.js | |
parent | 2e5b595a2e04fe72555a565af4aae43560946473 (diff) | |
download | fengari-456ab7b69f88859683c60cc2261e70d6dbadd8e8.tar.gz fengari-456ab7b69f88859683c60cc2261e70d6dbadd8e8.tar.bz2 fengari-456ab7b69f88859683c60cc2261e70d6dbadd8e8.zip |
8-bit string internally tests
Lexing/Parsing is done on byte rather than js strings
Diffstat (limited to 'src/lundump.js')
-rw-r--r-- | src/lundump.js | 30 |
1 files changed, 14 insertions, 16 deletions
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; |