MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / getobjname

Function getobjname

lua/ldebug.c:502–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

getfuncnameFunction · 0.85
luaG_typeerrorFunction · 0.85

Calls 5

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

Tested by

no test coverage detected