| 11613 | |
| 11614 | |
| 11615 | static int db_getinfo (lua_State *L) { |
| 11616 | lua_Debug ar; |
| 11617 | int arg; |
| 11618 | lua_State *L1 = getthread(L, &arg); |
| 11619 | const char *options = luaL_optstring(L, arg+2, "flnSu"); |
| 11620 | if (lua_isnumber(L, arg+1)) { |
| 11621 | if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { |
| 11622 | lua_pushnil(L); /* level out of range */ |
| 11623 | return 1; |
| 11624 | } |
| 11625 | } |
| 11626 | else if (lua_isfunction(L, arg+1)) { |
| 11627 | lua_pushfstring(L, ">%s", options); |
| 11628 | options = lua_tostring(L, -1); |
| 11629 | lua_pushvalue(L, arg+1); |
| 11630 | lua_xmove(L, L1, 1); |
| 11631 | } |
| 11632 | else |
| 11633 | return luaL_argerror(L, arg+1, "function or level expected"); |
| 11634 | if (!lua_getinfo(L1, options, &ar)) |
| 11635 | return luaL_argerror(L, arg+2, "invalid option"); |
| 11636 | lua_createtable(L, 0, 2); |
| 11637 | if (strchr(options, 'S')) { |
| 11638 | settabss(L, "source", ar.source); |
| 11639 | settabss(L, "short_src", ar.short_src); |
| 11640 | settabsi(L, "linedefined", ar.linedefined); |
| 11641 | settabsi(L, "lastlinedefined", ar.lastlinedefined); |
| 11642 | settabss(L, "what", ar.what); |
| 11643 | } |
| 11644 | if (strchr(options, 'l')) |
| 11645 | settabsi(L, "currentline", ar.currentline); |
| 11646 | if (strchr(options, 'u')) |
| 11647 | settabsi(L, "nups", ar.nups); |
| 11648 | if (strchr(options, 'n')) { |
| 11649 | settabss(L, "name", ar.name); |
| 11650 | settabss(L, "namewhat", ar.namewhat); |
| 11651 | } |
| 11652 | if (strchr(options, 'L')) |
| 11653 | treatstackoption(L, L1, "activelines"); |
| 11654 | if (strchr(options, 'f')) |
| 11655 | treatstackoption(L, L1, "func"); |
| 11656 | return 1; /* return table */ |
| 11657 | } |
| 11658 | |
| 11659 | |
| 11660 | static int db_getlocal (lua_State *L) { |
nothing calls this directly
no test coverage detected