From 99564913987698cdfc2528a93b5157030e637ced Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 23 Mar 2017 08:33:41 +0100 Subject: dofile --- src/lbaselib.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/lbaselib.js') 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; } -- cgit v1.2.3-54-g00ecf