MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / getbaseline

Function getbaseline

3rd/lua-5.4.3/src/ldebug.c:60–75  ·  view source on GitHub ↗

** 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 *

Source from the content-addressed store, hash-verified

58** smaller value.)
59*/
60static 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/*

Callers 1

luaG_getfunclineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected