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

Function getfuncname

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

Source from the content-addressed store, hash-verified

496
497
498static const char *getfuncname(lua_State *L, CallInfo *ci, const char **name) {
499 TMS tm = (TMS)0; /* to avoid warnings */
500 Proto *p = ci_func(ci)->p; /* calling function */
501 int pc = currentpc(ci); /* calling instruction index */
502 Instruction i = p->code[pc]; /* calling instruction */
503 if (ci->callstatus & CIST_HOOKED) { /* was it called inside a hook? */
504 *name = "?";
505 return "hook";
506 }
507 switch (GET_OPCODE(i)) {
508 case OP_CALL:
509 case OP_TAILCALL: /* get function name */
510 return getobjname(p, pc, GETARG_A(i), name);
511 case OP_TFORCALL: { /* for iterator */
512 *name = "for iterator";
513 return "for iterator";
514 }
515 /* all other instructions can call only through metamethods */
516 case OP_SELF: case OP_GETTABUP: case OP_GETTABLE:
517 tm = TM_INDEX;
518 break;
519 case OP_SETTABUP: case OP_SETTABLE:
520 tm = TM_NEWINDEX;
521 break;
522 case OP_ADD: case OP_SUB: case OP_MUL: case OP_MOD:
523 case OP_POW: case OP_DIV: case OP_IDIV: case OP_BAND:
524 case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: {
525 int offset = cast_int(GET_OPCODE(i)) - cast_int(OP_ADD); /* ORDER OP */
526 tm = lua_cast(TMS, offset + cast_int(TM_ADD)); /* ORDER TM */
527 break;
528 }
529 case OP_UNM: tm = TM_UNM; break;
530 case OP_BNOT: tm = TM_BNOT; break;
531 case OP_LEN: tm = TM_LEN; break;
532 case OP_CONCAT: tm = TM_CONCAT; break;
533 case OP_EQ: tm = TM_EQ; break;
534 case OP_LT: tm = TM_LT; break;
535 case OP_LE: tm = TM_LE; break;
536 default: lua_assert(0); /* other instructions cannot call a function */
537 }
538 *name = getstr(G(L)->tmname[tm]);
539 return "metamethod";
540}
541
542/* }====================================================== */
543

Callers 1

auxgetinfoFunction · 0.85

Calls 2

currentpcFunction · 0.85
getobjnameFunction · 0.85

Tested by

no test coverage detected