Small cleanup (#11185)

* Remove mStaticTy and mTypeTy

* Replace countup(x, y-1) with x ..< y

* Replace countup(x, y) with x .. y
This commit is contained in:
Andreas Rumpf 2019-05-08 17:18:46 +02:00 • committed by GitHub
commit 61380d0a07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 418 additions and 424 deletions

View file

@ -65,7 +65,7 @@ proc genVarTuple(p: BProc, n: PNode) =
var L = sonsLen(n)
# if we have a something that's been captured, use the lowering instead:
for i in countup(0, L-3):
for i in 0 .. L-3:
if n[i].kind != nkSym:
genStmts(p, lowerTupleUnpacking(p.module.g.graph, n, p.prc))
return
@ -87,7 +87,7 @@ proc genVarTuple(p: BProc, n: PNode) =
genLineDir(p, n)
initLocExpr(p, n.sons[L-1], tup)
var t = tup.t.skipTypes(abstractInst)
for i in countup(0, L-3):
for i in 0 .. L-3:
let vn = n.sons[i]
let v = vn.sym
if sfCompileTime in v.flags: continue
@ -201,7 +201,7 @@ proc blockLeaveActions(p: BProc, howManyTrys, howManyExcepts: int) =
var stack = newSeq[tuple[n: PNode, inExcept: bool]](0)
for i in countup(1, howManyTrys):
for i in 1 .. howManyTrys:
let tryStmt = p.nestedTryStmts.pop
if not p.module.compileToCpp or optNoCppExceptions in p.config.globalOptions:
# Pop safe points generated by try
@ -706,7 +706,7 @@ template genCaseGenericBranch(p: BProc, b: PNode, e: TLoc,
var
x, y: TLoc
var length = sonsLen(b)
for i in countup(0, length - 2):
for i in 0 .. length - 2:
if b.sons[i].kind == nkRange:
initLocExpr(p, b.sons[i].sons[0], x)
initLocExpr(p, b.sons[i].sons[1], y)
@ -765,7 +765,7 @@ proc genCaseStringBranch(p: BProc, b: PNode, e: TLoc, labl: TLabel,
branches: var openArray[Rope]) =
var x: TLoc
var length = sonsLen(b)
for i in countup(0, length - 2):
for i in 0 .. length - 2:
assert(b.sons[i].kind != nkRange)
initLocExpr(p, b.sons[i], x)
assert(b.sons[i].kind in {nkStrLit..nkTripleStrLit})
@ -776,7 +776,7 @@ proc genCaseStringBranch(p: BProc, b: PNode, e: TLoc, labl: TLabel,
proc genStringCase(p: BProc, t: PNode, d: var TLoc) =
# count how many constant strings there are in the case:
var strings = 0
for i in countup(1, sonsLen(t) - 1):
for i in 1 ..< sonsLen(t):
if t.sons[i].kind == nkOfBranch: inc(strings, sonsLen(t.sons[i]) - 1)
if strings > stringCaseThreshold:
var bitMask = math.nextPowerOfTwo(strings) - 1
@ -785,7 +785,7 @@ proc genStringCase(p: BProc, t: PNode, d: var TLoc) =
var a: TLoc
initLocExpr(p, t.sons[0], a) # fist pass: gnerate ifs+goto:
var labId = p.labels
for i in countup(1, sonsLen(t) - 1):
for i in 1 ..< sonsLen(t):
inc(p.labels)
if t.sons[i].kind == nkOfBranch:
genCaseStringBranch(p, t.sons[i], a, "LA" & rope(p.labels) & "_",
@ -796,7 +796,7 @@ proc genStringCase(p: BProc, t: PNode, d: var TLoc) =
discard
linefmt(p, cpsStmts, "switch (#hashString($1) & $2) {$n",
[rdLoc(a), bitMask])
for j in countup(0, high(branches)):
for j in 0 .. high(branches):
if branches[j] != nil:
lineF(p, cpsStmts, "case $1: $n$2break;$n",
[intLiteral(j), branches[j]])
@ -810,7 +810,7 @@ proc genStringCase(p: BProc, t: PNode, d: var TLoc) =
genCaseGeneric(p, t, d, "", "if (#eqStrings($1, $2)) goto $3;$n")
proc branchHasTooBigRange(b: PNode): bool =
for i in countup(0, sonsLen(b)-2):
for i in 0 .. sonsLen(b)-2:
# last son is block
if (b.sons[i].kind == nkRange) and
b.sons[i].sons[1].intVal - b.sons[i].sons[0].intVal > RangeExpandLimit:
@ -1051,7 +1051,7 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) =
endBlock(p)
else:
var orExpr: Rope = nil
for j in countup(0, blen - 2):
for j in 0 .. blen - 2:
assert(t.sons[i].sons[j].kind == nkType)
if orExpr != nil: add(orExpr, "||")
let checkFor = if optNimV2 in p.config.globalOptions: