MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / getobjname

Function getobjname

deps/lua/src/ldebug.c:497–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495
496
497static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
498 const char **name) {
499 if (isLua(ci)) { /* a Lua function? */
500 Proto *p = ci_func(ci)->l.p;
501 int pc = currentpc(L, ci);
502 Instruction i;
503 *name = luaF_getlocalname(p, stackpos+1, pc);
504 if (*name) /* is a local? */
505 return "local";
506 i = symbexec(p, pc, stackpos); /* try symbolic execution */
507 lua_assert(pc != -1);
508 switch (GET_OPCODE(i)) {
509 case OP_GETGLOBAL: {
510 int g = GETARG_Bx(i); /* global index */
511 lua_assert(ttisstring(&p->k[g]));
512 *name = svalue(&p->k[g]);
513 return "global";
514 }
515 case OP_MOVE: {
516 int a = GETARG_A(i);
517 int b = GETARG_B(i); /* move from `b' to `a' */
518 if (b < a)
519 return getobjname(L, ci, b, name); /* get name for `b' */
520 break;
521 }
522 case OP_GETTABLE: {
523 int k = GETARG_C(i); /* key index */
524 *name = kname(p, k);
525 return "field";
526 }
527 case OP_GETUPVAL: {
528 int u = GETARG_B(i); /* upvalue index */
529 *name = p->upvalues ? getstr(p->upvalues[u]) : "?";
530 return "upvalue";
531 }
532 case OP_SELF: {
533 int k = GETARG_C(i); /* key index */
534 *name = kname(p, k);
535 return "method";
536 }
537 default: break;
538 }
539 }
540 return NULL; /* no useful name found */
541}
542
543
544static 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