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

Function getobjname

Source/Misc/lua/src/lua.c:5005–5049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5003
5004
5005static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
5006const char **name) {
5007if (isLua(ci)) { /* a Lua function? */
5008Proto *p = ci_func(ci)->l.p;
5009int pc = currentpc(L, ci);
5010Instruction i;
5011*name = luaF_getlocalname(p, stackpos+1, pc);
5012if (*name) /* is a local? */
5013return "local";
5014i = symbexec(p, pc, stackpos); /* try symbolic execution */
5015lua_assert(pc != -1);
5016switch (GET_OPCODE(i)) {
5017case OP_GETGLOBAL: {
5018int g = GETARG_Bx(i); /* global index */
5019lua_assert(ttisstring(&p->k[g]));
5020*name = svalue(&p->k[g]);
5021return "global";
5022}
5023case OP_MOVE: {
5024int a = GETARG_A(i);
5025int b = GETARG_B(i); /* move from `b' to `a' */
5026if (b < a)
5027return getobjname(L, ci, b, name); /* get name for `b' */
5028break;
5029}
5030case OP_GETTABLE: {
5031int k = GETARG_C(i); /* key index */
5032*name = kname(p, k);
5033return "field";
5034}
5035case OP_GETUPVAL: {
5036int u = GETARG_B(i); /* upvalue index */
5037*name = p->upvalues ? getstr(p->upvalues[u]) : "?";
5038return "upvalue";
5039}
5040case OP_SELF: {
5041int k = GETARG_C(i); /* key index */
5042*name = kname(p, k);
5043return "method";
5044}
5045default: break;
5046}
5047}
5048return NULL; /* no useful name found */
5049}
5050
5051
5052static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {

Callers 2

getfuncnameFunction · 0.85
luaG_typeerrorFunction · 0.85

Calls 4

currentpcFunction · 0.85
luaF_getlocalnameFunction · 0.85
symbexecFunction · 0.85
knameFunction · 0.85

Tested by

no test coverage detected