| 665 | |
| 666 | |
| 667 | void luaG_traceexec (lua_State *L) { |
| 668 | CallInfo *ci = L->ci; |
| 669 | lu_byte mask = L->hookmask; |
| 670 | int counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT)); |
| 671 | if (counthook) |
| 672 | resethookcount(L); /* reset count */ |
| 673 | else if (!(mask & LUA_MASKLINE)) |
| 674 | return; /* no line hook and count != 0; nothing to be done */ |
| 675 | if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ |
| 676 | ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ |
| 677 | return; /* do not call hook again (VM yielded, so it did not move) */ |
| 678 | } |
| 679 | if (counthook) |
| 680 | luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ |
| 681 | if (mask & LUA_MASKLINE) { |
| 682 | Proto *p = ci_func(ci)->p; |
| 683 | int npc = pcRel(ci->u.l.savedpc, p); |
| 684 | int newline = getfuncline(p, npc); |
| 685 | if (npc == 0 || /* call linehook when enter a new function, */ |
| 686 | ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ |
| 687 | newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */ |
| 688 | luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ |
| 689 | } |
| 690 | L->oldpc = ci->u.l.savedpc; |
| 691 | if (L->status == LUA_YIELD) { /* did hook yield? */ |
| 692 | if (counthook) |
| 693 | L->hookcount = 1; /* undo decrement to zero */ |
| 694 | ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ |
| 695 | ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ |
| 696 | ci->func = L->top - 1; /* protect stack below results */ |
| 697 | luaD_throw(L, LUA_YIELD); |
| 698 | } |
| 699 | } |
| 700 |
nothing calls this directly
no test coverage detected