MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / getobjname

Function getobjname

src/Chain/libraries/glua/ldebug.cpp:444–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442
443
444static const char *getobjname(Proto *p, int lastpc, int reg,
445 const char **name) {
446 int pc;
447 *name = luaF_getlocalname(p, reg + 1, lastpc);
448 if (*name) /* is a local? */
449 return "local";
450 /* else try symbolic execution */
451 pc = findsetreg(p, lastpc, reg);
452 if (pc != -1) { /* could find instruction? */
453 Instruction i = p->code[pc];
454 OpCode op = GET_OPCODE(i);
455 switch (op) {
456 case OP_MOVE: {
457 int b = GETARG_B(i); /* move from 'b' to 'a' */
458 if (b < GETARG_A(i))
459 return getobjname(p, pc, b, name); /* get name for 'b' */
460 break;
461 }
462 case OP_GETTABUP:
463 case OP_GETTABLE: {
464 int k = GETARG_C(i); /* key index */
465 int t = GETARG_B(i); /* table index */
466 const char *vn = (op == OP_GETTABLE) /* name of indexed variable */
467 ? luaF_getlocalname(p, t + 1, pc)
468 : upvalname(p, t);
469 kname(p, pc, k, name);
470 return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field";
471 }
472 case OP_GETUPVAL: {
473 *name = upvalname(p, GETARG_B(i));
474 return "upvalue";
475 }
476 case OP_LOADK:
477 case OP_LOADKX: {
478 int b = (op == OP_LOADK) ? GETARG_Bx(i)
479 : GETARG_Ax(p->code[pc + 1]);
480 if (ttisstring(&p->k[b])) {
481 *name = svalue(&p->k[b]);
482 return "constant";
483 }
484 break;
485 }
486 case OP_SELF: {
487 int k = GETARG_C(i); /* key index */
488 kname(p, pc, k, name);
489 return "method";
490 }
491 default: break; /* go through to return nullptr */
492 }
493 }
494 return nullptr; /* could not find reasonable name */
495}
496
497
498static const char *getfuncname(lua_State *L, CallInfo *ci, const char **name) {

Callers 3

knameFunction · 0.85
getfuncnameFunction · 0.85
varinfoFunction · 0.85

Calls 4

luaF_getlocalnameFunction · 0.85
findsetregFunction · 0.85
upvalnameFunction · 0.85
knameFunction · 0.85

Tested by

no test coverage detected