| 115 | |
| 116 | |
| 117 | static void getfunc (lua_State *L, int opt) { |
| 118 | if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); |
| 119 | else { |
| 120 | lua_Debug ar; |
| 121 | int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); |
| 122 | luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); |
| 123 | if (lua_getstack(L, level, &ar) == 0) |
| 124 | luaL_argerror(L, 1, "invalid level"); |
| 125 | lua_getinfo(L, "f", &ar); |
| 126 | if (lua_isnil(L, -1)) |
| 127 | luaL_error(L, "no function environment for tail call at level %d", |
| 128 | level); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | |
| 133 | static int luaB_getfenv (lua_State *L) { |
no test coverage detected