aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js20
-rw-r--r--src/lbaselib.js10
-rw-r--r--src/ldebug.js2
3 files changed, 23 insertions, 9 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 9059ee9..c091150 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -548,9 +548,9 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) {
if (errfunc === 0)
func = 0;
else {
- let o = index2addr(L, errfunc);
+ // let o = index2addr(L, errfunc);
// TODO: api_checkstackindex(L, errfunc, o);
- func = errfunc;
+ func = index2addr_(L, errfunc);
}
c.funcOff = L.top - (nargs + 1); /* function to be called */
@@ -605,6 +605,17 @@ const lua_concat = function(L, n) {
}
};
+// This functions are only there for compatibility purposes
+const lua_gc = function () {};
+
+const lua_getallocf = function () {
+ console.warn("lua_getallocf is not available and will always return null");
+ return null;
+};
+const lua_getextraspace = function () {
+ console.warn("lua_getextraspace is not available and will always return null");
+ return null;
+};
module.exports.lua_pushvalue = lua_pushvalue;
module.exports.lua_pushnil = lua_pushnil;
@@ -659,4 +670,7 @@ module.exports.lua_settop = lua_settop;
module.exports.lua_rawequal = lua_rawequal;
module.exports.lua_concat = lua_concat;
module.exports.lua_error = lua_error;
-module.exports.lua_insert = lua_insert; \ No newline at end of file
+module.exports.lua_insert = lua_insert;
+module.exports.lua_gc = lua_gc;
+module.exports.lua_getallocf = lua_getallocf;
+module.exports.lua_getextraspace = lua_getextraspace; \ No newline at end of file
diff --git a/src/lbaselib.js b/src/lbaselib.js
index ac0ac4c..b3dcd12 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -131,10 +131,10 @@ const luaB_pcall = function(L) {
*/
const luaB_xpcall = function(L) {
let n = lapi.lua_gettop(L);
- lauxlib.luaL_checktype(L, 2, CT.LUA_TFUNCTION);
- lapi.lua_pushboolean(L, 1);
- lapi.lua_pushvalue(L, 1);
- lapi.lua_rotate(L, 3, 2);
+ lauxlib.luaL_checktype(L, 2, CT.LUA_TFUNCTION); /* check error function */
+ lapi.lua_pushboolean(L, 1); /* first result */
+ lapi.lua_pushvalue(L, 1); /* function */
+ lapi.lua_rotate(L, 3, 2); /* move them below function's arguments */
let status = lapi.lua_pcallk(L, n - 2, lua.LUA_MULTRET, 2, 2, finishpcall);
return finishpcall(L, status, 2);
};
@@ -167,4 +167,4 @@ const luaopen_base = function(L) {
return 1;
};
-module.exports.luaopen_base = luaopen_base;
+module.exports.luaopen_base = luaopen_base;
diff --git a/src/ldebug.js b/src/ldebug.js
index be122e0..f6d0633 100644
--- a/src/ldebug.js
+++ b/src/ldebug.js
@@ -485,7 +485,7 @@ const luaG_errormsg = function(L) {
if (L.errfunc !== 0) { /* is there an error handling function? */
let errfunc = L.errfunc;
L.stack[L.top] = L.stack[L.top - 1];
- L.stack[L.top - 1] = errfunc;
+ L.stack[L.top - 1] = L.stack[errfunc];
L.top++;
ldo.luaD_callnoyield(L, L.top - 2, 1);
}