** Get a "base line" to find the line corresponding to an instruction. ** Base lines are regularly placed at MAXIWTHABS intervals, so usually ** an integer division gets the right place. When the source file has ** large sequences of empty/comment lines, it may need extra entries, ** so the original estimate needs a correction. ** If the original estimate is -1, the initial 'if' ensures that the *
| 58 | ** smaller value.) |
| 59 | */ |
| 60 | static int getbaseline (const Proto *f, int pc, int *basepc) { |
| 61 | if (f->sizeabslineinfo == 0 || pc < f->abslineinfo[0].pc) { |
| 62 | *basepc = -1; /* start from the beginning */ |
| 63 | return f->linedefined; |
| 64 | } |
| 65 | else { |
| 66 | int i = cast_uint(pc) / MAXIWTHABS - 1; /* get an estimate */ |
| 67 | /* estimate must be a lower bond of the correct base */ |
| 68 | lua_assert(i < 0 || |
| 69 | (i < f->sizeabslineinfo && f->abslineinfo[i].pc <= pc)); |
| 70 | while (i + 1 < f->sizeabslineinfo && pc >= f->abslineinfo[i + 1].pc) |
| 71 | i++; /* low estimate; adjust it */ |
| 72 | *basepc = f->abslineinfo[i].pc; |
| 73 | return f->abslineinfo[i].line; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | |
| 78 | /* |