| 82 | |
| 83 | |
| 84 | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { |
| 85 | int status; |
| 86 | CallInfo *ci; |
| 87 | lua_lock(L); |
| 88 | for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { |
| 89 | level--; |
| 90 | if (f_isLua(ci)) /* Lua function? */ |
| 91 | level -= ci->tailcalls; /* skip lost tail calls */ |
| 92 | } |
| 93 | if (level == 0 && ci > L->base_ci) { /* level found? */ |
| 94 | status = 1; |
| 95 | ar->i_ci = cast_int(ci - L->base_ci); |
| 96 | } |
| 97 | else if (level < 0) { /* level is of a lost tail call? */ |
| 98 | status = 1; |
| 99 | ar->i_ci = 0; |
| 100 | } |
| 101 | else status = 0; /* no such level */ |
| 102 | lua_unlock(L); |
| 103 | return status; |
| 104 | } |
| 105 | |
| 106 | |
| 107 | static Proto *getluaproto (CallInfo *ci) { |
no outgoing calls
no test coverage detected