From d9a9f676d1265f71ab6ebebed582b25e1e7ed8ab Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Wed, 21 Oct 2009 12:32:59 +0200 Subject: Move print_?lua_stack into CLua. --- crawl-ref/source/clua.cc | 51 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'crawl-ref/source/clua.cc') diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 334b481319..529ca02c1d 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -653,6 +653,32 @@ void CLua::remove_shutdown_listener(lua_shutdown_listener *listener) shutdown_listeners.erase(i); } +// Can be called from within a debugger to look at the current Lua +// call stack. (Borrowed from ToME 3) +void CLua::print_stack() +{ + struct lua_Debug dbg; + int i = 0; + lua_State *L = state(); + + fprintf(stderr, EOL); + while (lua_getstack(L, i++, &dbg) == 1) + { + lua_getinfo(L, "lnuS", &dbg); + + char* file = strrchr(dbg.short_src, '/'); + if (file == NULL) + file = dbg.short_src; + else + file++; + + fprintf(stderr, "%s, function %s, line %d" EOL, file, + dbg.name, dbg.currentline); + } + + fprintf(stderr, EOL); +} + //////////////////////////////////////////////////////////////////////// // lua_text_pattern @@ -1110,28 +1136,3 @@ bool lua_datum::is_udata() const LUA_CHECK_TYPE(lua_isuserdata); } -// Can be called from within a debugger to look at the current Lua -// call stack. (Borrowed from ToME 3) -void print_clua_stack(void) -{ - struct lua_Debug dbg; - int i = 0; - lua_State *L = clua.state(); - - fprintf(stderr, EOL); - while (lua_getstack(L, i++, &dbg) == 1) - { - lua_getinfo(L, "lnuS", &dbg); - - char* file = strrchr(dbg.short_src, '/'); - if (file == NULL) - file = dbg.short_src; - else - file++; - - fprintf(stderr, "%s, function %s, line %d" EOL, file, - dbg.name, dbg.currentline); - } - - fprintf(stderr, EOL); -} -- cgit v1.2.3-54-g00ecf