summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-09 13:01:21 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-09 13:01:21 +1000
commit74dd47160960b3f0faa13dd1b61b64af69fde02e (patch)
treefee2730a670c4526c1c927230765be3dce49fc95 /src/lapi.js
parent9b74a453e4a48f0c2028bc15b2c5bdaee6fcd5c7 (diff)
downloadfengari-74dd47160960b3f0faa13dd1b61b64af69fde02e.tar.gz
fengari-74dd47160960b3f0faa13dd1b61b64af69fde02e.tar.bz2
fengari-74dd47160960b3f0faa13dd1b61b64af69fde02e.zip
Add is_luastring function instead of using Array.isArray directly
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 4b5be04..1971cd7 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -236,7 +236,7 @@ const lua_pushlstring = function(L, s, len) {
if (len === 0) {
ts = lstring.luaS_bless(L, []);
} else {
- assert(Array.isArray(s), "lua_pushlstring expects array of byte");
+ assert(defs.is_luastring(s), "lua_pushlstring expects array of byte");
ts = lstring.luaS_bless(L, s.slice(0, len));
}
lobject.pushsvalue2s(L, ts);
@@ -246,7 +246,7 @@ const lua_pushlstring = function(L, s, len) {
};
const lua_pushstring = function (L, s) {
- assert(Array.isArray(s) || s === undefined || s === null, "lua_pushstring expects array of byte");
+ assert(defs.is_luastring(s) || s === undefined || s === null, "lua_pushstring expects array of byte");
if (s === undefined || s === null) {
L.stack[L.top] = new TValue(CT.LUA_TNIL, null);
@@ -262,12 +262,12 @@ const lua_pushstring = function (L, s) {
};
const lua_pushvfstring = function (L, fmt, argp) {
- assert(Array.isArray(fmt));
+ assert(defs.is_luastring(fmt));
return lobject.luaO_pushvfstring(L, fmt, argp);
};
const lua_pushfstring = function (L, fmt, ...argp) {
- assert(Array.isArray(fmt));
+ assert(defs.is_luastring(fmt));
return lobject.luaO_pushvfstring(L, fmt, argp);
};
@@ -350,7 +350,7 @@ const lua_pushglobaltable = function(L) {
** t[k] = value at the top of the stack (where 'k' is a string)
*/
const auxsetstr = function(L, t, k) {
- assert(Array.isArray(k), "key must be an array of bytes");
+ assert(defs.is_luastring(k), "key must be an array of bytes");
let str = lstring.luaS_new(L, k);
assert(1 < L.top - L.ci.funcOff, "not enough elements in the stack");
@@ -464,7 +464,7 @@ const lua_rawsetp = function(L, idx, p) {
*/
const auxgetstr = function(L, t, k) {
- assert(Array.isArray(k), "key must be an array of bytes");
+ assert(defs.is_luastring(k), "key must be an array of bytes");
let str = lstring.luaS_new(L, k);
lobject.pushsvalue2s(L, str);
assert(L.top <= L.ci.top, "stack overflow");
@@ -908,8 +908,8 @@ const lua_arith = function(L, op) {
*/
const lua_load = function(L, reader, data, chunkname, mode) {
- assert(Array.isArray(chunkname), "lua_load expect an array of byte as chunkname");
- assert(mode ? Array.isArray(mode) : true, "lua_load expect an array of byte as mode");
+ assert(defs.is_luastring(chunkname), "lua_load expect an array of byte as chunkname");
+ assert(mode ? defs.is_luastring(mode) : true, "lua_load expect an array of byte as mode");
if (!chunkname) chunkname = [defs.char["?"]];
let z = new lzio.ZIO(L, reader, data);
let status = ldo.luaD_protectedparser(L, z, chunkname, mode);