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/lobject.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/lobject.js')
-rw-r--r-- | src/lobject.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lobject.js b/src/lobject.js index 812ac6a..e958975 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -132,6 +132,8 @@ const luaO_nilobject = new TValue(CT.LUA_TNIL, null); module.exports.luaO_nilobject = luaO_nilobject; const jsstring = function(value, from, to) { + assert(Array.isArray(value), "jsstring expect a array of bytes"); + let u0, u1, u2, u3, u4, u5; let idx = 0; value = value.slice(from ? from : 0, to); @@ -194,6 +196,8 @@ class Table extends TValue { } } else if (typeof key === "string") { // To avoid key = lua.to_luastring(key).map(e => `${e}|`).join(''); + } else if (Array.isArray(key)) { + key = key.map(e => `${e}|`).join(''); } return key; @@ -293,7 +297,7 @@ const luaO_chunkid = function(source, bufflen) { else { /* truncate it */ out = out.concat(source.slice(1, bufflen)); } - } else if (source.charAt(0) === '@') { /* file name */ + } else if (source[0] === '@'.charCodeAt(0)) { /* file name */ if (l <= bufflen) /* small enough? */ out = source.slice(1); else { /* add '...' before rest of name */ |