** 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'. */
| 862 | ** so it goes directly to 'luaG_getfuncline'. |
| 863 | */ |
| 864 | static int changedline (const Proto *p, int oldpc, int newpc) { |
| 865 | if (p->lineinfo == NULL) /* no debug information? */ |
| 866 | return 0; |
| 867 | if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */ |
| 868 | int delta = 0; /* line difference */ |
| 869 | int pc = oldpc; |
| 870 | for (;;) { |
| 871 | int lineinfo = p->lineinfo[++pc]; |
| 872 | if (lineinfo == ABSLINEINFO) |
| 873 | break; /* cannot compute delta; fall through */ |
| 874 | delta += lineinfo; |
| 875 | if (pc == newpc) |
| 876 | return (delta != 0); /* delta computed successfully */ |
| 877 | } |
| 878 | } |
| 879 | /* either instructions are too far apart or there is an absolute line |
| 880 | info in the way; compute line difference explicitly */ |
| 881 | return (luaG_getfuncline(p, oldpc) != luaG_getfuncline(p, newpc)); |
| 882 | } |
| 883 | |
| 884 | |
| 885 | /* |
no test coverage detected