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

This commit is contained in:
Clyybber 2019-05-07 12:04:00 +02:00
commit f18b3af9d4
58 changed files with 312 additions and 312 deletions

View file

@ -101,7 +101,7 @@ proc bitSetToWord(s: TBitSet, size: int): BiggestInt =
proc genRawSetData(cs: TBitSet, size: int): Rope =
if size > 8:
result = "{$n" % []
for i in countup(0, size - 1):
for i in 0 ..< size:
if i < size - 1:
# not last iteration?
if (i + 1) mod 8 == 0:
@ -849,7 +849,7 @@ proc genInExprAux(p: BProc, e: PNode, a, b, d: var TLoc)
proc genFieldCheck(p: BProc, e: PNode, obj: Rope, field: PSym) =
var test, u, v: TLoc
for i in countup(1, sonsLen(e) - 1):
for i in 1 ..< sonsLen(e):
var it = e.sons[i]
assert(it.kind in nkCallKinds)
assert(it.sons[0].kind == nkSym)
@ -1451,7 +1451,7 @@ proc genSeqConstr(p: BProc, n: PNode, d: var TLoc) =
# generate call to newSeq before adding the elements per hand:
genNewSeqAux(p, dest[], l,
optNilSeqs notin p.options and n.len == 0)
for i in countup(0, sonsLen(n) - 1):
for i in 0 ..< sonsLen(n):
initLoc(arr, locExpr, n[i], OnHeap)
arr.r = ropecg(p.module, "$1$3[$2]", [rdLoc(dest[]), intLiteral(i), dataField(p)])
arr.storage = OnHeap # we know that sequences are on the heap
@ -1483,7 +1483,7 @@ proc genArrToSeq(p: BProc, n: PNode, d: var TLoc) =
initLocExpr(p, n.sons[1], a)
# bug #5007; do not produce excessive C source code:
if L < 10:
for i in countup(0, L - 1):
for i in 0 ..< L:
initLoc(elem, locExpr, lodeTyp elemType(skipTypes(n.typ, abstractInst)), OnHeap)
elem.r = ropecg(p.module, "$1$3[$2]", [rdLoc(d), intLiteral(i), dataField(p)])
elem.storage = OnHeap # we know that sequences are on the heap
@ -1800,7 +1800,7 @@ proc genInOp(p: BProc, e: PNode, d: var TLoc) =
var length = sonsLen(e.sons[1])
if length > 0:
b.r = rope("(")
for i in countup(0, length - 1):
for i in 0 ..< length:
let it = e.sons[1].sons[i]
if it.kind == nkRange:
initLocExpr(p, it.sons[0], x)
@ -2340,7 +2340,7 @@ proc genTupleConstr(p: BProc, n: PNode, d: var TLoc) =
let t = n.typ
discard getTypeDesc(p.module, t) # so that any fields are initialized
if d.k == locNone: getTemp(p, t, d)
for i in countup(0, sonsLen(n) - 1):
for i in 0 ..< sonsLen(n):
var it = n.sons[i]
if it.kind == nkExprColonExpr: it = it.sons[1]
initLoc(rec, locExpr, it, d.storage)
@ -2382,7 +2382,7 @@ proc genArrayConstr(p: BProc, n: PNode, d: var TLoc) =
var arr: TLoc
if not handleConstExpr(p, n, d):
if d.k == locNone: getTemp(p, n.typ, d)
for i in countup(0, sonsLen(n) - 1):
for i in 0 ..< sonsLen(n):
initLoc(arr, locExpr, lodeTyp elemType(skipTypes(n.typ, abstractInst)), d.storage)
arr.r = "$1[$2]" % [rdLoc(d), intLiteral(i)]
expr(p, n.sons[i], arr)
@ -2757,7 +2757,7 @@ proc getNullValueAux(p: BProc; t: PType; obj, cons: PNode, result: var Rope; cou
getNullValueAux(p, t, it, cons, result, count)
of nkRecCase:
getNullValueAux(p, t, obj.sons[0], cons, result, count)
for i in countup(1, sonsLen(obj) - 1):
for i in 1 ..< sonsLen(obj):
getNullValueAux(p, t, lastSon(obj.sons[i]), cons, result, count)
of nkSym:
if count > 0: result.add ", "
@ -2817,7 +2817,7 @@ proc genConstSeq(p: BProc, n: PNode, t: PType): Rope =
if n.len > 0:
# array part needs extra curlies:
data.add(", {")
for i in countup(0, n.len - 1):
for i in 0 ..< n.len:
if i > 0: data.addf(",$n", [])
data.add genConstExpr(p, n.sons[i])
data.add("}")
@ -2837,7 +2837,7 @@ proc genConstSeq(p: BProc, n: PNode, t: PType): Rope =
proc genConstSeqV2(p: BProc, n: PNode, t: PType): Rope =
var data = rope"{"
for i in countup(0, n.len - 1):
for i in 0 ..< n.len:
if i > 0: data.addf(",$n", [])
data.add genConstExpr(p, n.sons[i])
data.add("}")