| 308 | |
| 309 | |
| 310 | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { |
| 311 | int status; |
| 312 | Closure *cl; |
| 313 | CallInfo *ci; |
| 314 | StkId func; |
| 315 | lua_lock(L); |
| 316 | swapextra(L); |
| 317 | if (*what == '>') { |
| 318 | ci = NULL; |
| 319 | func = L->top - 1; |
| 320 | api_check(L, ttisfunction(func), "function expected"); |
| 321 | what++; /* skip the '>' */ |
| 322 | L->top--; /* pop function */ |
| 323 | } |
| 324 | else { |
| 325 | ci = ar->i_ci; |
| 326 | func = ci->func; |
| 327 | lua_assert(ttisfunction(ci->func)); |
| 328 | } |
| 329 | cl = ttisclosure(func) ? clvalue(func) : NULL; |
| 330 | status = auxgetinfo(L, what, ar, cl, ci); |
| 331 | if (strchr(what, 'f')) { |
| 332 | setobjs2s(L, L->top, func); |
| 333 | api_incr_top(L); |
| 334 | } |
| 335 | swapextra(L); /* correct before option 'L', which can raise a mem. error */ |
| 336 | if (strchr(what, 'L')) |
| 337 | collectvalidlines(L, cl); |
| 338 | lua_unlock(L); |
| 339 | return status; |
| 340 | } |
| 341 | |
| 342 | |
| 343 | /* |
no test coverage detected