| 493 | |
| 494 | |
| 495 | static const char *basicgetobjname (const Proto *p, int *ppc, int reg, |
| 496 | const char **name) { |
| 497 | int pc = *ppc; |
| 498 | *name = luaF_getlocalname(p, reg + 1, pc); |
| 499 | if (*name) /* is a local? */ |
| 500 | return "local"; |
| 501 | /* else try symbolic execution */ |
| 502 | *ppc = pc = findsetreg(p, pc, reg); |
| 503 | if (pc != -1) { /* could find instruction? */ |
| 504 | Instruction i = p->code[pc]; |
| 505 | OpCode op = GET_OPCODE(i); |
| 506 | switch (op) { |
| 507 | case OP_MOVE: { |
| 508 | int b = GETARG_B(i); /* move from 'b' to 'a' */ |
| 509 | if (b < GETARG_A(i)) |
| 510 | return basicgetobjname(p, ppc, b, name); /* get name for 'b' */ |
| 511 | break; |
| 512 | } |
| 513 | case OP_GETUPVAL: { |
| 514 | *name = upvalname(p, GETARG_B(i)); |
| 515 | return "upvalue"; |
| 516 | } |
| 517 | case OP_LOADK: return kname(p, GETARG_Bx(i), name); |
| 518 | case OP_LOADKX: return kname(p, GETARG_Ax(p->code[pc + 1]), name); |
| 519 | default: break; |
| 520 | } |
| 521 | } |
| 522 | return NULL; /* could not find reasonable name */ |
| 523 | } |
| 524 | |
| 525 | |
| 526 | /* |
no test coverage detected