** 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'. */
| 798 | ** so it goes directly to 'luaG_getfuncline'. |
| 799 | */ |
| 800 | static int changedline (const Proto *p, int oldpc, int newpc) { |
| 801 | if (p->lineinfo == NULL) /* no debug information? */ |
| 802 | return 0; |
| 803 | if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */ |
| 804 | int delta = 0; /* line diference */ |
| 805 | int pc = oldpc; |
| 806 | for (;;) { |
| 807 | int lineinfo = p->lineinfo[++pc]; |
| 808 | if (lineinfo == ABSLINEINFO) |
| 809 | break; /* cannot compute delta; fall through */ |
| 810 | delta += lineinfo; |
| 811 | if (pc == newpc) |
| 812 | return (delta != 0); /* delta computed successfully */ |
| 813 | } |
| 814 | } |
| 815 | /* either instructions are too far apart or there is an absolute line |
| 816 | info in the way; compute line difference explicitly */ |
| 817 | return (luaG_getfuncline(p, oldpc) != luaG_getfuncline(p, newpc)); |
| 818 | } |
| 819 | |
| 820 | |
| 821 | /* |
no test coverage detected