| 457 | |
| 458 | |
| 459 | static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { |
| 460 | TMS tm; |
| 461 | Proto *p = ci_func(ci)->p; /* calling function */ |
| 462 | int pc = currentpc(ci); /* calling instruction index */ |
| 463 | Instruction i = p->code[pc]; /* calling instruction */ |
| 464 | switch (GET_OPCODE(i)) { |
| 465 | case OP_CALL: |
| 466 | case OP_TAILCALL: /* get function name */ |
| 467 | return getobjname(p, pc, GETARG_A(i), name); |
| 468 | case OP_TFORCALL: { /* for iterator */ |
| 469 | *name = "for iterator"; |
| 470 | return "for iterator"; |
| 471 | } |
| 472 | /* all other instructions can call only through metamethods */ |
| 473 | case OP_SELF: |
| 474 | case OP_GETTABUP: |
| 475 | case OP_GETTABLE: tm = TM_INDEX; break; |
| 476 | case OP_SETTABUP: |
| 477 | case OP_SETTABLE: tm = TM_NEWINDEX; break; |
| 478 | case OP_EQ: tm = TM_EQ; break; |
| 479 | case OP_ADD: tm = TM_ADD; break; |
| 480 | case OP_SUB: tm = TM_SUB; break; |
| 481 | case OP_MUL: tm = TM_MUL; break; |
| 482 | case OP_DIV: tm = TM_DIV; break; |
| 483 | case OP_MOD: tm = TM_MOD; break; |
| 484 | case OP_POW: tm = TM_POW; break; |
| 485 | case OP_UNM: tm = TM_UNM; break; |
| 486 | case OP_LEN: tm = TM_LEN; break; |
| 487 | case OP_LT: tm = TM_LT; break; |
| 488 | case OP_LE: tm = TM_LE; break; |
| 489 | case OP_CONCAT: tm = TM_CONCAT; break; |
| 490 | default: |
| 491 | return NULL; /* else no useful name can be found */ |
| 492 | } |
| 493 | *name = getstr(G(L)->tmname[tm]); |
| 494 | return "metamethod"; |
| 495 | } |
| 496 | |
| 497 | /* }====================================================== */ |
| 498 |
no test coverage detected