| 4590 | |
| 4591 | |
| 4592 | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { |
| 4593 | int status; |
| 4594 | CallInfo *ci; |
| 4595 | lua_lock(L); |
| 4596 | for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { |
| 4597 | level--; |
| 4598 | if (f_isLua(ci)) /* Lua function? */ |
| 4599 | level -= ci->tailcalls; /* skip lost tail calls */ |
| 4600 | } |
| 4601 | if (level == 0 && ci > L->base_ci) { /* level found? */ |
| 4602 | status = 1; |
| 4603 | ar->i_ci = cast_int(ci - L->base_ci); |
| 4604 | } |
| 4605 | else if (level < 0) { /* level is of a lost tail call? */ |
| 4606 | status = 1; |
| 4607 | ar->i_ci = 0; |
| 4608 | } |
| 4609 | else status = 0; /* no such level */ |
| 4610 | lua_unlock(L); |
| 4611 | return status; |
| 4612 | } |
| 4613 | |
| 4614 | |
| 4615 | static Proto *getluaproto (CallInfo *ci) { |
no outgoing calls
no test coverage detected