MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / db_getinfo

Function db_getinfo

Source/Misc/lua/src/lua.c:11615–11657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

getthreadFunction · 0.85
lua_isnumberFunction · 0.85
lua_getstackFunction · 0.85
lua_tointegerFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushfstringFunction · 0.85
lua_pushvalueFunction · 0.85
lua_xmoveFunction · 0.85
luaL_argerrorFunction · 0.85
lua_getinfoFunction · 0.85
lua_createtableFunction · 0.85
settabssFunction · 0.85

Tested by

no test coverage detected