| 154 | |
| 155 | |
| 156 | static void PushFunctionEnv(lua_State* L, const char* caller, int funcIndex) { |
| 157 | lua_getfenv(L, funcIndex); |
| 158 | lua_pushliteral(L, "__fenv"); |
| 159 | lua_rawget(L, -2); |
| 160 | if (lua_isnil(L, -1)) { |
| 161 | lua_pop(L, 1); // there is no fenv proxy |
| 162 | } |
| 163 | else { |
| 164 | lua_remove(L, -2); // remove the orig table, leave the proxy |
| 165 | } |
| 166 | |
| 167 | if (!lua_istable(L, -1)) { |
| 168 | luaL_error(L, "%s() invalid fenv", caller); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | |
| 173 | void LuaUtils::PushCurrentFuncEnv(lua_State* L, const char* caller) { |
no test coverage detected