summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-23 08:33:41 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-23 08:45:34 +0100
commit99564913987698cdfc2528a93b5157030e637ced (patch)
tree49963f4e7358367cb3c6a4a5784cb1dd6c97de33 /src
parent9e08fa3a4b9f8848bb4eac3e745079282099a3d8 (diff)
downloadfengari-99564913987698cdfc2528a93b5157030e637ced.tar.gz
fengari-99564913987698cdfc2528a93b5157030e637ced.tar.bz2
fengari-99564913987698cdfc2528a93b5157030e637ced.zip
dofile
Diffstat (limited to 'src')
-rw-r--r--src/lbaselib.js14
-rw-r--r--src/ldebug.js9
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) {