Skip to content

Commit

Permalink
refactor: use lua_getfenv to fetch globals
Browse files Browse the repository at this point in the history
  • Loading branch information
sssooonnnggg committed Dec 12, 2024
1 parent 3288efb commit 8c94015
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion debugger/src/internal/variable_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ void VariableRegistry::fetch(lua_State* L) {

void VariableRegistry::fetchGlobals(lua_State* L) {
lua_utils::StackGuard guard(L);
lua_Debug ar;
lua_getinfo(L, 0, "f", &ar);
lua_getfenv(L, -1);
std::vector<Variable> globals;
lua_pushnil(L);
while (lua_next(L, LUA_GLOBALSINDEX)) {
while (lua_next(L, -2)) {
std::string name = lua_utils::type::toString(L, -2);
globals.emplace_back(createVariable(L, name, -1));
lua_pop(L, 1);
Expand Down

0 comments on commit 8c94015

Please sign in to comment.