aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-13 15:13:27 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-13 15:13:27 +1100
commit3e7c102eefbaae9e6bc839b11bba79aee1c5e040 (patch)
treec811b42cc9ffb08a0bf8a93d6141324d707f4953 /src
parentd1d2a636ea67c2e30a34660eeb6c7da544646bea (diff)
downloadfengari-3e7c102eefbaae9e6bc839b11bba79aee1c5e040.tar.gz
fengari-3e7c102eefbaae9e6bc839b11bba79aee1c5e040.tar.bz2
fengari-3e7c102eefbaae9e6bc839b11bba79aee1c5e040.zip
Introduce defs.string_of to create string from bytes
Diffstat (limited to 'src')
-rw-r--r--src/defs.js3
-rw-r--r--src/ldump.js4
-rw-r--r--src/lobject.js2
3 files changed, 6 insertions, 3 deletions
diff --git a/src/defs.js b/src/defs.js
index 268e76e..27498c6 100644
--- a/src/defs.js
+++ b/src/defs.js
@@ -131,6 +131,8 @@ class lua_Debug {
}
+const string_of = Array.of;
+
const is_luastring = function(s) {
return Array.isArray(s);
};
@@ -422,6 +424,7 @@ module.exports.lua_upvalueindex = lua_upvalueindex;
module.exports.thread_status = thread_status;
module.exports.is_luastring = is_luastring;
module.exports.luastring_cmp = luastring_cmp;
+module.exports.string_of = string_of;
module.exports.to_jsstring = to_jsstring;
module.exports.to_luastring = to_luastring;
module.exports.to_uristring = to_uristring;
diff --git a/src/ldump.js b/src/ldump.js
index 627a252..964d6ff 100644
--- a/src/ldump.js
+++ b/src/ldump.js
@@ -3,7 +3,7 @@
const defs = require('./defs.js');
const CT = defs.constant_types;
-const LUAC_DATA = [25, 147, 13, 10, 26, 10];
+const LUAC_DATA = defs.string_of(25, 147, 13, 10, 26, 10);
const LUAC_INT = 0x5678;
const LUAC_NUM = 370.5;
const LUAC_VERSION = Number.parseInt(defs.LUA_VERSION_MAJOR) * 16 + Number.parseInt(defs.LUA_VERSION_MINOR);
@@ -30,7 +30,7 @@ const DumpLiteral = function(s, D) {
};
const DumpByte = function(y, D) {
- DumpBlock([y], 1, D);
+ DumpBlock(defs.string_of(y), 1, D);
};
const DumpInt = function(x, D) {
diff --git a/src/lobject.js b/src/lobject.js
index a70866d..707cdf8 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -547,7 +547,7 @@ const luaO_pushvfstring = function(L, fmt, argp) {
case char['c']: {
let buff = argp[a++];
if (ljstype.lisprint(buff))
- pushstr(L, [buff]);
+ pushstr(L, defs.string_of(buff));
else
luaO_pushfstring(L, defs.to_luastring("<\\%d>", true), buff);
break;