diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lbaselib.js | 14 | ||||
-rw-r--r-- | src/ldebug.js | 9 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js index 604a005..83b3c33 100644 --- a/src/lbaselib.js +++ b/src/lbaselib.js @@ -358,7 +358,21 @@ if (typeof window === "undefined") { return load_aux(L, status, env); }; + const dofilecont = function(L, d1, d2) { + return lapi.lua_gettop(L) - 1; + }; + + const luaB_dofile = function(L) { + let fname = lauxlib.luaL_optstring(L, 1, null); + lapi.lua_settop(L, 1); + if (lauxlib.luaL_loadfile(L, fname) !== TS.LUA_OK) + return lapi.lua_error(L); + lapi.lua_callk(L, 0, lua.LUA_MULTRET, 0, dofilecont); + return dofilecont(L, 0, 0); + }; + base_funcs.loadfile = luaB_loadfile; + base_funcs.dofile = luaB_dofile; } diff --git a/src/ldebug.js b/src/ldebug.js index 529cb0c..3b01263 100644 --- a/src/ldebug.js +++ b/src/ldebug.js @@ -431,7 +431,14 @@ const varinfo = function(L, o) { kind = getobjname(ci.func.p, ci.pcOff, stkid - ci.u.l.base); } - return kind ? ` (${kind.funcname} '${kind.name.jsstring()}')` : ``; + if (kind) { + let funcname = kind.funcname instanceof TValue ? kind.funcname.jsstring() : kind.funcname; + let name = kind.name instanceof TValue ? kind.name.jsstring() : kind.name; + + return ` (${funcname} '${name}')`; + } + + return ``; }; const luaG_typeerror = function(L, o, op) { |