| 10979 | |
| 10980 | |
| 10981 | static void getfunc (lua_State *L, int opt) { |
| 10982 | if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); |
| 10983 | else { |
| 10984 | lua_Debug ar; |
| 10985 | int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); |
| 10986 | luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); |
| 10987 | if (lua_getstack(L, level, &ar) == 0) |
| 10988 | luaL_argerror(L, 1, "invalid level"); |
| 10989 | lua_getinfo(L, "f", &ar); |
| 10990 | if (lua_isnil(L, -1)) |
| 10991 | luaL_error(L, "no function environment for tail call at level %d", |
| 10992 | level); |
| 10993 | } |
| 10994 | } |
| 10995 | |
| 10996 | |
| 10997 | static int luaB_getfenv (lua_State *L) { |
no test coverage detected