summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/clua.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-21 12:32:59 +0200
committerRobert Vollmert <rvollmert@gmx.net>2009-10-21 12:32:59 +0200
commitd9a9f676d1265f71ab6ebebed582b25e1e7ed8ab (patch)
treedccdca9d3d48b1e874f4fdb72b7c0f82687fc208 /crawl-ref/source/clua.cc
parentdf9d0d88a17ed81f394e76d336657e5a180c0c36 (diff)
downloadcrawl-ref-d9a9f676d1265f71ab6ebebed582b25e1e7ed8ab.tar.gz
crawl-ref-d9a9f676d1265f71ab6ebebed582b25e1e7ed8ab.zip
Move print_?lua_stack into CLua.
Diffstat (limited to 'crawl-ref/source/clua.cc')
-rw-r--r--crawl-ref/source/clua.cc51
1 files changed, 26 insertions, 25 deletions
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);
-}