** Extend 'basicgetobjname' to handle table accesses */
| 564 | ** Extend 'basicgetobjname' to handle table accesses |
| 565 | */ |
| 566 | static const char *getobjname (const Proto *p, int lastpc, int reg, |
| 567 | const char **name) { |
| 568 | const char *kind = basicgetobjname(p, &lastpc, reg, name); |
| 569 | if (kind != NULL) |
| 570 | return kind; |
| 571 | else if (lastpc != -1) { /* could find instruction? */ |
| 572 | Instruction i = p->code[lastpc]; |
| 573 | OpCode op = GET_OPCODE(i); |
| 574 | switch (op) { |
| 575 | case OP_GETTABUP: { |
| 576 | int k = GETARG_C(i); /* key index */ |
| 577 | kname(p, k, name); |
| 578 | return isEnv(p, lastpc, i, 1); |
| 579 | } |
| 580 | case OP_GETTABLE: { |
| 581 | int k = GETARG_C(i); /* key index */ |
| 582 | rname(p, lastpc, k, name); |
| 583 | return isEnv(p, lastpc, i, 0); |
| 584 | } |
| 585 | case OP_GETI: { |
| 586 | *name = "integer index"; |
| 587 | return "field"; |
| 588 | } |
| 589 | case OP_GETFIELD: { |
| 590 | int k = GETARG_C(i); /* key index */ |
| 591 | kname(p, k, name); |
| 592 | return isEnv(p, lastpc, i, 0); |
| 593 | } |
| 594 | case OP_SELF: { |
| 595 | rkname(p, lastpc, i, name); |
| 596 | return "method"; |
| 597 | } |
| 598 | default: break; /* go through to return NULL */ |
| 599 | } |
| 600 | } |
| 601 | return NULL; /* could not find reasonable name */ |
| 602 | } |
| 603 | |
| 604 | |
| 605 | /* |
no test coverage detected