** 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'. */
| 839 | ** so it goes directly to 'luaG_getfuncline'. |
| 840 | */ |
| 841 | static int changedline (const Proto *p, int oldpc, int newpc) { |
| 842 | if (p->lineinfo == NULL) /* no debug information? */ |
| 843 | return 0; |
| 844 | if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */ |
| 845 | int delta = 0; /* line diference */ |
| 846 | int pc = oldpc; |
| 847 | for (;;) { |
| 848 | int lineinfo = p->lineinfo[++pc]; |
| 849 | if (lineinfo == ABSLINEINFO) |
| 850 | break; /* cannot compute delta; fall through */ |
| 851 | delta += lineinfo; |
| 852 | if (pc == newpc) |
| 853 | return (delta != 0); /* delta computed successfully */ |
| 854 | } |
| 855 | } |
| 856 | /* either instructions are too far apart or there is an absolute line |
| 857 | info in the way; compute line difference explicitly */ |
| 858 | return (luaG_getfuncline(p, oldpc) != luaG_getfuncline(p, newpc)); |
| 859 | } |
| 860 | |
| 861 | |
| 862 | /* |
no test coverage detected