MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / changedline

Function changedline

third-party/lua-5.5.0/src/ldebug.c:881–899  ·  view source on GitHub ↗

** Check whether new instruction 'newpc' is in a different line from ** previous instruction 'oldpc'. More often than not, 'newpc' is only ** one or a few instructions after 'oldpc' (it must be after, see ** caller), so try to avoid calling 'luaG_getfuncline'. If they are ** too far apart, there is a good chance of a ABSLINEINFO in the way, ** so it goes directly to 'luaG_getfuncline'. */

Source from the content-addressed store, hash-verified

879** so it goes directly to 'luaG_getfuncline'.
880*/
881static int changedline (const Proto *p, int oldpc, int newpc) {
882 if (p->lineinfo == NULL) /* no debug information? */
883 return 0;
884 if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */
885 int delta = 0; /* line difference */
886 int pc = oldpc;
887 for (;;) {
888 int lineinfo = p->lineinfo[++pc];
889 if (lineinfo == ABSLINEINFO)
890 break; /* cannot compute delta; fall through */
891 delta += lineinfo;
892 if (pc == newpc)
893 return (delta != 0); /* delta computed successfully */
894 }
895 }
896 /* either instructions are too far apart or there is an absolute line
897 info in the way; compute line difference explicitly */
898 return (luaG_getfuncline(p, oldpc) != luaG_getfuncline(p, newpc));
899}
900
901
902/*

Callers 1

luaG_traceexecFunction · 0.70

Calls 1

luaG_getfunclineFunction · 0.70

Tested by

no test coverage detected