| 700 | |
| 701 | |
| 702 | int 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 | |
| 737 | bool Debugger::CreateEnv(lua_State *L, int stackLevel) { |
| 738 | if (!L) { |
nothing calls this directly
no test coverage detected