MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaG_traceexec

Function luaG_traceexec

src/Chain/libraries/glua/ldebug.cpp:673–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

luaV_executeFunction · 0.85

Calls 2

luaD_hookFunction · 0.85
luaD_throwFunction · 0.85

Tested by

no test coverage detected