God knows what's modified
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "luastack.hpp"
|
||||
#include "util.hpp"
|
||||
#include "source.hpp"
|
||||
#include "traceback.hpp"
|
||||
|
||||
|
||||
// Add another error status.
|
||||
@@ -61,30 +62,11 @@ static int report(lua_State *L, int status)
|
||||
return status;
|
||||
}
|
||||
|
||||
static int traceback(lua_State *L)
|
||||
static int docall(lua_State *L, int narg, int nret)
|
||||
{
|
||||
if (!lua_isstring(L, 1))
|
||||
{ /* Non-string error object? Try metamethod. */
|
||||
if (lua_isnoneornil(L, 1) ||
|
||||
!luaL_callmeta(L, 1, "__tostring") ||
|
||||
!lua_isstring(L, -1))
|
||||
return 1; /* Return non-string error object. */
|
||||
lua_remove(L, 1); /* Replace object by result of __tostring metamethod. */
|
||||
}
|
||||
luaL_traceback(L, L, lua_tostring(L, 1), 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int docall(lua_State *L, int narg, int clear)
|
||||
{
|
||||
int status;
|
||||
int base = lua_gettop(L) - narg; /* function index */
|
||||
lua_pushcfunction(L, traceback); /* push traceback function */
|
||||
lua_insert(L, base); /* put it under chunk and args */
|
||||
signal(SIGINT, laction);
|
||||
status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
|
||||
int status = traceback_pcall(L, narg, nret);
|
||||
signal(SIGINT, SIG_DFL);
|
||||
lua_remove(L, base); /* remove traceback function */
|
||||
/* force a complete garbage collection in case of errors */
|
||||
if (status != LUA_OK)
|
||||
lua_gc(L, LUA_GCCOLLECT, 0);
|
||||
@@ -169,7 +151,7 @@ static void dotty(lua_State *L)
|
||||
{
|
||||
int status = read_and_load(L);
|
||||
if (status == LUA_EOF) break;
|
||||
if (status == LUA_OK) status = docall(L, 0, 0);
|
||||
if (status == LUA_OK) status = docall(L, 0, LUA_MULTRET);
|
||||
report(L, status);
|
||||
if (status == LUA_OK && lua_gettop(L) > 0)
|
||||
{ /* any result to print? */
|
||||
@@ -198,12 +180,21 @@ static int pmain(lua_State *L)
|
||||
|
||||
LUAJIT_VERSION_SYM(); /* Linker-enforced version check. */
|
||||
|
||||
// Initialize the builtins, then copy a snapshot of the
|
||||
// builtins to the registry. This will allow us to restore
|
||||
// the builtins during source_rebuild operations.
|
||||
source_load_builtins(L);
|
||||
source_snapshot_builtins(L);
|
||||
|
||||
// Load the lua source.
|
||||
source_update(L);
|
||||
|
||||
// Rebuild the global environment and class database.
|
||||
|
||||
// Rebuild the global environment.
|
||||
source_rebuild(L);
|
||||
|
||||
// Run all the autoinit functions.
|
||||
source_autoinit(L);
|
||||
|
||||
dotty(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user