Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/core/ldebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ int luaG_getfuncline (const Proto *f, int pc) {
else {
int basepc;
int baseline = getbaseline(f, pc, &basepc);
while (basepc++ < pc) { /* walk until given instruction */
lua_assert(lineInfoSpan[basepc] != ABSLINEINFO);
baseline += lineInfoSpan[basepc]; /* correct line */
/* Walk from basepc+1 to pc (inclusive), accumulating line deltas */
for (size_t i = static_cast<size_t>(basepc + 1); i <= static_cast<size_t>(pc); i++) {
lua_assert(lineInfoSpan[i] != ABSLINEINFO);
baseline += lineInfoSpan[i]; /* correct line */
}
return baseline;
}
Expand Down Expand Up @@ -295,12 +296,12 @@ static void funcinfo (lua_Debug *ar, Closure *cl) {


// Phase 115.2: Use span accessors
static int nextline (const Proto *p, int currentline, int pc) {
static int nextline (const Proto *p, int currentline, size_t pc) {
auto lineInfoSpan = p->getDebugInfo().getLineInfoSpan();
if (lineInfoSpan[pc] != ABSLINEINFO)
return currentline + lineInfoSpan[pc];
else
return luaG_getfuncline(p, pc);
return luaG_getfuncline(p, static_cast<int>(pc));
}


Expand All @@ -317,7 +318,7 @@ static void collectvalidlines (lua_State *L, Closure *f) {
api_incr_top(L);
auto lineInfoSpan = p->getDebugInfo().getLineInfoSpan();
if (!lineInfoSpan.empty()) { /* proto with debug information? */
int i;
size_t i;
TValue v;
setbtvalue(&v); /* boolean 'true' to be the value of all indices */
if (!(p->getFlag() & PF_ISVARARG)) /* regular function? */
Expand All @@ -328,7 +329,7 @@ static void collectvalidlines (lua_State *L, Closure *f) {
currentline = nextline(p, currentline, 0);
i = 1; /* skip first instruction (OP_VARARGPREP) */
}
for (; i < static_cast<int>(lineInfoSpan.size()); i++) { /* for each instruction */
for (; i < lineInfoSpan.size(); i++) { /* for each instruction */
currentline = nextline(p, currentline, i); /* get its line */
luaH_setint(L, t, currentline, &v); /* table[line] = true */
}
Expand Down Expand Up @@ -953,13 +954,14 @@ static int changedline (const Proto *p, int oldpc, int newpc) {
return 0;
if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */
int delta = 0; /* line difference */
int pc = oldpc;
size_t pc = static_cast<size_t>(oldpc);
for (;;) {
int lineinfo = lineInfoSpan[++pc];
++pc;
int lineinfo = lineInfoSpan[pc];
if (lineinfo == ABSLINEINFO)
break; /* cannot compute delta; fall through */
delta += lineinfo;
if (pc == newpc)
if (static_cast<int>(pc) == newpc)
return (delta != 0); /* delta computed successfully */
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/objects/ltable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class NodeArray {
// Large table: allocate Limbox + Node[]
// LAYOUT: [Limbox header][Node array of size n]
// Verify no overflow in size calculation
if (n > (MAX_SIZET - sizeof(Limbox)) / sizeof(Node)) {
if (static_cast<size_t>(n) > (MAX_SIZET - sizeof(Limbox)) / sizeof(Node)) {
luaG_runerror(L, "table size overflow");
}
size_t total = sizeof(Limbox) + n * sizeof(Node);
Expand Down
11 changes: 4 additions & 7 deletions src/serialization/lundump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,14 @@ static void loadFunction(LoadState *S, Proto *f);

// Phase 115.2: Use span accessors
static void loadConstants (LoadState *S, Proto *f) {
int i;
int n = loadInt(S);
f->setConstants(luaM_newvectorchecked(S->L, n, TValue));
f->setConstantsSize(n);
auto constantsSpan = f->getConstantsSpan();
for (TValue& v : constantsSpan) {
setnilvalue(&v);
}
for (i = 0; i < n; i++) {
for (size_t i = 0; i < static_cast<size_t>(n); i++) {
TValue *o = &constantsSpan[i];
int t = loadByte(S);
switch (t) {
Expand Down Expand Up @@ -278,7 +277,6 @@ static void loadProtos (LoadState *S, Proto *f) {
*/
// Phase 115.2: Use span accessors
static void loadUpvalues (LoadState *S, Proto *f) {
int i;
int n = loadInt(S);
f->setUpvalues(luaM_newvectorchecked(S->L, n, Upvaldesc));
f->setUpvaluesSize(n);
Expand All @@ -287,7 +285,7 @@ static void loadUpvalues (LoadState *S, Proto *f) {
for (Upvaldesc& uv : upvaluesSpan) {
uv.setName(nullptr);
}
for (i = 0; i < n; i++) { /* following calls can raise errors */
for (size_t i = 0; i < static_cast<size_t>(n); i++) { /* following calls can raise errors */
upvaluesSpan[i].setInStack(loadByte(S));
upvaluesSpan[i].setIndex(loadByte(S));
upvaluesSpan[i].setKind(loadByte(S));
Expand All @@ -297,7 +295,6 @@ static void loadUpvalues (LoadState *S, Proto *f) {

// Phase 115.2: Use span accessors
static void loadDebug (LoadState *S, Proto *f) {
int i;
int n = loadInt(S);
if (S->fixed) {
f->setLineInfo(getaddr(S, n, ls_byte));
Expand Down Expand Up @@ -330,7 +327,7 @@ static void loadDebug (LoadState *S, Proto *f) {
for (LocVar& lv : locVarsSpan) {
lv.setVarName(nullptr);
}
for (i = 0; i < n; i++) {
for (size_t i = 0; i < static_cast<size_t>(n); i++) {
loadString(S, f, locVarsSpan[i].getVarNamePtr());
locVarsSpan[i].setStartPC(loadInt(S));
locVarsSpan[i].setEndPC(loadInt(S));
Expand All @@ -339,7 +336,7 @@ static void loadDebug (LoadState *S, Proto *f) {
if (n != 0) /* does it have debug information? */
n = f->getUpvaluesSize(); /* must be this many */
auto upvaluesSpan = f->getUpvaluesSpan();
for (i = 0; i < n; i++)
for (size_t i = 0; i < static_cast<size_t>(n); i++)
loadString(S, f, upvaluesSpan[i].getNamePtr());
}

Expand Down
Loading