MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaG_traceexec

Function luaG_traceexec

extlibs/lua/src/ldebug.c:796–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794
795
796int luaG_traceexec (lua_State *L, const Instruction *pc) {
797 CallInfo *ci = L->ci;
798 lu_byte mask = L->hookmask;
799 int counthook;
800 if (!(mask & (LUA_MASKLINE | LUA_MASKCOUNT))) { /* no hooks? */
801 ci->u.l.trap = 0; /* don't need to stop again */
802 return 0; /* turn off 'trap' */
803 }
804 pc++; /* reference is always next instruction */
805 ci->u.l.savedpc = pc; /* save 'pc' */
806 counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT));
807 if (counthook)
808 resethookcount(L); /* reset count */
809 else if (!(mask & LUA_MASKLINE))
810 return 1; /* no line hook and count != 0; nothing to be done now */
811 if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */
812 ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */
813 return 1; /* do not call hook again (VM yielded, so it did not move) */
814 }
815 if (!isIT(*(ci->u.l.savedpc - 1)))
816 L->top = ci->top; /* prepare top */
817 if (counthook)
818 luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */
819 if (mask & LUA_MASKLINE) {
820 const Proto *p = ci_func(ci)->p;
821 int npci = pcRel(pc, p);
822 if (npci == 0 || /* call linehook when enter a new function, */
823 pc <= L->oldpc || /* when jump back (loop), or when */
824 changedline(p, pcRel(L->oldpc, p), npci)) { /* enter new line */
825 int newline = luaG_getfuncline(p, npci);
826 luaD_hook(L, LUA_HOOKLINE, newline, 0, 0); /* call line hook */
827 }
828 L->oldpc = pc; /* 'pc' of last call to line hook */
829 }
830 if (L->status == LUA_YIELD) { /* did hook yield? */
831 if (counthook)
832 L->hookcount = 1; /* undo decrement to zero */
833 ci->u.l.savedpc--; /* undo increment (resume will increment it again) */
834 ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */
835 luaD_throw(L, LUA_YIELD);
836 }
837 return 1; /* keep 'trap' on */
838}
839

Callers 1

lvm.cFile · 0.85

Calls 4

luaD_hookFunction · 0.85
changedlineFunction · 0.85
luaG_getfunclineFunction · 0.85
luaD_throwFunction · 0.85

Tested by

no test coverage detected