summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-03-12 10:50:19 +0100
committerBenoit Giannangeli <giann@users.noreply.github.com>2017-03-13 11:03:24 +0100
commit632cf08572b35e8a350ac8b1f9d5bf77fb4e7b95 (patch)
treef44c8921491b40561b7709cd0c081c931ba18f6a
parent883d01f0a707a03ef5b183cd2d03046fdc544e0e (diff)
downloadfengari-632cf08572b35e8a350ac8b1f9d5bf77fb4e7b95.tar.gz
fengari-632cf08572b35e8a350ac8b1f9d5bf77fb4e7b95.tar.bz2
fengari-632cf08572b35e8a350ac8b1f9d5bf77fb4e7b95.zip
[Strings] ldebug.js, ldo.js, lfunc.js
-rw-r--r--src/ldebug.js8
-rw-r--r--src/ldo.js6
-rw-r--r--src/lfunc.js4
-rw-r--r--src/lua.js1
4 files changed, 10 insertions, 9 deletions
diff --git a/src/ldebug.js b/src/ldebug.js
index 091b896..2858267 100644
--- a/src/ldebug.js
+++ b/src/ldebug.js
@@ -400,7 +400,7 @@ const isinstack = function(L, ci, o) {
}
return false;
-}
+};
/*
** Checks whether value 'o' came from an upvalue. (That can only happen
@@ -414,7 +414,7 @@ const getupvalname = function(L, ci, o, name) {
return {
name: upvalname(c.p, i),
funcname: 'upvalue'
- }
+ };
}
}
@@ -469,7 +469,7 @@ const luaG_addinfo = function(L, msg, src, line) {
if (src)
buff = lobject.luaO_chunkid(src, luaconf.LUA_IDSIZE);
- L.stack[L.top++] = new TValue(CT.LUA_TLNGSTR, `${buff}:${line}: ${msg}`); // We don't need to check for overflow here
+ L.stack[L.top++] = L.l_G.intern(lua.to_luastring(`${buff}:${line}: ${msg}`)); // We don't need to check for overflow here
return L.stack[L.top - 1];
};
@@ -501,7 +501,7 @@ const luaG_tointerror = function(L, p1, p2) {
if (temp === false)
p2 = p1;
luaG_runerror(L, `number${varinfo(L, p2)} has no integer representation`);
-}
+};
module.exports.lua_getstack = lua_getstack;
module.exports.lua_getinfo = lua_getinfo;
diff --git a/src/ldo.js b/src/ldo.js
index cde2755..e088d8d 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -25,11 +25,11 @@ const nil = new TValue(CT.LUA_TNIL, null);
const seterrorobj = function(L, errcode, oldtop) {
switch (errcode) {
case TS.LUA_ERRMEM: {
- L.stack[oldtop] = new TValue(CT.LUA_TLNGSTR, "not enough memory");
+ L.stack[oldtop] = L.l_G.intern(lua.to_luastring("not enough memory"));
break;
}
case TS.LUA_ERRERR: {
- L.stack[oldtop] = new TValue(CT.LUA_TLNGSTR, "error in error handling");
+ L.stack[oldtop] = L.l_G.intern(lua.to_luastring("error in error handling"));
break;
}
default: {
@@ -359,7 +359,7 @@ const recover = function(L, status) {
*/
const resume_error = function(L, msg, narg) {
L.top -= narg; /* remove args from the stack */
- L.stack[L.top++] = new TValue(CT.LUA_TLNGSTR, msg); /* push error message */
+ L.stack[L.top++] = L.l_G.intern(lua.to_luastring(msg)); /* push error message */
assert(L.top <= L.ci.top, "stack overflow");
return TS.LUA_ERRRUN;
};
diff --git a/src/lfunc.js b/src/lfunc.js
index 227606d..032f653 100644
--- a/src/lfunc.js
+++ b/src/lfunc.js
@@ -128,7 +128,7 @@ const luaF_getlocalname = function(f, local_number, pc) {
}
}
return null; /* not found */
-}
+};
module.exports.MAXUPVAL = 255;
@@ -136,6 +136,6 @@ module.exports.Proto = Proto;
module.exports.UpVal = UpVal;
module.exports.findupval = findupval;
module.exports.luaF_close = luaF_close;
-module.exports.luaF_getlocalname = luaF_getlocalname
+module.exports.luaF_getlocalname = luaF_getlocalname;
module.exports.luaF_initupvals = luaF_initupvals;
module.exports.luaF_newLclosure = luaF_newLclosure; \ No newline at end of file
diff --git a/src/lua.js b/src/lua.js
index 971593d..12d4e65 100644
--- a/src/lua.js
+++ b/src/lua.js
@@ -133,6 +133,7 @@ class lua_Debug {
}
const to_luastring = function(str, maxBytesToWrite) {
+ maxBytesToWrite = maxBytesToWrite !== undefined ? maxBytesToWrite : str.length;
let outU8Array = new Array(maxBytesToWrite);
if (!(maxBytesToWrite > 0)) // Parameter maxBytesToWrite is not optional. Negative values, 0, null, undefined and false each don't write out any bytes.