diff options
Diffstat (limited to 'source/core')
-rw-r--r-- | source/core/StarLua.cpp | 7 | ||||
-rw-r--r-- | source/core/StarLua.hpp | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/source/core/StarLua.cpp b/source/core/StarLua.cpp index 4499ebc..73955f2 100644 --- a/source/core/StarLua.cpp +++ b/source/core/StarLua.cpp @@ -461,6 +461,13 @@ ByteArray LuaEngine::compile(ByteArray const& contents, String const& name) { return compile(contents.ptr(), contents.size(), name.empty() ? nullptr : name.utf8Ptr()); } +lua_Debug const& LuaEngine::debugInfo(int level, const char* what) { + lua_Debug& debug = m_debugInfo = lua_Debug(); + lua_getstack(m_state, level, &debug); + lua_getinfo(m_state, what, &debug); + return debug; +} + LuaString LuaEngine::createString(String const& str) { lua_checkstack(m_state, 1); diff --git a/source/core/StarLua.hpp b/source/core/StarLua.hpp index 2fe275d..09e81e6 100644 --- a/source/core/StarLua.hpp +++ b/source/core/StarLua.hpp @@ -519,6 +519,9 @@ public: ByteArray compile(char const* contents, size_t size, char const* name = nullptr); ByteArray compile(String const& contents, String const& name = String()); ByteArray compile(ByteArray const& contents, String const& name = String()); + + // Returns the debug info of the state. + lua_Debug const& debugInfo(int level = 1, const char* what = "nSlu"); // Generic from/to lua conversion, calls template specialization of // LuaConverter for actual conversion. @@ -734,6 +737,7 @@ private: unsigned m_recursionLimit; int m_nullTerminated; HashMap<tuple<String, unsigned>, shared_ptr<LuaProfileEntry>> m_profileEntries; + lua_Debug m_debugInfo; }; // Built in conversions |