MCPcopy Create free account
hub / github.com/F-Stack/f-stack / getobjname

Function getobjname

freebsd/contrib/openzfs/module/lua/ldebug.c:405–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403
404
405static const char *getobjname (Proto *p, int lastpc, int reg,
406 const char **name) {
407 int pc;
408 *name = luaF_getlocalname(p, reg + 1, lastpc);
409 if (*name) /* is a local? */
410 return "local";
411 /* else try symbolic execution */
412 pc = findsetreg(p, lastpc, reg);
413 if (pc != -1) { /* could find instruction? */
414 Instruction i = p->code[pc];
415 OpCode op = GET_OPCODE(i);
416 switch (op) {
417 case OP_MOVE: {
418 int b = GETARG_B(i); /* move from 'b' to 'a' */
419 if (b < GETARG_A(i))
420 return getobjname(p, pc, b, name); /* get name for 'b' */
421 break;
422 }
423 case OP_GETTABUP:
424 case OP_GETTABLE: {
425 int k = GETARG_C(i); /* key index */
426 int t = GETARG_B(i); /* table index */
427 const char *vn = (op == OP_GETTABLE) /* name of indexed variable */
428 ? luaF_getlocalname(p, t + 1, pc)
429 : upvalname(p, t);
430 kname(p, pc, k, name);
431 return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field";
432 }
433 case OP_GETUPVAL: {
434 *name = upvalname(p, GETARG_B(i));
435 return "upvalue";
436 }
437 case OP_LOADK:
438 case OP_LOADKX: {
439 int b = (op == OP_LOADK) ? GETARG_Bx(i)
440 : GETARG_Ax(p->code[pc + 1]);
441 if (ttisstring(&p->k[b])) {
442 *name = svalue(&p->k[b]);
443 return "constant";
444 }
445 break;
446 }
447 case OP_SELF: {
448 int k = GETARG_C(i); /* key index */
449 kname(p, pc, k, name);
450 return "method";
451 }
452 default: break; /* go through to return NULL */
453 }
454 }
455 return NULL; /* could not find reasonable name */
456}
457
458
459static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {

Callers 3

knameFunction · 0.70
getfuncnameFunction · 0.70
luaG_typeerrorFunction · 0.70

Calls 5

findsetregFunction · 0.85
upvalnameFunction · 0.85
strcmpFunction · 0.85
luaF_getlocalnameFunction · 0.70
knameFunction · 0.70

Tested by

no test coverage detected