MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / PushFunctionEnv

Function PushFunctionEnv

src/lua/LuaUtils.cpp:156–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154
155
156static 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
173void LuaUtils::PushCurrentFuncEnv(lua_State* L, const char* caller) {

Callers 1

PushCurrentFuncEnvMethod · 0.85

Calls 4

lua_getfenvFunction · 0.50
lua_rawgetFunction · 0.50
lua_removeFunction · 0.50
luaL_errorFunction · 0.50

Tested by

no test coverage detected