diff options
author | Clyybber <darkmine956@gmail.com> | 2019-05-07 12:37:28 +0200 |
---|---|---|
committer | Clyybber <darkmine956@gmail.com> | 2019-05-07 12:37:28 +0200 |
commit | cc28eef38e601171644ffe1a2775744eaaca8123 (patch) | |
tree | 720cfdcb95072394a62d365cc18f7b6c71ffe031 /compiler | |
parent | f18b3af9d4a6393ba988cdb17d8f0861b1c75c7d (diff) | |
download | Nim-cc28eef38e601171644ffe1a2775744eaaca8123.tar.gz |
Replace countup(x, y) with x .. y
Diffstat (limited to 'compiler')
35 files changed, 103 insertions, 103 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 6382ab522..ee90c566b 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1158,17 +1158,17 @@ const # for all kind of hash tables: proc copyStrTable*(dest: var TStrTable, src: TStrTable) = dest.counter = src.counter setLen(dest.data, len(src.data)) - for i in countup(0, high(src.data)): dest.data[i] = src.data[i] + for i in 0 .. high(src.data): dest.data[i] = src.data[i] proc copyIdTable*(dest: var TIdTable, src: TIdTable) = dest.counter = src.counter newSeq(dest.data, len(src.data)) - for i in countup(0, high(src.data)): dest.data[i] = src.data[i] + for i in 0 .. high(src.data): dest.data[i] = src.data[i] proc copyObjectSet*(dest: var TObjectSet, src: TObjectSet) = dest.counter = src.counter setLen(dest.data, len(src.data)) - for i in countup(0, high(src.data)): dest.data[i] = src.data[i] + for i in 0 .. high(src.data): dest.data[i] = src.data[i] proc discardSons*(father: PNode) = when defined(nimNoNilSeqs): @@ -1520,7 +1520,7 @@ proc delSon*(father: PNode, idx: int) = else: if isNil(father.sons): return var length = sonsLen(father) - for i in countup(idx, length - 2): father.sons[i] = father.sons[i + 1] + for i in idx .. length - 2: father.sons[i] = father.sons[i + 1] setLen(father.sons, length - 1) proc copyNode*(src: PNode): PNode = diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index bd997b962..280022780 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -630,7 +630,7 @@ proc objectSetRawInsert(data: var TObjectSeq, obj: RootRef) = proc objectSetEnlarge(t: var TObjectSet) = var n: TObjectSeq newSeq(n, len(t.data) * GrowthFactor) - for i in countup(0, high(t.data)): + for i in 0 .. high(t.data): if t.data[i] != nil: objectSetRawInsert(n, t.data[i]) swap(t.data, n) @@ -709,7 +709,7 @@ proc symTabReplace*(t: var TStrTable, prevSym: PSym, newSym: PSym) = proc strTableEnlarge(t: var TStrTable) = var n: seq[PSym] newSeq(n, len(t.data) * GrowthFactor) - for i in countup(0, high(t.data)): + for i in 0 .. high(t.data): if t.data[i] != nil: strTableRawInsert(n, t.data[i]) swap(t.data, n) @@ -845,7 +845,7 @@ iterator items*(tab: TStrTable): PSym = s = nextIter(it, tab) proc hasEmptySlot(data: TIdPairSeq): bool = - for h in countup(0, high(data)): + for h in 0 .. high(data): if data[h].key == nil: return true result = false @@ -900,7 +900,7 @@ proc idTablePut(t: var TIdTable, key: PIdObj, val: RootRef) = else: if mustRehash(len(t.data), t.counter): newSeq(n, len(t.data) * GrowthFactor) - for i in countup(0, high(t.data)): + for i in 0 .. high(t.data): if t.data[i].key != nil: idTableRawInsert(n, t.data[i].key, t.data[i].val) assert(hasEmptySlot(n)) @@ -946,7 +946,7 @@ proc idNodeTablePut(t: var TIdNodeTable, key: PIdObj, val: PNode) = if mustRehash(len(t.data), t.counter): var n: TIdNodePairSeq newSeq(n, len(t.data) * GrowthFactor) - for i in countup(0, high(t.data)): + for i in 0 .. high(t.data): if t.data[i].key != nil: idNodeTableRawInsert(n, t.data[i].key, t.data[i].val) swap(t.data, n) @@ -994,8 +994,8 @@ proc iiTablePut(t: var TIITable, key, val: int) = if mustRehash(len(t.data), t.counter): var n: TIIPairSeq newSeq(n, len(t.data) * GrowthFactor) - for i in countup(0, high(n)): n[i].key = InvalidKey - for i in countup(0, high(t.data)): + for i in 0 .. high(n): n[i].key = InvalidKey + for i in 0 .. high(t.data): if t.data[i].key != InvalidKey: iiTableRawInsert(n, t.data[i].key, t.data[i].val) swap(t.data, n) diff --git a/compiler/bitsets.nim b/compiler/bitsets.nim index e38732877..0f12da95f 100644 --- a/compiler/bitsets.nim +++ b/compiler/bitsets.nim @@ -48,25 +48,25 @@ proc bitSetInit(b: var TBitSet, length: int) = newSeq(b, length) proc bitSetUnion(x: var TBitSet, y: TBitSet) = - for i in countup(0, high(x)): x[i] = x[i] or y[i] + for i in 0 .. high(x): x[i] = x[i] or y[i] proc bitSetDiff(x: var TBitSet, y: TBitSet) = - for i in countup(0, high(x)): x[i] = x[i] and not y[i] + for i in 0 .. high(x): x[i] = x[i] and not y[i] proc bitSetSymDiff(x: var TBitSet, y: TBitSet) = - for i in countup(0, high(x)): x[i] = x[i] xor y[i] + for i in 0 .. high(x): x[i] = x[i] xor y[i] proc bitSetIntersect(x: var TBitSet, y: TBitSet) = - for i in countup(0, high(x)): x[i] = x[i] and y[i] + for i in 0 .. high(x): x[i] = x[i] and y[i] proc bitSetEquals(x, y: TBitSet): bool = - for i in countup(0, high(x)): + for i in 0 .. high(x): if x[i] != y[i]: return false result = true proc bitSetContains(x, y: TBitSet): bool = - for i in countup(0, high(x)): + for i in 0 .. high(x): if (x[i] and not y[i]) != int8(0): return false result = true diff --git a/compiler/canonicalizer.nim b/compiler/canonicalizer.nim index a3e6bcb0d..8c418b790 100644 --- a/compiler/canonicalizer.nim +++ b/compiler/canonicalizer.nim @@ -128,7 +128,7 @@ proc hashType(c: var MD5Context, t: PType) = of tyUserTypeClassInst: let body = t.base c.hashSym body.sym - for i in countup(1, sonsLen(t) - 2): + for i in 1 .. sonsLen(t) - 2: c.hashType t.sons[i] of tyFromExpr: c.hashTree(t.n) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 40fd26d4f..97ce5a485 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1134,7 +1134,7 @@ proc genStrConcat(p: BProc, e: PNode, d: var TLoc) = var L = 0 var appends: Rope = nil var lens: Rope = nil - for i in countup(0, sonsLen(e) - 2): + for i in 0 .. sonsLen(e) - 2: # compute the length expression: initLocExpr(p, e.sons[i + 1], a) if skipTypes(e.sons[i + 1].typ, abstractVarRange).kind == tyChar: @@ -1173,7 +1173,7 @@ proc genStrAppend(p: BProc, e: PNode, d: var TLoc) = assert(d.k == locNone) var L = 0 initLocExpr(p, e.sons[1], dest) - for i in countup(0, sonsLen(e) - 3): + for i in 0 .. sonsLen(e) - 3: # compute the length expression: initLocExpr(p, e.sons[i + 2], a) if skipTypes(e.sons[i + 2].typ, abstractVarRange).kind == tyChar: @@ -2477,7 +2477,7 @@ proc downConv(p: BProc, n: PNode, d: var TLoc) = add(r, "->Sup") else: add(r, ".Sup") - for i in countup(2, abs(inheritanceDiff(dest, src))): add(r, ".Sup") + for i in 2 .. abs(inheritanceDiff(dest, src)): add(r, ".Sup") if isRef: # it can happen that we end up generating '&&x->Sup' here, so we pack # the '&x->Sup' into a temporary and then those address is taken @@ -2806,7 +2806,7 @@ proc genConstObjConstr(p: BProc; n: PNode): Rope = proc genConstSimpleList(p: BProc, n: PNode): Rope = var length = sonsLen(n) result = rope("{") - for i in countup(0, length - 2): + for i in 0 .. length - 2: addf(result, "$1,$n", [genNamedConstExpr(p, n.sons[i])]) if length > 0: add(result, genNamedConstExpr(p, n.sons[length - 1])) diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index 7d0367938..3be31503a 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -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 @@ -99,7 +99,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 @@ -202,7 +202,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 @@ -709,7 +709,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) @@ -768,7 +768,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}) @@ -799,7 +799,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]]) @@ -813,7 +813,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: @@ -1054,7 +1054,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: diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 3cbc29005..abdb97e5d 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -1080,7 +1080,7 @@ proc genObjectFields(m: BModule, typ, origType: PType, n: PNode, expr: Rope; of nkOfBranch: if sonsLen(b) < 2: internalError(m.config, b.info, "genObjectFields; nkOfBranch broken") - for j in countup(0, sonsLen(b) - 2): + for j in 0 .. sonsLen(b) - 2: if b.sons[j].kind == nkRange: var x = int(getOrdValue(b.sons[j].sons[0])) var y = int(getOrdValue(b.sons[j].sons[1])) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 479ba0d37..c46c846d2 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -664,7 +664,7 @@ proc loadDynamicLib(m: BModule, lib: PLib) = libCandidates(lib.path.strVal, s) rawMessage(m.config, hintDependency, lib.path.strVal) var loadlib: Rope = nil - for i in countup(0, high(s)): + for i in 0 .. high(s): inc(m.labels) if i > 0: add(loadlib, "||") let n = newStrNode(nkStrLit, s[i]) @@ -1710,7 +1710,7 @@ proc genModule(m: BModule, cfile: Cfile): Rope = add(result, "#define nimfr_(x, y)\n#define nimln_(x, y)\n") add(result, genSectionEnd(cfsFrameDefines, m.config)) - for i in countup(cfsForwardTypes, cfsProcs): + for i in cfsForwardTypes .. cfsProcs: if m.s[i].len > 0: moduleIsEmpty = false add(result, genSectionStart(i, m.config)) @@ -1811,7 +1811,7 @@ proc writeHeader(m: BModule) = generateHeaders(m) generateThreadLocalStorage(m) - for i in countup(cfsHeaders, cfsProcs): + for i in cfsHeaders .. cfsProcs: add(result, genSectionStart(i, m.config)) add(result, m.s[i]) add(result, genSectionEnd(i, m.config)) diff --git a/compiler/cgmeth.nim b/compiler/cgmeth.nim index c1e2ed74c..d9e99a84a 100644 --- a/compiler/cgmeth.nim +++ b/compiler/cgmeth.nim @@ -192,7 +192,7 @@ proc relevantCol(methods: seq[PSym], col: int): bool = # returns true iff the position is relevant var t = methods[0].typ.sons[col].skipTypes(skipPtrs) if t.kind == tyObject: - for i in countup(1, high(methods)): + for i in 1 .. high(methods): let t2 = skipTypes(methods[i].typ.sons[col], skipPtrs) if not sameType(t2, t): return true @@ -240,7 +240,7 @@ proc genDispatcher(g: ModuleGraph; methods: seq[PSym], relevantCols: IntSet): PS if param.typ.skipTypes(abstractInst).kind in {tyRef, tyPtr}: addSon(nilchecks, newTree(nkCall, newSymNode(getCompilerProc(g, "chckNilDisp")), newSymNode(param))) - for meth in countup(0, high(methods)): + for meth in 0 .. high(methods): var curr = methods[meth] # generate condition: var cond: PNode = nil for col in 1 ..< paramLen: diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 865dd3592..2e9b1affe 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -177,7 +177,7 @@ template dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArra else: addf(dest, tex, args) proc getVarIdx(varnames: openArray[string], id: string): int = - for i in countup(0, high(varnames)): + for i in 0 .. high(varnames): if cmpIgnoreStyle(varnames[i], id) == 0: return i result = -1 @@ -971,12 +971,12 @@ proc genOutFile(d: PDoc): Rope = var tmp = "" renderTocEntries(d[], j, 1, tmp) var toc = tmp.rope - for i in countup(low(TSymKind), high(TSymKind)): + for i in low(TSymKind) .. high(TSymKind): genSection(d, i) add(toc, d.toc[i]) if toc != nil: toc = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.toc"), ["content"], [toc]) - for i in countup(low(TSymKind), high(TSymKind)): add(code, d.section[i]) + for i in low(TSymKind) .. high(TSymKind): add(code, d.section[i]) # Extract the title. Non API modules generate an entry in the index table. if d.meta[metaTitle].len != 0: diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index dfbd2626a..499cca6d8 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -370,7 +370,7 @@ proc libNameTmpl(conf: ConfigRef): string {.inline.} = proc nameToCC*(name: string): TSystemCC = ## Returns the kind of compiler referred to by `name`, or ccNone ## if the name doesn't refer to any known compiler. - for i in countup(succ(ccNone), high(TSystemCC)): + for i in succ(ccNone) .. high(TSystemCC): if cmpIgnoreStyle(name, CC[i].name) == 0: return i result = ccNone @@ -412,7 +412,7 @@ proc setCC*(conf: ConfigRef; ccname: string; info: TLineInfo) = conf.compileOptions = getConfigVar(conf, conf.cCompiler, ".options.always") conf.linkOptions = "" conf.ccompilerpath = getConfigVar(conf, conf.cCompiler, ".path") - for i in countup(low(CC), high(CC)): undefSymbol(conf.symbols, CC[i].name) + for i in low(CC) .. high(CC): undefSymbol(conf.symbols, CC[i].name) defineSymbol(conf.symbols, CC[conf.cCompiler].name) proc addOpt(dest: var string, src: string) = @@ -434,7 +434,7 @@ proc addCompileOptionCmd*(conf: ConfigRef; option: string) = proc initVars*(conf: ConfigRef) = # we need to define the symbol here, because ``CC`` may have never been set! - for i in countup(low(CC), high(CC)): undefSymbol(conf.symbols, CC[i].name) + for i in low(CC) .. high(CC): undefSymbol(conf.symbols, CC[i].name) defineSymbol(conf.symbols, CC[conf.cCompiler].name) addCompileOption(conf, getConfigVar(conf, conf.cCompiler, ".options.always")) #addLinkOption(getConfigVar(cCompiler, ".options.linker")) @@ -787,7 +787,7 @@ proc execCmdsInParallel(conf: ConfigRef; cmds: seq[string]; prettyCb: proc (idx: if conf.numberOfProcessors == 0: conf.numberOfProcessors = countProcessors() var res = 0 if conf.numberOfProcessors <= 1: - for i in countup(0, high(cmds)): + for i in 0 .. high(cmds): tryExceptOSErrorMessage(conf, "invocation of external compiler program failed."): res = execWithEcho(conf, cmds[i]) if res != 0: diff --git a/compiler/idents.nim b/compiler/idents.nim index 80dc6e591..f82ff5db5 100644 --- a/compiler/idents.nim +++ b/compiler/idents.nim @@ -110,7 +110,7 @@ proc newIdentCache*(): IdentCache = result.idDelegator = result.getIdent":delegator" result.emptyIdent = result.getIdent("") # initialize the keywords: - for s in countup(succ(low(specialWords)), high(specialWords)): + for s in succ(low(specialWords)) .. high(specialWords): result.getIdent(specialWords[s], hashIgnoreStyle(specialWords[s])).id = ord(s) proc whichKeyword*(id: PIdent): TSpecialWord = diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index fb6d31725..193077760 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -780,7 +780,7 @@ proc genTry(p: PProc, n: PNode, r: var TCompRes) = var excAlias: PNode = nil useMagic(p, "isObj") - for j in countup(0, blen - 2): + for j in 0 .. blen - 2: var throwObj: PNode let it = n.sons[i].sons[j] @@ -862,7 +862,7 @@ proc genCaseJS(p: PProc, n: PNode, r: var TCompRes) = let it = n.sons[i] case it.kind of nkOfBranch: - for j in countup(0, sonsLen(it) - 2): + for j in 0 .. sonsLen(it) - 2: let e = it.sons[j] if e.kind == nkRange: var v = copyNode(e.sons[0]) @@ -1811,7 +1811,7 @@ proc genConStrStr(p: PProc, n: PNode, r: var TCompRes) = else: r.res.add("($1 || []).concat(" % [a.res]) - for i in countup(2, sonsLen(n) - 2): + for i in 2 .. sonsLen(n) - 2: gen(p, n.sons[i], a) if skipTypes(n.sons[i].typ, abstractVarRange).kind == tyChar: r.res.add("[$1]," % [a.res]) diff --git a/compiler/jstypes.nim b/compiler/jstypes.nim index b25ff4a3d..b49985cbf 100644 --- a/compiler/jstypes.nim +++ b/compiler/jstypes.nim @@ -48,7 +48,7 @@ proc genObjectFields(p: PProc, typ: PType, n: PNode): Rope = of nkOfBranch: if sonsLen(b) < 2: internalError(p.config, b.info, "genObjectFields; nkOfBranch broken") - for j in countup(0, sonsLen(b) - 2): + for j in 0 .. sonsLen(b) - 2: if u != nil: add(u, ", ") if b.sons[j].kind == nkRange: addf(u, "[$1, $2]", [rope(getOrdValue(b.sons[j].sons[0])), diff --git a/compiler/nimsets.nim b/compiler/nimsets.nim index 1447e4cfd..b13f3be3d 100644 --- a/compiler/nimsets.nim +++ b/compiler/nimsets.nim @@ -133,7 +133,7 @@ proc equalSets*(conf: ConfigRef; a, b: PNode): bool = proc complement*(conf: ConfigRef; a: PNode): PNode = var x: TBitSet toBitSet(conf, a, x) - for i in countup(0, high(x)): x[i] = not x[i] + for i in 0 .. high(x): x[i] = not x[i] result = toTreeSet(conf, x, a.typ, a.info) proc deduplicate*(conf: ConfigRef; a: PNode): PNode = diff --git a/compiler/patterns.nim b/compiler/patterns.nim index 4ff514be0..560382d93 100644 --- a/compiler/patterns.nim +++ b/compiler/patterns.nim @@ -182,7 +182,7 @@ proc matches(c: PPatternContext, p, n: PNode): bool = if isPatternParam(c, v) and v.sym.typ.kind == tyVarargs: var arglist: PNode if plen <= sonsLen(n): - for i in countup(0, plen - 2): + for i in 0 .. plen - 2: if not matches(c, p.sons[i], n.sons[i]): return if plen == sonsLen(n) and lastSon(n).kind == nkHiddenStdConv and lastSon(n).sons[1].kind == nkBracket: @@ -194,11 +194,11 @@ proc matches(c: PPatternContext, p, n: PNode): bool = arglist = newNodeI(nkArgList, n.info, sonsLen(n) - plen + 1) # f(1, 2, 3) # p(X) - for i in countup(0, sonsLen(n) - plen): + for i in 0 .. sonsLen(n) - plen: arglist.sons[i] = n.sons[i + plen - 1] return bindOrCheck(c, v.sym, arglist) elif plen-1 == sonsLen(n): - for i in countup(0, plen - 2): + for i in 0 .. plen - 2: if not matches(c, p.sons[i], n.sons[i]): return arglist = newNodeI(nkArgList, n.info) return bindOrCheck(c, v.sym, arglist) diff --git a/compiler/platform.nim b/compiler/platform.nim index e1003a385..d5a76024e 100644 --- a/compiler/platform.nim +++ b/compiler/platform.nim @@ -237,13 +237,13 @@ proc setTarget*(t: var Target; o: TSystemOS, c: TSystemCPU) = t.tnl = OS[o].newLine proc nameToOS*(name: string): TSystemOS = - for i in countup(succ(osNone), high(TSystemOS)): + for i in succ(osNone) .. high(TSystemOS): if cmpIgnoreStyle(name, OS[i].name) == 0: return i result = osNone proc nameToCPU*(name: string): TSystemCPU = - for i in countup(succ(cpuNone), high(TSystemCPU)): + for i in succ(cpuNone) .. high(TSystemCPU): if cmpIgnoreStyle(name, CPU[i].name) == 0: return i result = cpuNone diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 5e14e9e0e..e49461eea 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -209,7 +209,7 @@ proc processMagic(c: PContext, n: PNode, s: PSym) = var v: string if n.sons[1].kind == nkIdent: v = n.sons[1].ident.s else: v = expectStrLit(c, n) - for m in countup(low(TMagic), high(TMagic)): + for m in low(TMagic) .. high(TMagic): if substr($m, 1) == v: s.magic = m break diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 04bb5181e..56f57b25a 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -302,7 +302,7 @@ proc gcom(g: var TSrcGen, n: PNode) = putComment(g, n.comment) #assert(g.comStack[high(g.comStack)] = n); proc gcoms(g: var TSrcGen) = - for i in countup(0, high(g.comStack)): gcom(g, g.comStack[i]) + for i in 0 .. high(g.comStack): gcom(g, g.comStack[i]) popAllComs(g) proc lsub(g: TSrcGen; n: PNode): int @@ -393,7 +393,7 @@ proc atom(g: TSrcGen; n: PNode): string = proc lcomma(g: TSrcGen; n: PNode, start: int = 0, theEnd: int = - 1): int = assert(theEnd < 0) result = 0 - for i in countup(start, sonsLen(n) + theEnd): + for i in start .. sonsLen(n) + theEnd: let param = n.sons[i] if nfDefaultParam notin param.flags: inc(result, lsub(g, param)) @@ -404,7 +404,7 @@ proc lcomma(g: TSrcGen; n: PNode, start: int = 0, theEnd: int = - 1): int = proc lsons(g: TSrcGen; n: PNode, start: int = 0, theEnd: int = - 1): int = assert(theEnd < 0) result = 0 - for i in countup(start, sonsLen(n) + theEnd): inc(result, lsub(g, n.sons[i])) + for i in start .. sonsLen(n) + theEnd: inc(result, lsub(g, n.sons[i])) proc lsub(g: TSrcGen; n: PNode): int = # computes the length of a tree @@ -563,7 +563,7 @@ proc putWithSpace(g: var TSrcGen, kind: TTokType, s: string) = proc gcommaAux(g: var TSrcGen, n: PNode, ind: int, start: int = 0, theEnd: int = - 1, separator = tkComma) = - for i in countup(start, sonsLen(n) + theEnd): + for i in start .. sonsLen(n) + theEnd: var c = i < sonsLen(n) + theEnd var sublen = lsub(g, n.sons[i]) + ord(c) if not fits(g, sublen) and (ind + sublen < MaxLineLen): optNL(g, ind) @@ -598,7 +598,7 @@ proc gsemicolon(g: var TSrcGen, n: PNode, start: int = 0, theEnd: int = - 1) = proc gsons(g: var TSrcGen, n: PNode, c: TContext, start: int = 0, theEnd: int = - 1) = - for i in countup(start, sonsLen(n) + theEnd): gsub(g, n.sons[i], c) + for i in start .. sonsLen(n) + theEnd: gsub(g, n.sons[i], c) proc gsection(g: var TSrcGen, n: PNode, c: TContext, kind: TTokType, k: string) = @@ -616,7 +616,7 @@ proc longMode(g: TSrcGen; n: PNode, start: int = 0, theEnd: int = - 1): bool = result = n.comment.len > 0 if not result: # check further - for i in countup(start, sonsLen(n) + theEnd): + for i in start .. sonsLen(n) + theEnd: if (lsub(g, n.sons[i]) > MaxLineLen): result = true break diff --git a/compiler/reorder.nim b/compiler/reorder.nim index 18ec659ba..09168ae6a 100644 --- a/compiler/reorder.nim +++ b/compiler/reorder.nim @@ -75,7 +75,7 @@ proc computeDeps(cache: IdentCache; n: PNode, declares, uses: var IntSet; topLev of nkLetSection, nkVarSection, nkUsingStmt: for a in n: if a.kind in {nkIdentDefs, nkVarTuple}: - for j in countup(0, a.len-3): decl(a[j]) + for j in 0 .. a.len-3: decl(a[j]) for j in a.len-2..a.len-1: deps(a[j]) of nkConstSection, nkTypeSection: for a in n: diff --git a/compiler/ropes.nim b/compiler/ropes.nim index 87026025f..774c266b2 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -157,7 +157,7 @@ proc `&`*(a: string, b: Rope): Rope = proc `&`*(a: openArray[Rope]): Rope = ## the concatenation operator for an openarray of ropes. - for i in countup(0, high(a)): result = result & a[i] + for i in 0 .. high(a): result = result & a[i] proc add*(a: var Rope, b: Rope) = ## adds `b` to the rope `a`. @@ -206,7 +206,7 @@ proc `$`*(r: Rope): string = proc ropeConcat*(a: varargs[Rope]): Rope = # not overloaded version of concat to speed-up `rfmt` a little bit - for i in countup(0, high(a)): result = result & a[i] + for i in 0 .. high(a): result = result & a[i] proc prepend*(a: var Rope, b: Rope) = a = b & a proc prepend*(a: var Rope, b: string) = a = b & a diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 20fbdf993..acdece3fd 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -984,7 +984,7 @@ proc lookupInRecordAndBuildCheck(c: PContext, n, r: PNode, field: PIdent, check = newNodeI(nkCheckedFieldExpr, n.info) addSon(check, c.graph.emptyNode) # make space for access node s = newNodeIT(nkCurly, n.info, setType) - for j in countup(0, sonsLen(it) - 2): addSon(s, copyTree(it.sons[j])) + for j in 0 .. sonsLen(it) - 2: addSon(s, copyTree(it.sons[j])) var inExpr = newNodeIT(nkCall, n.info, getSysType(c.graph, n.info, tyBool)) addSon(inExpr, newSymNode(c.graph.opContains, n.info)) addSon(inExpr, s) @@ -1046,7 +1046,7 @@ proc readTypeParameter(c: PContext, typ: PType, let ty = if typ.kind == tyCompositeTypeClass: typ.sons[1].skipGenericAlias else: typ.skipGenericAlias let tbody = ty.sons[0] - for s in countup(0, tbody.len-2): + for s in 0 .. tbody.len-2: let tParam = tbody.sons[s] if tParam.sym.name.id == paramName.id: let rawTyp = ty.sons[s + 1] diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index 2b8184322..e63e69f68 100644 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -343,7 +343,7 @@ proc semGenericStmt(c: PContext, n: PNode, var a = n.sons[i] checkMinSonsLen(a, 1, c.config) var L = sonsLen(a) - for j in countup(0, L-2): + for j in 0 .. L-2: a.sons[j] = semGenericStmt(c, a.sons[j], flags, ctx) a.sons[L - 1] = semGenericStmtScope(c, a.sons[L-1], flags, ctx) closeScope(c) @@ -351,7 +351,7 @@ proc semGenericStmt(c: PContext, n: PNode, var L = sonsLen(n) openScope(c) n.sons[L - 2] = semGenericStmt(c, n.sons[L-2], flags, ctx) - for i in countup(0, L - 3): + for i in 0 .. L - 3: if (n.sons[i].kind == nkVarTuple): for s in n.sons[i]: if (s.kind == nkIdent): @@ -377,7 +377,7 @@ proc semGenericStmt(c: PContext, n: PNode, checkMinSonsLen(a, 1, c.config) var L = sonsLen(a) openScope(c) - for j in countup(0, L-2): + for j in 0 .. L-2: if a.sons[j].isInfixAs(): addTempDecl(c, getIdentNode(c, a.sons[j][2]), skLet) a.sons[j].sons[1] = semGenericStmt(c, a.sons[j][1], flags+{withinTypeDesc}, ctx) @@ -395,7 +395,7 @@ proc semGenericStmt(c: PContext, n: PNode, var L = sonsLen(a) a.sons[L-2] = semGenericStmt(c, a.sons[L-2], flags+{withinTypeDesc}, ctx) a.sons[L-1] = semGenericStmt(c, a.sons[L-1], flags, ctx) - for j in countup(0, L-3): + for j in 0 .. L-3: addTempDecl(c, getIdentNode(c, a.sons[j]), skVar) of nkGenericParams: for i in 0 ..< sonsLen(n): @@ -405,7 +405,7 @@ proc semGenericStmt(c: PContext, n: PNode, var L = sonsLen(a) a.sons[L-2] = semGenericStmt(c, a.sons[L-2], flags+{withinTypeDesc}, ctx) # do not perform symbol lookup for default expressions - for j in countup(0, L-3): + for j in 0 .. L-3: addTempDecl(c, getIdentNode(c, a.sons[j]), skType) of nkConstSection: for i in 0 ..< sonsLen(n): @@ -459,7 +459,7 @@ proc semGenericStmt(c: PContext, n: PNode, var L = sonsLen(a) a.sons[L-2] = semGenericStmt(c, a.sons[L-2], flags+{withinTypeDesc}, ctx) a.sons[L-1] = semGenericStmt(c, a.sons[L-1], flags, ctx) - for j in countup(0, L-3): + for j in 0 .. L-3: addTempDecl(c, getIdentNode(c, a.sons[j]), skParam) of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef, nkFuncDef, nkIteratorDef, nkLambdaKinds: diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 1bcdb1e9b..557e5d3f7 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -386,7 +386,7 @@ proc trackTryStmt(tracked: PEffects, n: PNode) = if blen == 1: catchesAll(tracked) else: - for j in countup(0, blen - 2): + for j in 0 .. blen - 2: if b.sons[j].isInfixAs(): assert(b.sons[j][1].kind == nkType) catches(tracked, b.sons[j][1].typ) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 5d6134a74..1cf8e7ab2 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -207,7 +207,7 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = var last = sonsLen(n) - 1 var catchAllExcepts = 0 - for i in countup(1, last): + for i in 1 .. last: let a = n.sons[i] checkMinSonsLen(a, 1, c.config) openScope(c) @@ -365,7 +365,7 @@ proc semUsing(c: PContext; n: PNode): PNode = var length = sonsLen(a) if a.sons[length-2].kind != nkEmpty: let typ = semTypeNode(c, a.sons[length-2], nil) - for j in countup(0, length-3): + for j in 0 .. length-3: let v = semIdentDef(c, a.sons[j], skParam) styleCheckDef(c.config, v) onDef(a[j].info, v) @@ -504,7 +504,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = a.kind == nkIdentDefs and a.len > 3: message(c.config, a.info, warnEachIdentIsTuple) - for j in countup(0, length-3): + for j in 0 .. length-3: if a[j].kind == nkDotExpr: fillPartialObject(c, a[j], if a.kind != nkVarTuple: typ else: tup.sons[j]) @@ -624,7 +624,7 @@ proc semConst(c: PContext, n: PNode): PNode = b.sons[length-2] = a.sons[length-2] b.sons[length-1] = def - for j in countup(0, length-3): + for j in 0 .. length-3: var v = semIdentDef(c, a.sons[j], skConst) if sfGenSym notin v.flags: addInterfaceDecl(c, v) elif v.owner == nil: v.owner = getCurrOwner(c) @@ -699,7 +699,7 @@ proc semForVars(c: PContext, n: PNode; flags: TExprFlags): PNode = elif length-2 != sonsLen(iter): localError(c.config, n.info, errWrongNumberOfVariables) else: - for i in countup(0, length - 3): + for i in 0 .. length - 3: if n.sons[i].kind == nkVarTuple: var mutable = false if iter[i].kind == tyVar: diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index 95d4c9855..4b283f793 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -298,7 +298,7 @@ proc semTemplSomeDecl(c: var TemplCtx, n: PNode, symKind: TSymKind; start=0) = when defined(nimsuggest): dec c.c.inTypeContext a.sons[L-1] = semTemplBody(c, a.sons[L-1]) - for j in countup(0, L-3): + for j in 0 .. L-3: addLocalDecl(c, a.sons[j], symKind) proc semPattern(c: PContext, n: PNode): PNode @@ -363,7 +363,7 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode = var a = n.sons[i] checkMinSonsLen(a, 1, c.c.config) var L = sonsLen(a) - for j in countup(0, L-2): + for j in 0 .. L-2: a.sons[j] = semTemplBody(c, a.sons[j]) a.sons[L-1] = semTemplBodyScope(c, a.sons[L-1]) closeScope(c) @@ -371,7 +371,7 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode = var L = sonsLen(n) openScope(c) n.sons[L-2] = semTemplBody(c, n.sons[L-2]) - for i in countup(0, L - 3): + for i in 0 .. L - 3: if n[i].kind == nkVarTuple: for j in 0 ..< sonsLen(n[i])-1: addLocalDecl(c, n[i][j], skForVar) @@ -403,7 +403,7 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode = checkMinSonsLen(a, 1, c.c.config) var L = sonsLen(a) openScope(c) - for j in countup(0, L-2): + for j in 0 .. L-2: if a.sons[j].isInfixAs(): addLocalDecl(c, a.sons[j].sons[2], skLet) a.sons[j].sons[1] = semTemplBody(c, a.sons[j][1]) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 9ce76325f..f37e8263e 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -431,7 +431,7 @@ proc semTuple(c: PContext, n: PNode, prev: PType): PType = typ = errorType(c) if a.sons[length - 1].kind != nkEmpty: localError(c.config, a.sons[length - 1].info, errInitHereNotAllowed) - for j in countup(0, length - 3): + for j in 0 .. length - 3: var field = newSymG(skField, a.sons[j], c) field.typ = typ field.position = counter @@ -489,8 +489,8 @@ proc semIdentWithPragma(c: PContext, kind: TSymKind, n: PNode, proc checkForOverlap(c: PContext, t: PNode, currentEx, branchIndex: int) = let ex = t[branchIndex][currentEx].skipConv - for i in countup(1, branchIndex): - for j in countup(0, sonsLen(t.sons[i]) - 2): + for i in 1 .. branchIndex: + for j in 0 .. sonsLen(t.sons[i]) - 2: if i == branchIndex and j == currentEx: break if overlap(t.sons[i].sons[j].skipConv, ex): localError(c.config, ex.info, errDuplicateCaseLabel) @@ -699,7 +699,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int, propagateToOwner(rectype, typ) var fieldOwner = if c.inGenericContext > 0: c.getCurrOwner else: rectype.sym - for i in countup(0, sonsLen(n)-3): + for i in 0 .. sonsLen(n)-3: var f = semIdentWithPragma(c, skField, n.sons[i], {sfExported}) suggestSym(c.config, n.sons[i].info, f, c.graph.usageSym) f.typ = typ @@ -1159,7 +1159,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode, elif skipTypes(typ, {tyGenericInst, tyAlias, tySink}).kind == tyVoid: continue - for j in countup(0, length-3): + for j in 0 .. length-3: var arg = newSymG(skParam, a.sons[j], c) if not hasType and not hasDefault and kind notin {skTemplate, skMacro}: let param = strTableGet(c.signatures, arg.name) @@ -1237,7 +1237,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode, proc semStmtListType(c: PContext, n: PNode, prev: PType): PType = checkMinSonsLen(n, 1, c.config) var length = sonsLen(n) - for i in countup(0, length - 2): + for i in 0 .. length - 2: n.sons[i] = semStmt(c, n.sons[i], {}) if length > 0: result = semTypeNode(c, n.sons[length - 1], prev) @@ -1917,7 +1917,7 @@ proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode = typ.flags.incl tfGenericTypeParam - for j in countup(0, L-3): + for j in 0 .. L-3: let finalType = if j == 0: typ else: copyType(typ, typ.owner, false) # it's important the we create an unique diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim index ce769ab3b..046479de4 100644 --- a/compiler/sighashes.nim +++ b/compiler/sighashes.nim @@ -134,7 +134,7 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) = let inst = t.typeInst t.typeInst = nil assert inst.kind == tyGenericInst - for i in countup(0, inst.len - 2): + for i in 0 .. inst.len - 2: c.hashType inst.sons[i], flags t.typeInst = inst return diff --git a/compiler/syntaxes.nim b/compiler/syntaxes.nim index 60246b9bf..598a9bdc3 100644 --- a/compiler/syntaxes.nim +++ b/compiler/syntaxes.nim @@ -85,13 +85,13 @@ proc parsePipe(filename: AbsoluteFile, inputStream: PLLStream; cache: IdentCache llStreamClose(s) proc getFilter(ident: PIdent): TFilterKind = - for i in countup(low(TFilterKind), high(TFilterKind)): + for i in low(TFilterKind) .. high(TFilterKind): if cmpIgnoreStyle(ident.s, filterNames[i]) == 0: return i result = filtNone proc getParser(conf: ConfigRef; n: PNode; ident: PIdent): TParserKind = - for i in countup(low(TParserKind), high(TParserKind)): + for i in low(TParserKind) .. high(TParserKind): if cmpIgnoreStyle(ident.s, parserNames[i]) == 0: return i localError(conf, n.info, "unknown parser: " & ident.s) @@ -131,7 +131,7 @@ proc evalPipe(p: var TParsers, n: PNode, filename: AbsoluteFile, result = start if n.kind == nkEmpty: return if n.kind == nkInfix and n[0].kind == nkIdent and n[0].ident.s == "|": - for i in countup(1, 2): + for i in 1 .. 2: if n.sons[i].kind == nkInfix: result = evalPipe(p, n.sons[i], filename, result) else: diff --git a/compiler/transf.nim b/compiler/transf.nim index 634e99c86..0e788b833 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -203,7 +203,7 @@ proc transformVarSection(c: PTransf, v: PNode): PTransNode = internalError(c.graph.config, it.info, "transformVarSection: not nkVarTuple") var L = sonsLen(it) var defs = newTransNode(it.kind, it.info, L) - for j in countup(0, L-3): + for j in 0 .. L-3: if it[j].kind == nkSym: let x = freshVar(c, it.sons[j].sym) idNodeTablePut(c.transCon.mapping, it.sons[j].sym, x) @@ -390,7 +390,7 @@ proc transformYield(c: PTransf, n: PNode): PTransNode = else: # Unpack the tuple into the loop variables # XXX: BUG: what if `n` is an expression with side-effects? - for i in countup(0, sonsLen(c.transCon.forStmt) - 3): + for i in 0 .. sonsLen(c.transCon.forStmt) - 3: let lhs = c.transCon.forStmt.sons[i] let rhs = transform(c, newTupleAccess(c.graph, e, i)) add(result, asgnTo(lhs, rhs)) @@ -620,7 +620,7 @@ proc transformFor(c: PTransf, n: PNode): PTransNode = discard c.breakSyms.pop var v = newNodeI(nkVarSection, n.info) - for i in countup(0, length - 3): + for i in 0 .. length - 3: if n[i].kind == nkVarTuple: for j in 0 ..< sonsLen(n[i])-1: addVar(v, copyTree(n[i][j])) # declare new vars diff --git a/compiler/treetab.nim b/compiler/treetab.nim index d6f5f11b7..7d654509c 100644 --- a/compiler/treetab.nim +++ b/compiler/treetab.nim @@ -84,7 +84,7 @@ proc nodeTablePut*(t: var TNodeTable, key: PNode, val: int) = else: if mustRehash(len(t.data), t.counter): newSeq(n, len(t.data) * GrowthFactor) - for i in countup(0, high(t.data)): + for i in 0 .. high(t.data): if t.data[i].key != nil: nodeTableRawInsert(n, t.data[i].h, t.data[i].key, t.data[i].val) swap(t.data, n) @@ -101,7 +101,7 @@ proc nodeTableTestOrSet*(t: var TNodeTable, key: PNode, val: int): int = else: if mustRehash(len(t.data), t.counter): newSeq(n, len(t.data) * GrowthFactor) - for i in countup(0, high(t.data)): + for i in 0 .. high(t.data): if t.data[i].key != nil: nodeTableRawInsert(n, t.data[i].h, t.data[i].key, t.data[i].val) swap(t.data, n) diff --git a/compiler/types.nim b/compiler/types.nim index ec0cf4df1..b0a6a4c17 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -465,7 +465,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = add(result, ']') of tyGenericBody: result = typeToString(t.lastSon) & '[' - for i in countup(0, sonsLen(t)-2): + for i in 0 .. sonsLen(t)-2: if i > 0: add(result, ", ") add(result, typeToString(t.sons[i], preferTypeName)) add(result, ']') @@ -506,7 +506,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = of tyUserTypeClassInst: let body = t.base result = body.sym.name.s & "[" - for i in countup(1, sonsLen(t) - 2): + for i in 1 .. sonsLen(t) - 2: if i > 1: add(result, ", ") add(result, typeToString(t.sons[i])) result.add "]" diff --git a/compiler/vm.nim b/compiler/vm.nim index de762edc2..6fc2626f7 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1154,7 +1154,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = # we know the next instruction is a 'fjmp': let branch = c.constants[instr.regBx-wordExcess] var cond = false - for j in countup(0, sonsLen(branch) - 2): + for j in 0 .. sonsLen(branch) - 2: if overlap(regs[ra].regToNode, branch.sons[j]): cond = true break diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index e66105907..5bb44785a 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -510,7 +510,7 @@ proc genTry(c: PCtx; n: PNode; dest: var TDest) = var blen = len(it) # first opcExcept contains the end label of the 'except' block: let endExcept = c.xjmp(it, opcExcept, 0) - for j in countup(0, blen - 2): + for j in 0 .. blen - 2: assert(it.sons[j].kind == nkType) let typ = it.sons[j].typ.skipTypes(abstractPtrs-{tyTypeDesc}) c.gABx(it, opcExcept, 0, c.genType(typ)) diff --git a/compiler/wordrecg.nim b/compiler/wordrecg.nim index 4da19779b..ef59fc979 100644 --- a/compiler/wordrecg.nim +++ b/compiler/wordrecg.nim @@ -180,7 +180,7 @@ const ] proc findStr*(a: openArray[string], s: string): int = - for i in countup(low(a), high(a)): + for i in low(a) .. high(a): if cmpIgnoreStyle(a[i], s) == 0: return i result = - 1 |