MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / EnvIndexFunction

Function EnvIndexFunction

emmy_debugger/src/debugger/emmy_debugger.cpp:702–735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700
701
702int EnvIndexFunction(lua_State *L) {
703 const int locals = lua_upvalueindex(1);
704 const int upvalues = lua_upvalueindex(2);
705 const char *name = lua_tostring(L, 2);
706 // up value
707 lua_getfield(L, upvalues, name);
708 if (lua_isnil(L, -1) == 0) {
709 return 1;
710 }
711 lua_pop(L, 1);
712 // local value
713 lua_getfield(L, locals, name);
714 if (lua_isnil(L, -1) == 0) {
715 return 1;
716 }
717 lua_pop(L, 1);
718 // _ENV
719 lua_getfield(L, upvalues, "_ENV");
720 if (lua_istable(L, -1)) {
721 lua_getfield(L, -1, name);// _ENV[name]
722 if (lua_isnil(L, -1) == 0) {
723 return 1;
724 }
725 lua_pop(L, 1);
726 }
727 lua_pop(L, 1);
728 // global
729 lua_getglobal(L, name);
730 if (lua_isnil(L, -1) == 0) {
731 return 1;
732 }
733 lua_pop(L, 1);
734 return 0;
735}
736
737bool Debugger::CreateEnv(lua_State *L, int stackLevel) {
738 if (!L) {

Callers

nothing calls this directly

Calls 3

lua_upvalueindexFunction · 0.85
lua_getfieldFunction · 0.50
lua_getglobalFunction · 0.50

Tested by

no test coverage detected