Skip to content

Commit

Permalink
[core.lua] when lua prints out the stack, it will include the typenam…
Browse files Browse the repository at this point in the history
…e of everything aswell as their value
  • Loading branch information
harrand committed Nov 19, 2024
1 parent 9b027d2 commit 9bace70
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/tz/core/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,19 @@ namespace tz
lua_getglobal(lua, "tostring");
for(int i = top; i >= bottom; i--)
{
const char* type_name = luaL_typename(lua, i);
lua_pushvalue(lua, -1);
lua_pushvalue(lua, i);
lua_pcall(lua, 1, 1, 0);
const char* str = lua_tostring(lua, -1);
ret += std::string(">") + std::to_string(i) + ": ";
if(str == nullptr)
{
ret += luaL_typename(lua, i) + std::string("\n");
ret += std::format("<unprintable> ({})\n", type_name);
}
else
{
ret += str + std::string("\n");
ret += std::format("{} ({})\n", str, type_name);
}
lua_pop(lua, 1);
}
Expand Down

0 comments on commit 9bace70

Please sign in to comment.