Replace countup(x, y-1) with x ..< y
This commit is contained in:
parent
9ffab44c35
commit
f18b3af9d4
58 changed files with 312 additions and 312 deletions
|
|
@ -22,14 +22,14 @@ proc isPartOfAux(n: PNode, b: PType, marker: var IntSet): TAnalysisResult =
|
||||||
result = arNo
|
result = arNo
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = isPartOfAux(n.sons[i], b, marker)
|
result = isPartOfAux(n.sons[i], b, marker)
|
||||||
if result == arYes: return
|
if result == arYes: return
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
assert(n.sons[0].kind == nkSym)
|
assert(n.sons[0].kind == nkSym)
|
||||||
result = isPartOfAux(n.sons[0], b, marker)
|
result = isPartOfAux(n.sons[0], b, marker)
|
||||||
if result == arYes: return
|
if result == arYes: return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
result = isPartOfAux(lastSon(n.sons[i]), b, marker)
|
result = isPartOfAux(lastSon(n.sons[i]), b, marker)
|
||||||
|
|
@ -52,7 +52,7 @@ proc isPartOfAux(a, b: PType, marker: var IntSet): TAnalysisResult =
|
||||||
of tyGenericInst, tyDistinct, tyAlias, tySink:
|
of tyGenericInst, tyDistinct, tyAlias, tySink:
|
||||||
result = isPartOfAux(lastSon(a), b, marker)
|
result = isPartOfAux(lastSon(a), b, marker)
|
||||||
of tyArray, tySet, tyTuple:
|
of tyArray, tySet, tyTuple:
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
result = isPartOfAux(a.sons[i], b, marker)
|
result = isPartOfAux(a.sons[i], b, marker)
|
||||||
if result == arYes: return
|
if result == arYes: return
|
||||||
else: discard
|
else: discard
|
||||||
|
|
|
||||||
|
|
@ -1357,7 +1357,7 @@ proc assignType*(dest, src: PType) =
|
||||||
else:
|
else:
|
||||||
dest.sym = src.sym
|
dest.sym = src.sym
|
||||||
newSons(dest, sonsLen(src))
|
newSons(dest, sonsLen(src))
|
||||||
for i in countup(0, sonsLen(src) - 1): dest.sons[i] = src.sons[i]
|
for i in 0 ..< sonsLen(src): dest.sons[i] = src.sons[i]
|
||||||
|
|
||||||
proc copyType*(t: PType, owner: PSym, keepId: bool): PType =
|
proc copyType*(t: PType, owner: PSym, keepId: bool): PType =
|
||||||
result = newType(t.kind, owner)
|
result = newType(t.kind, owner)
|
||||||
|
|
@ -1582,17 +1582,17 @@ proc copyTree*(src: PNode): PNode =
|
||||||
of nkStrLit..nkTripleStrLit: result.strVal = src.strVal
|
of nkStrLit..nkTripleStrLit: result.strVal = src.strVal
|
||||||
else:
|
else:
|
||||||
newSeq(result.sons, sonsLen(src))
|
newSeq(result.sons, sonsLen(src))
|
||||||
for i in countup(0, sonsLen(src) - 1):
|
for i in 0 ..< sonsLen(src):
|
||||||
result.sons[i] = copyTree(src.sons[i])
|
result.sons[i] = copyTree(src.sons[i])
|
||||||
|
|
||||||
proc hasSonWith*(n: PNode, kind: TNodeKind): bool =
|
proc hasSonWith*(n: PNode, kind: TNodeKind): bool =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if n.sons[i].kind == kind:
|
if n.sons[i].kind == kind:
|
||||||
return true
|
return true
|
||||||
result = false
|
result = false
|
||||||
|
|
||||||
proc hasNilSon*(n: PNode): bool =
|
proc hasNilSon*(n: PNode): bool =
|
||||||
for i in countup(0, safeLen(n) - 1):
|
for i in 0 ..< safeLen(n):
|
||||||
if n.sons[i] == nil:
|
if n.sons[i] == nil:
|
||||||
return true
|
return true
|
||||||
elif hasNilSon(n.sons[i]):
|
elif hasNilSon(n.sons[i]):
|
||||||
|
|
@ -1604,14 +1604,14 @@ proc containsNode*(n: PNode, kinds: TNodeKinds): bool =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkEmpty..nkNilLit: result = n.kind in kinds
|
of nkEmpty..nkNilLit: result = n.kind in kinds
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if n.kind in kinds or containsNode(n.sons[i], kinds): return true
|
if n.kind in kinds or containsNode(n.sons[i], kinds): return true
|
||||||
|
|
||||||
proc hasSubnodeWith*(n: PNode, kind: TNodeKind): bool =
|
proc hasSubnodeWith*(n: PNode, kind: TNodeKind): bool =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkEmpty..nkNilLit: result = n.kind == kind
|
of nkEmpty..nkNilLit: result = n.kind == kind
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if (n.sons[i].kind == kind) or hasSubnodeWith(n.sons[i], kind):
|
if (n.sons[i].kind == kind) or hasSubnodeWith(n.sons[i], kind):
|
||||||
return true
|
return true
|
||||||
result = false
|
result = false
|
||||||
|
|
|
||||||
|
|
@ -152,14 +152,14 @@ proc lookupInRecord(n: PNode, field: PIdent): PSym =
|
||||||
result = nil
|
result = nil
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = lookupInRecord(n.sons[i], field)
|
result = lookupInRecord(n.sons[i], field)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
if (n.sons[0].kind != nkSym): return nil
|
if (n.sons[0].kind != nkSym): return nil
|
||||||
result = lookupInRecord(n.sons[0], field)
|
result = lookupInRecord(n.sons[0], field)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
result = lookupInRecord(lastSon(n.sons[i]), field)
|
result = lookupInRecord(lastSon(n.sons[i]), field)
|
||||||
|
|
@ -175,7 +175,7 @@ proc getModule*(s: PSym): PSym =
|
||||||
while result != nil and result.kind != skModule: result = result.owner
|
while result != nil and result.kind != skModule: result = result.owner
|
||||||
|
|
||||||
proc getSymFromList(list: PNode, ident: PIdent, start: int = 0): PSym =
|
proc getSymFromList(list: PNode, ident: PIdent, start: int = 0): PSym =
|
||||||
for i in countup(start, sonsLen(list) - 1):
|
for i in start ..< sonsLen(list):
|
||||||
if list.sons[i].kind == nkSym:
|
if list.sons[i].kind == nkSym:
|
||||||
result = list.sons[i].sym
|
result = list.sons[i].sym
|
||||||
if result.name.id == ident.id: return
|
if result.name.id == ident.id: return
|
||||||
|
|
@ -281,7 +281,7 @@ proc typeToYamlAux(conf: ConfigRef; n: PType, marker: var IntSet, indent: int,
|
||||||
else:
|
else:
|
||||||
if sonsLen(n) > 0:
|
if sonsLen(n) > 0:
|
||||||
sonsRope = rope("[")
|
sonsRope = rope("[")
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if i > 0: add(sonsRope, ",")
|
if i > 0: add(sonsRope, ",")
|
||||||
addf(sonsRope, "$N$1$2", [rspaces(indent + 4), typeToYamlAux(conf, n.sons[i],
|
addf(sonsRope, "$N$1$2", [rspaces(indent + 4), typeToYamlAux(conf, n.sons[i],
|
||||||
marker, indent + 4, maxRecDepth - 1)])
|
marker, indent + 4, maxRecDepth - 1)])
|
||||||
|
|
@ -330,7 +330,7 @@ proc treeToYamlAux(conf: ConfigRef; n: PNode, marker: var IntSet, indent: int,
|
||||||
else:
|
else:
|
||||||
if sonsLen(n) > 0:
|
if sonsLen(n) > 0:
|
||||||
addf(result, ",$N$1\"sons\": [", [istr])
|
addf(result, ",$N$1\"sons\": [", [istr])
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if i > 0: add(result, ",")
|
if i > 0: add(result, ",")
|
||||||
addf(result, "$N$1$2", [rspaces(indent + 4), treeToYamlAux(conf, n.sons[i],
|
addf(result, "$N$1$2", [rspaces(indent + 4), treeToYamlAux(conf, n.sons[i],
|
||||||
marker, indent + 4, maxRecDepth - 1)])
|
marker, indent + 4, maxRecDepth - 1)])
|
||||||
|
|
@ -960,7 +960,7 @@ iterator pairs*(t: TIdNodeTable): tuple[key: PIdObj, val: PNode] =
|
||||||
proc initIITable(x: var TIITable) =
|
proc initIITable(x: var TIITable) =
|
||||||
x.counter = 0
|
x.counter = 0
|
||||||
newSeq(x.data, StartSize)
|
newSeq(x.data, StartSize)
|
||||||
for i in countup(0, StartSize - 1): x.data[i].key = InvalidKey
|
for i in 0 ..< StartSize: x.data[i].key = InvalidKey
|
||||||
|
|
||||||
proc iiTableRawGet(t: TIITable, key: int): int =
|
proc iiTableRawGet(t: TIITable, key: int): int =
|
||||||
var h: Hash
|
var h: Hash
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ proc hashType(c: var MD5Context, t: PType) =
|
||||||
|
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyGenericBody, tyGenericInst, tyGenericInvocation:
|
of tyGenericBody, tyGenericInst, tyGenericInvocation:
|
||||||
for i in countup(0, sonsLen(t) -1 -ord(t.kind != tyGenericInvocation)):
|
for i in 0 ..< sonsLen(t)-ord(t.kind != tyGenericInvocation):
|
||||||
c.hashType t.sons[i]
|
c.hashType t.sons[i]
|
||||||
of tyUserTypeClass:
|
of tyUserTypeClass:
|
||||||
internalAssert t.sym != nil and t.sym.owner != nil
|
internalAssert t.sym != nil and t.sym.owner != nil
|
||||||
|
|
@ -138,14 +138,14 @@ proc hashType(c: var MD5Context, t: PType) =
|
||||||
of tyTuple:
|
of tyTuple:
|
||||||
if t.n != nil:
|
if t.n != nil:
|
||||||
assert(sonsLen(t.n) == sonsLen(t))
|
assert(sonsLen(t.n) == sonsLen(t))
|
||||||
for i in countup(0, sonsLen(t.n) - 1):
|
for i in 0 ..< sonsLen(t.n):
|
||||||
assert(t.n.sons[i].kind == nkSym)
|
assert(t.n.sons[i].kind == nkSym)
|
||||||
c &= t.n.sons[i].sym.name.s
|
c &= t.n.sons[i].sym.name.s
|
||||||
c &= ":"
|
c &= ":"
|
||||||
c.hashType(t.sons[i])
|
c.hashType(t.sons[i])
|
||||||
c &= ","
|
c &= ","
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(t) - 1): c.hashType t.sons[i]
|
for i in 0 ..< sonsLen(t): c.hashType t.sons[i]
|
||||||
of tyRange:
|
of tyRange:
|
||||||
c.hashTree(t.n)
|
c.hashTree(t.n)
|
||||||
c.hashType(t.sons[0])
|
c.hashType(t.sons[0])
|
||||||
|
|
@ -238,7 +238,7 @@ proc encodeNode(w: PRodWriter, fInfo: TLineInfo, n: PNode,
|
||||||
encodeVInt(n.sym.id, result)
|
encodeVInt(n.sym.id, result)
|
||||||
pushSym(w, n.sym)
|
pushSym(w, n.sym)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
encodeNode(w, n.info, n.sons[i], result)
|
encodeNode(w, n.info, n.sons[i], result)
|
||||||
add(result, ')')
|
add(result, ')')
|
||||||
|
|
||||||
|
|
@ -304,7 +304,7 @@ proc encodeType(w: PRodWriter, t: PType, result: var string) =
|
||||||
add(result, '=')
|
add(result, '=')
|
||||||
encodeVInt(t.align, result)
|
encodeVInt(t.align, result)
|
||||||
encodeLoc(w, t.loc, result)
|
encodeLoc(w, t.loc, result)
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
if t.sons[i] == nil:
|
if t.sons[i] == nil:
|
||||||
add(result, "^()")
|
add(result, "^()")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ proc genPrefixCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
assert(typ.kind == tyProc)
|
assert(typ.kind == tyProc)
|
||||||
assert(sonsLen(typ) == sonsLen(typ.n))
|
assert(sonsLen(typ) == sonsLen(typ.n))
|
||||||
var length = sonsLen(ri)
|
var length = sonsLen(ri)
|
||||||
for i in countup(1, length - 1):
|
for i in 1 ..< length:
|
||||||
genParamLoop(params)
|
genParamLoop(params)
|
||||||
var callee = rdLoc(op)
|
var callee = rdLoc(op)
|
||||||
if p.hcrOn and ri.sons[0].kind == nkSym:
|
if p.hcrOn and ri.sons[0].kind == nkSym:
|
||||||
|
|
@ -223,7 +223,7 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
var typ = skipTypes(ri.sons[0].typ, abstractInst)
|
var typ = skipTypes(ri.sons[0].typ, abstractInst)
|
||||||
assert(typ.kind == tyProc)
|
assert(typ.kind == tyProc)
|
||||||
var length = sonsLen(ri)
|
var length = sonsLen(ri)
|
||||||
for i in countup(1, length - 1):
|
for i in 1 ..< length:
|
||||||
assert(sonsLen(typ) == sonsLen(typ.n))
|
assert(sonsLen(typ) == sonsLen(typ.n))
|
||||||
genParamLoop(pl)
|
genParamLoop(pl)
|
||||||
|
|
||||||
|
|
@ -470,7 +470,7 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
add(pl, genThisArg(p, ri, 1, typ))
|
add(pl, genThisArg(p, ri, 1, typ))
|
||||||
add(pl, op.r)
|
add(pl, op.r)
|
||||||
var params: Rope
|
var params: Rope
|
||||||
for i in countup(2, length - 1):
|
for i in 2 ..< length:
|
||||||
if params != nil: params.add(~", ")
|
if params != nil: params.add(~", ")
|
||||||
assert(sonsLen(typ) == sonsLen(typ.n))
|
assert(sonsLen(typ) == sonsLen(typ.n))
|
||||||
add(params, genOtherArg(p, ri, i, typ))
|
add(params, genOtherArg(p, ri, i, typ))
|
||||||
|
|
@ -506,7 +506,7 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) =
|
||||||
if length > 2:
|
if length > 2:
|
||||||
add(pl, ~": ")
|
add(pl, ~": ")
|
||||||
add(pl, genArg(p, ri.sons[2], typ.n.sons[2].sym, ri))
|
add(pl, genArg(p, ri.sons[2], typ.n.sons[2].sym, ri))
|
||||||
for i in countup(start, length-1):
|
for i in start ..< length:
|
||||||
assert(sonsLen(typ) == sonsLen(typ.n))
|
assert(sonsLen(typ) == sonsLen(typ.n))
|
||||||
if i >= sonsLen(typ):
|
if i >= sonsLen(typ):
|
||||||
internalError(p.config, ri.info, "varargs for objective C method?")
|
internalError(p.config, ri.info, "varargs for objective C method?")
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ proc bitSetToWord(s: TBitSet, size: int): BiggestInt =
|
||||||
proc genRawSetData(cs: TBitSet, size: int): Rope =
|
proc genRawSetData(cs: TBitSet, size: int): Rope =
|
||||||
if size > 8:
|
if size > 8:
|
||||||
result = "{$n" % []
|
result = "{$n" % []
|
||||||
for i in countup(0, size - 1):
|
for i in 0 ..< size:
|
||||||
if i < size - 1:
|
if i < size - 1:
|
||||||
# not last iteration?
|
# not last iteration?
|
||||||
if (i + 1) mod 8 == 0:
|
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) =
|
proc genFieldCheck(p: BProc, e: PNode, obj: Rope, field: PSym) =
|
||||||
var test, u, v: TLoc
|
var test, u, v: TLoc
|
||||||
for i in countup(1, sonsLen(e) - 1):
|
for i in 1 ..< sonsLen(e):
|
||||||
var it = e.sons[i]
|
var it = e.sons[i]
|
||||||
assert(it.kind in nkCallKinds)
|
assert(it.kind in nkCallKinds)
|
||||||
assert(it.sons[0].kind == nkSym)
|
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:
|
# generate call to newSeq before adding the elements per hand:
|
||||||
genNewSeqAux(p, dest[], l,
|
genNewSeqAux(p, dest[], l,
|
||||||
optNilSeqs notin p.options and n.len == 0)
|
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)
|
initLoc(arr, locExpr, n[i], OnHeap)
|
||||||
arr.r = ropecg(p.module, "$1$3[$2]", [rdLoc(dest[]), intLiteral(i), dataField(p)])
|
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
|
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)
|
initLocExpr(p, n.sons[1], a)
|
||||||
# bug #5007; do not produce excessive C source code:
|
# bug #5007; do not produce excessive C source code:
|
||||||
if L < 10:
|
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)
|
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.r = ropecg(p.module, "$1$3[$2]", [rdLoc(d), intLiteral(i), dataField(p)])
|
||||||
elem.storage = OnHeap # we know that sequences are on the heap
|
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])
|
var length = sonsLen(e.sons[1])
|
||||||
if length > 0:
|
if length > 0:
|
||||||
b.r = rope("(")
|
b.r = rope("(")
|
||||||
for i in countup(0, length - 1):
|
for i in 0 ..< length:
|
||||||
let it = e.sons[1].sons[i]
|
let it = e.sons[1].sons[i]
|
||||||
if it.kind == nkRange:
|
if it.kind == nkRange:
|
||||||
initLocExpr(p, it.sons[0], x)
|
initLocExpr(p, it.sons[0], x)
|
||||||
|
|
@ -2340,7 +2340,7 @@ proc genTupleConstr(p: BProc, n: PNode, d: var TLoc) =
|
||||||
let t = n.typ
|
let t = n.typ
|
||||||
discard getTypeDesc(p.module, t) # so that any fields are initialized
|
discard getTypeDesc(p.module, t) # so that any fields are initialized
|
||||||
if d.k == locNone: getTemp(p, t, d)
|
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]
|
var it = n.sons[i]
|
||||||
if it.kind == nkExprColonExpr: it = it.sons[1]
|
if it.kind == nkExprColonExpr: it = it.sons[1]
|
||||||
initLoc(rec, locExpr, it, d.storage)
|
initLoc(rec, locExpr, it, d.storage)
|
||||||
|
|
@ -2382,7 +2382,7 @@ proc genArrayConstr(p: BProc, n: PNode, d: var TLoc) =
|
||||||
var arr: TLoc
|
var arr: TLoc
|
||||||
if not handleConstExpr(p, n, d):
|
if not handleConstExpr(p, n, d):
|
||||||
if d.k == locNone: getTemp(p, n.typ, 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)
|
initLoc(arr, locExpr, lodeTyp elemType(skipTypes(n.typ, abstractInst)), d.storage)
|
||||||
arr.r = "$1[$2]" % [rdLoc(d), intLiteral(i)]
|
arr.r = "$1[$2]" % [rdLoc(d), intLiteral(i)]
|
||||||
expr(p, n.sons[i], arr)
|
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)
|
getNullValueAux(p, t, it, cons, result, count)
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
getNullValueAux(p, t, obj.sons[0], cons, result, count)
|
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)
|
getNullValueAux(p, t, lastSon(obj.sons[i]), cons, result, count)
|
||||||
of nkSym:
|
of nkSym:
|
||||||
if count > 0: result.add ", "
|
if count > 0: result.add ", "
|
||||||
|
|
@ -2817,7 +2817,7 @@ proc genConstSeq(p: BProc, n: PNode, t: PType): Rope =
|
||||||
if n.len > 0:
|
if n.len > 0:
|
||||||
# array part needs extra curlies:
|
# array part needs extra curlies:
|
||||||
data.add(", {")
|
data.add(", {")
|
||||||
for i in countup(0, n.len - 1):
|
for i in 0 ..< n.len:
|
||||||
if i > 0: data.addf(",$n", [])
|
if i > 0: data.addf(",$n", [])
|
||||||
data.add genConstExpr(p, n.sons[i])
|
data.add genConstExpr(p, n.sons[i])
|
||||||
data.add("}")
|
data.add("}")
|
||||||
|
|
@ -2837,7 +2837,7 @@ proc genConstSeq(p: BProc, n: PNode, t: PType): Rope =
|
||||||
|
|
||||||
proc genConstSeqV2(p: BProc, n: PNode, t: PType): Rope =
|
proc genConstSeqV2(p: BProc, n: PNode, t: PType): Rope =
|
||||||
var data = rope"{"
|
var data = rope"{"
|
||||||
for i in countup(0, n.len - 1):
|
for i in 0 ..< n.len:
|
||||||
if i > 0: data.addf(",$n", [])
|
if i > 0: data.addf(",$n", [])
|
||||||
data.add genConstExpr(p, n.sons[i])
|
data.add genConstExpr(p, n.sons[i])
|
||||||
data.add("}")
|
data.add("}")
|
||||||
|
|
|
||||||
|
|
@ -779,7 +779,7 @@ proc genCaseStringBranch(p: BProc, b: PNode, e: TLoc, labl: TLabel,
|
||||||
proc genStringCase(p: BProc, t: PNode, d: var TLoc) =
|
proc genStringCase(p: BProc, t: PNode, d: var TLoc) =
|
||||||
# count how many constant strings there are in the case:
|
# count how many constant strings there are in the case:
|
||||||
var strings = 0
|
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 t.sons[i].kind == nkOfBranch: inc(strings, sonsLen(t.sons[i]) - 1)
|
||||||
if strings > stringCaseThreshold:
|
if strings > stringCaseThreshold:
|
||||||
var bitMask = math.nextPowerOfTwo(strings) - 1
|
var bitMask = math.nextPowerOfTwo(strings) - 1
|
||||||
|
|
@ -788,7 +788,7 @@ proc genStringCase(p: BProc, t: PNode, d: var TLoc) =
|
||||||
var a: TLoc
|
var a: TLoc
|
||||||
initLocExpr(p, t.sons[0], a) # fist pass: gnerate ifs+goto:
|
initLocExpr(p, t.sons[0], a) # fist pass: gnerate ifs+goto:
|
||||||
var labId = p.labels
|
var labId = p.labels
|
||||||
for i in countup(1, sonsLen(t) - 1):
|
for i in 1 ..< sonsLen(t):
|
||||||
inc(p.labels)
|
inc(p.labels)
|
||||||
if t.sons[i].kind == nkOfBranch:
|
if t.sons[i].kind == nkOfBranch:
|
||||||
genCaseStringBranch(p, t.sons[i], a, "LA" & rope(p.labels) & "_",
|
genCaseStringBranch(p, t.sons[i], a, "LA" & rope(p.labels) & "_",
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ proc genTraverseProc(c: TTraversalClosure, accessor: Rope, n: PNode;
|
||||||
if n == nil: return
|
if n == nil: return
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
genTraverseProc(c, accessor, n.sons[i], typ)
|
genTraverseProc(c, accessor, n.sons[i], typ)
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
if (n.sons[0].kind != nkSym): internalError(c.p.config, n.info, "genTraverseProc")
|
if (n.sons[0].kind != nkSym): internalError(c.p.config, n.info, "genTraverseProc")
|
||||||
|
|
@ -38,7 +38,7 @@ proc genTraverseProc(c: TTraversalClosure, accessor: Rope, n: PNode;
|
||||||
if disc.loc.t == nil:
|
if disc.loc.t == nil:
|
||||||
internalError(c.p.config, n.info, "genTraverseProc()")
|
internalError(c.p.config, n.info, "genTraverseProc()")
|
||||||
lineF(p, cpsStmts, "switch ($1.$2) {$n", [accessor, disc.loc.r])
|
lineF(p, cpsStmts, "switch ($1.$2) {$n", [accessor, disc.loc.r])
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
let branch = n.sons[i]
|
let branch = n.sons[i]
|
||||||
assert branch.kind in {nkOfBranch, nkElse}
|
assert branch.kind in {nkOfBranch, nkElse}
|
||||||
if branch.kind == nkOfBranch:
|
if branch.kind == nkOfBranch:
|
||||||
|
|
@ -87,14 +87,14 @@ proc genTraverseProc(c: TTraversalClosure, accessor: Rope, typ: PType) =
|
||||||
else:
|
else:
|
||||||
lineF(p, cpsStmts, "}$n", [])
|
lineF(p, cpsStmts, "}$n", [])
|
||||||
of tyObject:
|
of tyObject:
|
||||||
for i in countup(0, sonsLen(typ) - 1):
|
for i in 0 ..< sonsLen(typ):
|
||||||
var x = typ.sons[i]
|
var x = typ.sons[i]
|
||||||
if x != nil: x = x.skipTypes(skipPtrs)
|
if x != nil: x = x.skipTypes(skipPtrs)
|
||||||
genTraverseProc(c, accessor.parentObj(c.p.module), x)
|
genTraverseProc(c, accessor.parentObj(c.p.module), x)
|
||||||
if typ.n != nil: genTraverseProc(c, accessor, typ.n, typ)
|
if typ.n != nil: genTraverseProc(c, accessor, typ.n, typ)
|
||||||
of tyTuple:
|
of tyTuple:
|
||||||
let typ = getUniqueType(typ)
|
let typ = getUniqueType(typ)
|
||||||
for i in countup(0, sonsLen(typ) - 1):
|
for i in 0 ..< sonsLen(typ):
|
||||||
genTraverseProc(c, ropecg(c.p.module, "$1.Field$2", [accessor, i]), typ.sons[i])
|
genTraverseProc(c, ropecg(c.p.module, "$1.Field$2", [accessor, i]), typ.sons[i])
|
||||||
of tyRef:
|
of tyRef:
|
||||||
lineCg(p, cpsStmts, visitorFrmt, [accessor, c.visitorFrmt])
|
lineCg(p, cpsStmts, visitorFrmt, [accessor, c.visitorFrmt])
|
||||||
|
|
|
||||||
|
|
@ -407,7 +407,7 @@ proc genProcParams(m: BModule, t: PType, rettype, params: var Rope,
|
||||||
rettype = ~"void"
|
rettype = ~"void"
|
||||||
else:
|
else:
|
||||||
rettype = getTypeDescAux(m, t.sons[0], check)
|
rettype = getTypeDescAux(m, t.sons[0], check)
|
||||||
for i in countup(1, sonsLen(t.n) - 1):
|
for i in 1 ..< sonsLen(t.n):
|
||||||
if t.n.sons[i].kind != nkSym: internalError(m.config, t.n.info, "genProcParams")
|
if t.n.sons[i].kind != nkSym: internalError(m.config, t.n.info, "genProcParams")
|
||||||
var param = t.n.sons[i].sym
|
var param = t.n.sons[i].sym
|
||||||
if isCompileTimeOnly(param.typ): continue
|
if isCompileTimeOnly(param.typ): continue
|
||||||
|
|
@ -468,7 +468,7 @@ proc genRecordFieldsAux(m: BModule, n: PNode,
|
||||||
result = nil
|
result = nil
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
add(result, genRecordFieldsAux(m, n.sons[i], rectype, check))
|
add(result, genRecordFieldsAux(m, n.sons[i], rectype, check))
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
if n.sons[0].kind != nkSym: internalError(m.config, n.info, "genRecordFieldsAux")
|
if n.sons[0].kind != nkSym: internalError(m.config, n.info, "genRecordFieldsAux")
|
||||||
|
|
@ -476,7 +476,7 @@ proc genRecordFieldsAux(m: BModule, n: PNode,
|
||||||
# prefix mangled name with "_U" to avoid clashes with other field names,
|
# prefix mangled name with "_U" to avoid clashes with other field names,
|
||||||
# since identifiers are not allowed to start with '_'
|
# since identifiers are not allowed to start with '_'
|
||||||
var unionBody: Rope = nil
|
var unionBody: Rope = nil
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
let k = lastSon(n.sons[i])
|
let k = lastSon(n.sons[i])
|
||||||
|
|
@ -591,7 +591,7 @@ proc getTupleDesc(m: BModule, typ: PType, name: Rope,
|
||||||
check: var IntSet): Rope =
|
check: var IntSet): Rope =
|
||||||
result = "$1 $2 {$n" % [structOrUnion(typ), name]
|
result = "$1 $2 {$n" % [structOrUnion(typ), name]
|
||||||
var desc: Rope = nil
|
var desc: Rope = nil
|
||||||
for i in countup(0, sonsLen(typ) - 1):
|
for i in 0 ..< sonsLen(typ):
|
||||||
addf(desc, "$1 Field$2;$n",
|
addf(desc, "$1 Field$2;$n",
|
||||||
[getTypeDescAux(m, typ.sons[i], check), rope(i)])
|
[getTypeDescAux(m, typ.sons[i], check), rope(i)])
|
||||||
if desc == nil: add(result, "char dummy;\L")
|
if desc == nil: add(result, "char dummy;\L")
|
||||||
|
|
@ -710,7 +710,7 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope =
|
||||||
let owner = hashOwner(t.sym)
|
let owner = hashOwner(t.sym)
|
||||||
if not gDebugInfo.hasEnum(t.sym.name.s, t.sym.info.line, owner):
|
if not gDebugInfo.hasEnum(t.sym.name.s, t.sym.info.line, owner):
|
||||||
var vals: seq[(string, int)] = @[]
|
var vals: seq[(string, int)] = @[]
|
||||||
for i in countup(0, t.n.len - 1):
|
for i in 0 ..< t.n.len:
|
||||||
assert(t.n.sons[i].kind == nkSym)
|
assert(t.n.sons[i].kind == nkSym)
|
||||||
let field = t.n.sons[i].sym
|
let field = t.n.sons[i].sym
|
||||||
vals.add((field.name.s, field.position.int))
|
vals.add((field.name.s, field.position.int))
|
||||||
|
|
@ -1047,7 +1047,7 @@ proc genObjectFields(m: BModule, typ, origType: PType, n: PNode, expr: Rope;
|
||||||
elif L > 0:
|
elif L > 0:
|
||||||
var tmp = getTempName(m) & "_" & $L
|
var tmp = getTempName(m) & "_" & $L
|
||||||
genTNimNodeArray(m, tmp, rope(L))
|
genTNimNodeArray(m, tmp, rope(L))
|
||||||
for i in countup(0, L-1):
|
for i in 0 ..< L:
|
||||||
var tmp2 = getNimNode(m)
|
var tmp2 = getNimNode(m)
|
||||||
addf(m.s[cfsTypeInit3], "$1[$2] = &$3;$n", [tmp, rope(i), tmp2])
|
addf(m.s[cfsTypeInit3], "$1[$2] = &$3;$n", [tmp, rope(i), tmp2])
|
||||||
genObjectFields(m, typ, origType, n.sons[i], tmp2, info)
|
genObjectFields(m, typ, origType, n.sons[i], tmp2, info)
|
||||||
|
|
@ -1072,7 +1072,7 @@ proc genObjectFields(m: BModule, typ, origType: PType, n: PNode, expr: Rope;
|
||||||
makeCString(field.name.s),
|
makeCString(field.name.s),
|
||||||
tmp, rope(L)])
|
tmp, rope(L)])
|
||||||
addf(m.s[cfsData], "TNimNode* $1[$2];$n", [tmp, rope(L+1)])
|
addf(m.s[cfsData], "TNimNode* $1[$2];$n", [tmp, rope(L+1)])
|
||||||
for i in countup(1, sonsLen(n)-1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var b = n.sons[i] # branch
|
var b = n.sons[i] # branch
|
||||||
var tmp2 = getNimNode(m)
|
var tmp2 = getNimNode(m)
|
||||||
genObjectFields(m, typ, origType, lastSon(b), tmp2, info)
|
genObjectFields(m, typ, origType, lastSon(b), tmp2, info)
|
||||||
|
|
@ -1133,7 +1133,7 @@ proc genTupleInfo(m: BModule, typ, origType: PType, name: Rope; info: TLineInfo)
|
||||||
if length > 0:
|
if length > 0:
|
||||||
var tmp = getTempName(m) & "_" & $length
|
var tmp = getTempName(m) & "_" & $length
|
||||||
genTNimNodeArray(m, tmp, rope(length))
|
genTNimNodeArray(m, tmp, rope(length))
|
||||||
for i in countup(0, length - 1):
|
for i in 0 ..< length:
|
||||||
var a = typ.sons[i]
|
var a = typ.sons[i]
|
||||||
var tmp2 = getNimNode(m)
|
var tmp2 = getNimNode(m)
|
||||||
addf(m.s[cfsTypeInit3], "$1[$2] = &$3;$n", [tmp, rope(i), tmp2])
|
addf(m.s[cfsTypeInit3], "$1[$2] = &$3;$n", [tmp, rope(i), tmp2])
|
||||||
|
|
@ -1161,7 +1161,7 @@ proc genEnumInfo(m: BModule, typ: PType, name: Rope; info: TLineInfo) =
|
||||||
var enumNames, specialCases: Rope
|
var enumNames, specialCases: Rope
|
||||||
var firstNimNode = m.typeNodes
|
var firstNimNode = m.typeNodes
|
||||||
var hasHoles = false
|
var hasHoles = false
|
||||||
for i in countup(0, length - 1):
|
for i in 0 ..< length:
|
||||||
assert(typ.n.sons[i].kind == nkSym)
|
assert(typ.n.sons[i].kind == nkSym)
|
||||||
var field = typ.n.sons[i].sym
|
var field = typ.n.sons[i].sym
|
||||||
var elemNode = getNimNode(m)
|
var elemNode = getNimNode(m)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ proc hashString*(conf: ConfigRef; s: string): BiggestInt =
|
||||||
# we have to use the same bitwidth
|
# we have to use the same bitwidth
|
||||||
# as the target CPU
|
# as the target CPU
|
||||||
var b = 0'i64
|
var b = 0'i64
|
||||||
for i in countup(0, len(s) - 1):
|
for i in 0 ..< len(s):
|
||||||
b = b +% ord(s[i])
|
b = b +% ord(s[i])
|
||||||
b = b +% `shl`(b, 10)
|
b = b +% `shl`(b, 10)
|
||||||
b = b xor `shr`(b, 6)
|
b = b xor `shr`(b, 6)
|
||||||
|
|
@ -43,7 +43,7 @@ proc hashString*(conf: ConfigRef; s: string): BiggestInt =
|
||||||
result = b
|
result = b
|
||||||
else:
|
else:
|
||||||
var a = 0'i32
|
var a = 0'i32
|
||||||
for i in countup(0, len(s) - 1):
|
for i in 0 ..< len(s):
|
||||||
a = a +% ord(s[i]).int32
|
a = a +% ord(s[i]).int32
|
||||||
a = a +% `shl`(a, 10'i32)
|
a = a +% `shl`(a, 10'i32)
|
||||||
a = a xor `shr`(a, 6'i32)
|
a = a xor `shr`(a, 6'i32)
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ macro ropecg(m: BModule, frmt: static[FormatStr], args: untyped): Rope =
|
||||||
|
|
||||||
proc indentLine(p: BProc, r: Rope): Rope =
|
proc indentLine(p: BProc, r: Rope): Rope =
|
||||||
result = r
|
result = r
|
||||||
for i in countup(0, p.blocks.len-1):
|
for i in 0 ..< p.blocks.len:
|
||||||
prepend(result, "\t".rope)
|
prepend(result, "\t".rope)
|
||||||
|
|
||||||
template appcg(m: BModule, c: var Rope, frmt: FormatStr,
|
template appcg(m: BModule, c: var Rope, frmt: FormatStr,
|
||||||
|
|
@ -1004,7 +1004,7 @@ proc genProcAux(m: BModule, prc: PSym) =
|
||||||
#incl(res.loc.flags, lfIndirect)
|
#incl(res.loc.flags, lfIndirect)
|
||||||
res.loc.storage = OnUnknown
|
res.loc.storage = OnUnknown
|
||||||
|
|
||||||
for i in countup(1, sonsLen(prc.typ.n) - 1):
|
for i in 1 ..< sonsLen(prc.typ.n):
|
||||||
let param = prc.typ.n.sons[i].sym
|
let param = prc.typ.n.sons[i].sym
|
||||||
if param.typ.isCompileTimeOnly: continue
|
if param.typ.isCompileTimeOnly: continue
|
||||||
assignParam(p, param, prc.typ[0])
|
assignParam(p, param, prc.typ[0])
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ proc methodCall*(n: PNode; conf: ConfigRef): PNode =
|
||||||
if disp != nil:
|
if disp != nil:
|
||||||
result.sons[0].sym = disp
|
result.sons[0].sym = disp
|
||||||
# change the arguments to up/downcasts to fit the dispatcher's parameters:
|
# change the arguments to up/downcasts to fit the dispatcher's parameters:
|
||||||
for i in countup(1, sonsLen(result)-1):
|
for i in 1 ..< sonsLen(result):
|
||||||
result.sons[i] = genConv(result.sons[i], disp.typ.sons[i], true, conf)
|
result.sons[i] = genConv(result.sons[i], disp.typ.sons[i], true, conf)
|
||||||
else:
|
else:
|
||||||
localError(conf, n.info, "'" & $result.sons[0] & "' lacks a dispatcher")
|
localError(conf, n.info, "'" & $result.sons[0] & "' lacks a dispatcher")
|
||||||
|
|
@ -61,7 +61,7 @@ proc sameMethodBucket(a, b: PSym): MethodResult =
|
||||||
if sonsLen(a.typ) != sonsLen(b.typ):
|
if sonsLen(a.typ) != sonsLen(b.typ):
|
||||||
return
|
return
|
||||||
|
|
||||||
for i in countup(1, sonsLen(a.typ) - 1):
|
for i in 1 ..< sonsLen(a.typ):
|
||||||
var aa = a.typ.sons[i]
|
var aa = a.typ.sons[i]
|
||||||
var bb = b.typ.sons[i]
|
var bb = b.typ.sons[i]
|
||||||
while true:
|
while true:
|
||||||
|
|
@ -160,7 +160,7 @@ proc fixupDispatcher(meth, disp: PSym; conf: ConfigRef) =
|
||||||
proc methodDef*(g: ModuleGraph; s: PSym, fromCache: bool) =
|
proc methodDef*(g: ModuleGraph; s: PSym, fromCache: bool) =
|
||||||
let L = len(g.methods)
|
let L = len(g.methods)
|
||||||
var witness: PSym
|
var witness: PSym
|
||||||
for i in countup(0, L - 1):
|
for i in 0 ..< L:
|
||||||
let disp = g.methods[i].dispatcher
|
let disp = g.methods[i].dispatcher
|
||||||
case sameMethodBucket(disp, s)
|
case sameMethodBucket(disp, s)
|
||||||
of Yes:
|
of Yes:
|
||||||
|
|
@ -198,7 +198,7 @@ proc relevantCol(methods: seq[PSym], col: int): bool =
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc cmpSignatures(a, b: PSym, relevantCols: IntSet): int =
|
proc cmpSignatures(a, b: PSym, relevantCols: IntSet): int =
|
||||||
for col in countup(1, sonsLen(a.typ) - 1):
|
for col in 1 ..< sonsLen(a.typ):
|
||||||
if contains(relevantCols, col):
|
if contains(relevantCols, col):
|
||||||
var aa = skipTypes(a.typ.sons[col], skipPtrs)
|
var aa = skipTypes(a.typ.sons[col], skipPtrs)
|
||||||
var bb = skipTypes(b.typ.sons[col], skipPtrs)
|
var bb = skipTypes(b.typ.sons[col], skipPtrs)
|
||||||
|
|
@ -215,7 +215,7 @@ proc sortBucket(a: var seq[PSym], relevantCols: IntSet) =
|
||||||
if h > n: break
|
if h > n: break
|
||||||
while true:
|
while true:
|
||||||
h = h div 3
|
h = h div 3
|
||||||
for i in countup(h, n - 1):
|
for i in h ..< n:
|
||||||
var v = a[i]
|
var v = a[i]
|
||||||
var j = i
|
var j = i
|
||||||
while cmpSignatures(a[j - h], v, relevantCols) >= 0:
|
while cmpSignatures(a[j - h], v, relevantCols) >= 0:
|
||||||
|
|
@ -234,7 +234,7 @@ proc genDispatcher(g: ModuleGraph; methods: seq[PSym], relevantCols: IntSet): PS
|
||||||
var ands = getSysMagic(g, unknownLineInfo(), "and", mAnd)
|
var ands = getSysMagic(g, unknownLineInfo(), "and", mAnd)
|
||||||
var iss = getSysMagic(g, unknownLineInfo(), "of", mOf)
|
var iss = getSysMagic(g, unknownLineInfo(), "of", mOf)
|
||||||
let boolType = getSysType(g, unknownLineInfo(), tyBool)
|
let boolType = getSysType(g, unknownLineInfo(), tyBool)
|
||||||
for col in countup(1, paramLen - 1):
|
for col in 1 ..< paramLen:
|
||||||
if contains(relevantCols, col):
|
if contains(relevantCols, col):
|
||||||
let param = base.typ.n.sons[col].sym
|
let param = base.typ.n.sons[col].sym
|
||||||
if param.typ.skipTypes(abstractInst).kind in {tyRef, tyPtr}:
|
if param.typ.skipTypes(abstractInst).kind in {tyRef, tyPtr}:
|
||||||
|
|
@ -243,7 +243,7 @@ proc genDispatcher(g: ModuleGraph; methods: seq[PSym], relevantCols: IntSet): PS
|
||||||
for meth in countup(0, high(methods)):
|
for meth in countup(0, high(methods)):
|
||||||
var curr = methods[meth] # generate condition:
|
var curr = methods[meth] # generate condition:
|
||||||
var cond: PNode = nil
|
var cond: PNode = nil
|
||||||
for col in countup(1, paramLen - 1):
|
for col in 1 ..< paramLen:
|
||||||
if contains(relevantCols, col):
|
if contains(relevantCols, col):
|
||||||
var isn = newNodeIT(nkCall, base.info, boolType)
|
var isn = newNodeIT(nkCall, base.info, boolType)
|
||||||
addSon(isn, newSymNode(iss))
|
addSon(isn, newSymNode(iss))
|
||||||
|
|
@ -261,7 +261,7 @@ proc genDispatcher(g: ModuleGraph; methods: seq[PSym], relevantCols: IntSet): PS
|
||||||
let retTyp = base.typ.sons[0]
|
let retTyp = base.typ.sons[0]
|
||||||
let call = newNodeIT(nkCall, base.info, retTyp)
|
let call = newNodeIT(nkCall, base.info, retTyp)
|
||||||
addSon(call, newSymNode(curr))
|
addSon(call, newSymNode(curr))
|
||||||
for col in countup(1, paramLen - 1):
|
for col in 1 ..< paramLen:
|
||||||
addSon(call, genConv(newSymNode(base.typ.n.sons[col].sym),
|
addSon(call, genConv(newSymNode(base.typ.n.sons[col].sym),
|
||||||
curr.typ.sons[col], false, g.config))
|
curr.typ.sons[col], false, g.config))
|
||||||
var ret: PNode
|
var ret: PNode
|
||||||
|
|
@ -286,9 +286,9 @@ proc genDispatcher(g: ModuleGraph; methods: seq[PSym], relevantCols: IntSet): PS
|
||||||
|
|
||||||
proc generateMethodDispatchers*(g: ModuleGraph): PNode =
|
proc generateMethodDispatchers*(g: ModuleGraph): PNode =
|
||||||
result = newNode(nkStmtList)
|
result = newNode(nkStmtList)
|
||||||
for bucket in countup(0, len(g.methods) - 1):
|
for bucket in 0 ..< len(g.methods):
|
||||||
var relevantCols = initIntSet()
|
var relevantCols = initIntSet()
|
||||||
for col in countup(1, sonsLen(g.methods[bucket].methods[0].typ) - 1):
|
for col in 1 ..< sonsLen(g.methods[bucket].methods[0].typ):
|
||||||
if relevantCol(g.methods[bucket].methods, col): incl(relevantCols, col)
|
if relevantCol(g.methods[bucket].methods, col): incl(relevantCols, col)
|
||||||
if optMultiMethods notin g.config.globalOptions:
|
if optMultiMethods notin g.config.globalOptions:
|
||||||
# if multi-methods are not enabled, we are interested only in the first field
|
# if multi-methods are not enabled, we are interested only in the first field
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ proc addDotDependency(c: PPassContext, n: PNode): PNode =
|
||||||
let b = Backend(g.graph.backend)
|
let b = Backend(g.graph.backend)
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkImportStmt:
|
of nkImportStmt:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var imported = getModuleName(g.config, n.sons[i])
|
var imported = getModuleName(g.config, n.sons[i])
|
||||||
addDependencyAux(b, g.module.name.s, imported)
|
addDependencyAux(b, g.module.name.s, imported)
|
||||||
of nkFromStmt, nkImportExceptStmt:
|
of nkFromStmt, nkImportExceptStmt:
|
||||||
var imported = getModuleName(g.config, n.sons[0])
|
var imported = getModuleName(g.config, n.sons[0])
|
||||||
addDependencyAux(b, g.module.name.s, imported)
|
addDependencyAux(b, g.module.name.s, imported)
|
||||||
of nkStmtList, nkBlockStmt, nkStmtListExpr, nkBlockExpr:
|
of nkStmtList, nkBlockStmt, nkStmtListExpr, nkBlockExpr:
|
||||||
for i in countup(0, sonsLen(n) - 1): discard addDotDependency(c, n.sons[i])
|
for i in 0 ..< sonsLen(n): discard addDotDependency(c, n.sons[i])
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -441,7 +441,7 @@ proc genIf(c: var Con, n: PNode) =
|
||||||
]#
|
]#
|
||||||
let oldLen = c.forks.len
|
let oldLen = c.forks.len
|
||||||
var endings: seq[TPosition] = @[]
|
var endings: seq[TPosition] = @[]
|
||||||
for i in countup(0, len(n) - 1):
|
for i in 0 ..< len(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
c.gen(it.sons[0])
|
c.gen(it.sons[0])
|
||||||
if it.len == 2:
|
if it.len == 2:
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ proc genRecCommentAux(d: PDoc, n: PNode): Rope =
|
||||||
if n.kind in {nkStmtList, nkStmtListExpr, nkTypeDef, nkConstDef,
|
if n.kind in {nkStmtList, nkStmtListExpr, nkTypeDef, nkConstDef,
|
||||||
nkObjectTy, nkRefTy, nkPtrTy, nkAsgn, nkFastAsgn, nkHiddenStdConv}:
|
nkObjectTy, nkRefTy, nkPtrTy, nkAsgn, nkFastAsgn, nkHiddenStdConv}:
|
||||||
# notin {nkEmpty..nkNilLit, nkEnumTy, nkTupleTy}:
|
# notin {nkEmpty..nkNilLit, nkEnumTy, nkTupleTy}:
|
||||||
for i in countup(0, len(n)-1):
|
for i in 0 ..< len(n):
|
||||||
result = genRecCommentAux(d, n.sons[i])
|
result = genRecCommentAux(d, n.sons[i])
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
else:
|
else:
|
||||||
|
|
@ -284,7 +284,7 @@ proc getPlainDocstring(n: PNode): string =
|
||||||
if startsWith(n.comment, "##"):
|
if startsWith(n.comment, "##"):
|
||||||
result = n.comment
|
result = n.comment
|
||||||
if result.len < 1:
|
if result.len < 1:
|
||||||
for i in countup(0, safeLen(n)-1):
|
for i in 0 ..< safeLen(n):
|
||||||
result = getPlainDocstring(n.sons[i])
|
result = getPlainDocstring(n.sons[i])
|
||||||
if result.len > 0: return
|
if result.len > 0: return
|
||||||
|
|
||||||
|
|
@ -838,13 +838,13 @@ proc generateDoc*(d: PDoc, n, orig: PNode) =
|
||||||
when useEffectSystem: documentRaises(d.cache, n)
|
when useEffectSystem: documentRaises(d.cache, n)
|
||||||
genItem(d, n, n.sons[namePos], skConverter)
|
genItem(d, n, n.sons[namePos], skConverter)
|
||||||
of nkTypeSection, nkVarSection, nkLetSection, nkConstSection:
|
of nkTypeSection, nkVarSection, nkLetSection, nkConstSection:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if n.sons[i].kind != nkCommentStmt:
|
if n.sons[i].kind != nkCommentStmt:
|
||||||
# order is always 'type var let const':
|
# order is always 'type var let const':
|
||||||
genItem(d, n.sons[i], n.sons[i].sons[0],
|
genItem(d, n.sons[i], n.sons[i].sons[0],
|
||||||
succ(skType, ord(n.kind)-ord(nkTypeSection)))
|
succ(skType, ord(n.kind)-ord(nkTypeSection)))
|
||||||
of nkStmtList:
|
of nkStmtList:
|
||||||
for i in countup(0, sonsLen(n) - 1): generateDoc(d, n.sons[i], orig)
|
for i in 0 ..< sonsLen(n): generateDoc(d, n.sons[i], orig)
|
||||||
of nkWhenStmt:
|
of nkWhenStmt:
|
||||||
# generate documentation for the first branch only:
|
# generate documentation for the first branch only:
|
||||||
if not checkForFalse(n.sons[0].sons[0]):
|
if not checkForFalse(n.sons[0].sons[0]):
|
||||||
|
|
@ -892,13 +892,13 @@ proc generateJson*(d: PDoc, n: PNode, includeComments: bool = true) =
|
||||||
when useEffectSystem: documentRaises(d.cache, n)
|
when useEffectSystem: documentRaises(d.cache, n)
|
||||||
d.add genJsonItem(d, n, n.sons[namePos], skConverter)
|
d.add genJsonItem(d, n, n.sons[namePos], skConverter)
|
||||||
of nkTypeSection, nkVarSection, nkLetSection, nkConstSection:
|
of nkTypeSection, nkVarSection, nkLetSection, nkConstSection:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if n.sons[i].kind != nkCommentStmt:
|
if n.sons[i].kind != nkCommentStmt:
|
||||||
# order is always 'type var let const':
|
# order is always 'type var let const':
|
||||||
d.add genJsonItem(d, n.sons[i], n.sons[i].sons[0],
|
d.add genJsonItem(d, n.sons[i], n.sons[i].sons[0],
|
||||||
succ(skType, ord(n.kind)-ord(nkTypeSection)))
|
succ(skType, ord(n.kind)-ord(nkTypeSection)))
|
||||||
of nkStmtList:
|
of nkStmtList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
generateJson(d, n.sons[i], includeComments)
|
generateJson(d, n.sons[i], includeComments)
|
||||||
of nkWhenStmt:
|
of nkWhenStmt:
|
||||||
# generate documentation for the first branch only:
|
# generate documentation for the first branch only:
|
||||||
|
|
@ -935,13 +935,13 @@ proc generateTags*(d: PDoc, n: PNode, r: var Rope) =
|
||||||
when useEffectSystem: documentRaises(d.cache, n)
|
when useEffectSystem: documentRaises(d.cache, n)
|
||||||
r.add genTagsItem(d, n, n.sons[namePos], skConverter)
|
r.add genTagsItem(d, n, n.sons[namePos], skConverter)
|
||||||
of nkTypeSection, nkVarSection, nkLetSection, nkConstSection:
|
of nkTypeSection, nkVarSection, nkLetSection, nkConstSection:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if n.sons[i].kind != nkCommentStmt:
|
if n.sons[i].kind != nkCommentStmt:
|
||||||
# order is always 'type var let const':
|
# order is always 'type var let const':
|
||||||
r.add genTagsItem(d, n.sons[i], n.sons[i].sons[0],
|
r.add genTagsItem(d, n.sons[i], n.sons[i].sons[0],
|
||||||
succ(skType, ord(n.kind)-ord(nkTypeSection)))
|
succ(skType, ord(n.kind)-ord(nkTypeSection)))
|
||||||
of nkStmtList:
|
of nkStmtList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
generateTags(d, n.sons[i], r)
|
generateTags(d, n.sons[i], r)
|
||||||
of nkWhenStmt:
|
of nkWhenStmt:
|
||||||
# generate documentation for the first branch only:
|
# generate documentation for the first branch only:
|
||||||
|
|
|
||||||
|
|
@ -138,13 +138,13 @@ proc pack(conf: ConfigRef, v: PNode, typ: PType, res: pointer)
|
||||||
proc getField(conf: ConfigRef, n: PNode; position: int): PSym =
|
proc getField(conf: ConfigRef, n: PNode; position: int): PSym =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = getField(conf, n.sons[i], position)
|
result = getField(conf, n.sons[i], position)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
result = getField(conf, n.sons[0], position)
|
result = getField(conf, n.sons[0], position)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
result = getField(conf, lastSon(n.sons[i]), position)
|
result = getField(conf, lastSon(n.sons[i]), position)
|
||||||
|
|
@ -158,7 +158,7 @@ proc packObject(conf: ConfigRef, x: PNode, typ: PType, res: pointer) =
|
||||||
internalAssert conf, x.kind in {nkObjConstr, nkPar, nkTupleConstr}
|
internalAssert conf, x.kind in {nkObjConstr, nkPar, nkTupleConstr}
|
||||||
# compute the field's offsets:
|
# compute the field's offsets:
|
||||||
discard getSize(conf, typ)
|
discard getSize(conf, typ)
|
||||||
for i in countup(ord(x.kind == nkObjConstr), sonsLen(x) - 1):
|
for i in ord(x.kind == nkObjConstr) ..< sonsLen(x):
|
||||||
var it = x.sons[i]
|
var it = x.sons[i]
|
||||||
if it.kind == nkExprColonExpr:
|
if it.kind == nkExprColonExpr:
|
||||||
internalAssert conf, it.sons[0].kind == nkSym
|
internalAssert conf, it.sons[0].kind == nkSym
|
||||||
|
|
@ -245,7 +245,7 @@ proc unpack(conf: ConfigRef, x: pointer, typ: PType, n: PNode): PNode
|
||||||
proc unpackObjectAdd(conf: ConfigRef, x: pointer, n, result: PNode) =
|
proc unpackObjectAdd(conf: ConfigRef, x: pointer, n, result: PNode) =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
unpackObjectAdd(conf, x, n.sons[i], result)
|
unpackObjectAdd(conf, x, n.sons[i], result)
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
globalError(conf, result.info, "case objects cannot be unpacked")
|
globalError(conf, result.info, "case objects cannot be unpacked")
|
||||||
|
|
@ -275,7 +275,7 @@ proc unpackObject(conf: ConfigRef, x: pointer, typ: PType, n: PNode): PNode =
|
||||||
globalError(conf, n.info, "cannot map value from FFI")
|
globalError(conf, n.info, "cannot map value from FFI")
|
||||||
if typ.n.isNil:
|
if typ.n.isNil:
|
||||||
globalError(conf, n.info, "cannot unpack unnamed tuple")
|
globalError(conf, n.info, "cannot unpack unnamed tuple")
|
||||||
for i in countup(ord(n.kind == nkObjConstr), sonsLen(n) - 1):
|
for i in ord(n.kind == nkObjConstr) ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.kind == nkExprColonExpr:
|
if it.kind == nkExprColonExpr:
|
||||||
internalAssert conf, it.sons[0].kind == nkSym
|
internalAssert conf, it.sons[0].kind == nkSym
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ proc evalTemplateAux(templ, actual: PNode, c: var TemplCtx, result: PNode) =
|
||||||
# "declarative" context (bug #9235).
|
# "declarative" context (bug #9235).
|
||||||
if c.isDeclarative:
|
if c.isDeclarative:
|
||||||
var res = copyNode(c, templ, actual)
|
var res = copyNode(c, templ, actual)
|
||||||
for i in countup(0, sonsLen(templ) - 1):
|
for i in 0 ..< sonsLen(templ):
|
||||||
evalTemplateAux(templ.sons[i], actual, c, res)
|
evalTemplateAux(templ.sons[i], actual, c, res)
|
||||||
result.add res
|
result.add res
|
||||||
else:
|
else:
|
||||||
|
|
@ -78,7 +78,7 @@ proc evalTemplateAux(templ, actual: PNode, c: var TemplCtx, result: PNode) =
|
||||||
c.isDeclarative = true
|
c.isDeclarative = true
|
||||||
isDeclarative = true
|
isDeclarative = true
|
||||||
var res = copyNode(c, templ, actual)
|
var res = copyNode(c, templ, actual)
|
||||||
for i in countup(0, sonsLen(templ) - 1):
|
for i in 0 ..< sonsLen(templ):
|
||||||
evalTemplateAux(templ.sons[i], actual, c, res)
|
evalTemplateAux(templ.sons[i], actual, c, res)
|
||||||
result.add res
|
result.add res
|
||||||
if isDeclarative: c.isDeclarative = false
|
if isDeclarative: c.isDeclarative = false
|
||||||
|
|
@ -189,7 +189,7 @@ proc evalTemplate*(n: PNode, tmpl, genSymOwner: PSym;
|
||||||
ctx.instLines = sfCallsite in tmpl.flags
|
ctx.instLines = sfCallsite in tmpl.flags
|
||||||
if ctx.instLines:
|
if ctx.instLines:
|
||||||
result.info = n.info
|
result.info = n.info
|
||||||
for i in countup(0, safeLen(body) - 1):
|
for i in 0 ..< safeLen(body):
|
||||||
evalTemplateAux(body.sons[i], args, ctx, result)
|
evalTemplateAux(body.sons[i], args, ctx, result)
|
||||||
result.flags.incl nfFromTemplate
|
result.flags.incl nfFromTemplate
|
||||||
result = wrapInComesFrom(n.info, tmpl, result)
|
result = wrapInComesFrom(n.info, tmpl, result)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ proc invalidPragma(conf: ConfigRef; n: PNode) =
|
||||||
proc getArg(conf: ConfigRef; n: PNode, name: string, pos: int): PNode =
|
proc getArg(conf: ConfigRef; n: PNode, name: string, pos: int): PNode =
|
||||||
result = nil
|
result = nil
|
||||||
if n.kind in {nkEmpty..nkNilLit}: return
|
if n.kind in {nkEmpty..nkNilLit}: return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
if n.sons[i].kind == nkExprEqExpr:
|
if n.sons[i].kind == nkExprEqExpr:
|
||||||
if n.sons[i].sons[0].kind != nkIdent: invalidPragma(conf, n)
|
if n.sons[i].sons[0].kind != nkIdent: invalidPragma(conf, n)
|
||||||
if cmpIgnoreStyle(n.sons[i].sons[0].ident.s, name) == 0:
|
if cmpIgnoreStyle(n.sons[i].sons[0].ident.s, name) == 0:
|
||||||
|
|
|
||||||
|
|
@ -443,7 +443,7 @@ proc sameTree*(a, b: PNode): bool =
|
||||||
of nkEmpty, nkNilLit: result = true
|
of nkEmpty, nkNilLit: result = true
|
||||||
else:
|
else:
|
||||||
if sonsLen(a) == sonsLen(b):
|
if sonsLen(a) == sonsLen(b):
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
if not sameTree(a.sons[i], b.sons[i]): return
|
if not sameTree(a.sons[i], b.sons[i]): return
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ proc getIdent*(ic: IdentCache; identifier: cstring, length: int, h: Hash): PIden
|
||||||
new(result)
|
new(result)
|
||||||
result.h = h
|
result.h = h
|
||||||
result.s = newString(length)
|
result.s = newString(length)
|
||||||
for i in countup(0, length - 1): result.s[i] = identifier[i]
|
for i in 0 ..< length: result.s[i] = identifier[i]
|
||||||
result.next = ic.buckets[idx]
|
result.next = ic.buckets[idx]
|
||||||
ic.buckets[idx] = result
|
ic.buckets[idx] = result
|
||||||
if id == 0:
|
if id == 0:
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ proc rawImportSymbol(c: PContext, s: PSym) =
|
||||||
if s.kind == skType:
|
if s.kind == skType:
|
||||||
var etyp = s.typ
|
var etyp = s.typ
|
||||||
if etyp.kind in {tyBool, tyEnum}:
|
if etyp.kind in {tyBool, tyEnum}:
|
||||||
for j in countup(0, sonsLen(etyp.n) - 1):
|
for j in 0 ..< sonsLen(etyp.n):
|
||||||
var e = etyp.n.sons[j].sym
|
var e = etyp.n.sons[j].sym
|
||||||
if e.kind != skEnumField:
|
if e.kind != skEnumField:
|
||||||
internalError(c.config, s.info, "rawImportSymbol")
|
internalError(c.config, s.info, "rawImportSymbol")
|
||||||
|
|
@ -146,7 +146,7 @@ proc myImportModule(c: PContext, n: PNode; importStmtResult: PNode): PSym =
|
||||||
#echo "adding ", toFullPath(f), " at ", L+1
|
#echo "adding ", toFullPath(f), " at ", L+1
|
||||||
if recursion >= 0:
|
if recursion >= 0:
|
||||||
var err = ""
|
var err = ""
|
||||||
for i in countup(recursion, L-1):
|
for i in recursion ..< L:
|
||||||
if i > recursion: err.add "\n"
|
if i > recursion: err.add "\n"
|
||||||
err.add toFullPath(c.config, c.graph.importStack[i]) & " imports " &
|
err.add toFullPath(c.config, c.graph.importStack[i]) & " imports " &
|
||||||
toFullPath(c.config, c.graph.importStack[i+1])
|
toFullPath(c.config, c.graph.importStack[i+1])
|
||||||
|
|
@ -189,7 +189,7 @@ proc impMod(c: PContext; it: PNode; importStmtResult: PNode) =
|
||||||
|
|
||||||
proc evalImport*(c: PContext, n: PNode): PNode =
|
proc evalImport*(c: PContext, n: PNode): PNode =
|
||||||
result = newNodeI(nkImportStmt, n.info)
|
result = newNodeI(nkImportStmt, n.info)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket:
|
if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket:
|
||||||
let sep = it[0]
|
let sep = it[0]
|
||||||
|
|
@ -219,7 +219,7 @@ proc evalFrom*(c: PContext, n: PNode): PNode =
|
||||||
if m != nil:
|
if m != nil:
|
||||||
n.sons[0] = newSymNode(m)
|
n.sons[0] = newSymNode(m)
|
||||||
addDecl(c, m, n.info) # add symbol to symbol table of module
|
addDecl(c, m, n.info) # add symbol to symbol table of module
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
if n.sons[i].kind != nkNilLit:
|
if n.sons[i].kind != nkNilLit:
|
||||||
importSymbol(c, n.sons[i], m)
|
importSymbol(c, n.sons[i], m)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ proc indentLine(p: PProc, r: Rope): Rope =
|
||||||
result = r
|
result = r
|
||||||
var p = p
|
var p = p
|
||||||
while true:
|
while true:
|
||||||
for i in countup(0, p.blocks.len - 1 + p.extraIndent):
|
for i in 0 ..< p.blocks.len + p.extraIndent:
|
||||||
prepend(result, "\t".rope)
|
prepend(result, "\t".rope)
|
||||||
if p.up == nil or p.up.prc != p.prc.owner:
|
if p.up == nil or p.up.prc != p.prc.owner:
|
||||||
break
|
break
|
||||||
|
|
@ -858,7 +858,7 @@ proc genCaseJS(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
if not isEmptyType(n.typ):
|
if not isEmptyType(n.typ):
|
||||||
r.kind = resVal
|
r.kind = resVal
|
||||||
r.res = getTemp(p)
|
r.res = getTemp(p)
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
case it.kind
|
case it.kind
|
||||||
of nkOfBranch:
|
of nkOfBranch:
|
||||||
|
|
@ -930,7 +930,7 @@ proc genBreakStmt(p: PProc, n: PNode) =
|
||||||
proc genAsmOrEmitStmt(p: PProc, n: PNode) =
|
proc genAsmOrEmitStmt(p: PProc, n: PNode) =
|
||||||
genLineDir(p, n)
|
genLineDir(p, n)
|
||||||
p.body.add p.indentLine(nil)
|
p.body.add p.indentLine(nil)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
let it = n[i]
|
let it = n[i]
|
||||||
case it.kind
|
case it.kind
|
||||||
of nkStrLit..nkTripleStrLit:
|
of nkStrLit..nkTripleStrLit:
|
||||||
|
|
@ -968,7 +968,7 @@ proc genIf(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
if not isEmptyType(n.typ):
|
if not isEmptyType(n.typ):
|
||||||
r.kind = resVal
|
r.kind = resVal
|
||||||
r.res = getTemp(p)
|
r.res = getTemp(p)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
if sonsLen(it) != 1:
|
if sonsLen(it) != 1:
|
||||||
if i > 0:
|
if i > 0:
|
||||||
|
|
@ -987,7 +987,7 @@ proc genIf(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
|
|
||||||
proc generateHeader(p: PProc, typ: PType): Rope =
|
proc generateHeader(p: PProc, typ: PType): Rope =
|
||||||
result = nil
|
result = nil
|
||||||
for i in countup(1, sonsLen(typ.n) - 1):
|
for i in 1 ..< sonsLen(typ.n):
|
||||||
assert(typ.n.sons[i].kind == nkSym)
|
assert(typ.n.sons[i].kind == nkSym)
|
||||||
var param = typ.n.sons[i].sym
|
var param = typ.n.sons[i].sym
|
||||||
if isCompileTimeOnly(param.typ): continue
|
if isCompileTimeOnly(param.typ): continue
|
||||||
|
|
@ -1000,7 +1000,7 @@ proc generateHeader(p: PProc, typ: PType): Rope =
|
||||||
add(result, "_Idx")
|
add(result, "_Idx")
|
||||||
|
|
||||||
proc countJsParams(typ: PType): int =
|
proc countJsParams(typ: PType): int =
|
||||||
for i in countup(1, sonsLen(typ.n) - 1):
|
for i in 1 ..< sonsLen(typ.n):
|
||||||
assert(typ.n.sons[i].kind == nkSym)
|
assert(typ.n.sons[i].kind == nkSym)
|
||||||
var param = typ.n.sons[i].sym
|
var param = typ.n.sons[i].sym
|
||||||
if isCompileTimeOnly(param.typ): continue
|
if isCompileTimeOnly(param.typ): continue
|
||||||
|
|
@ -1443,7 +1443,7 @@ proc genArgs(p: PProc, n: PNode, r: var TCompRes; start=1) =
|
||||||
assert(sonsLen(typ) == sonsLen(typ.n))
|
assert(sonsLen(typ) == sonsLen(typ.n))
|
||||||
var emitted = start-1
|
var emitted = start-1
|
||||||
|
|
||||||
for i in countup(start, sonsLen(n) - 1):
|
for i in start ..< sonsLen(n):
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
var paramType: PNode = nil
|
var paramType: PNode = nil
|
||||||
if i < sonsLen(typ):
|
if i < sonsLen(typ):
|
||||||
|
|
@ -1562,7 +1562,7 @@ proc genEcho(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
useMagic(p, "toJSStr") # Used in rawEcho
|
useMagic(p, "toJSStr") # Used in rawEcho
|
||||||
useMagic(p, "rawEcho")
|
useMagic(p, "rawEcho")
|
||||||
add(r.res, "rawEcho(")
|
add(r.res, "rawEcho(")
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
if it.typ.isCompileTimeOnly: continue
|
if it.typ.isCompileTimeOnly: continue
|
||||||
if i > 0: add(r.res, ", ")
|
if i > 0: add(r.res, ", ")
|
||||||
|
|
@ -1578,11 +1578,11 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope
|
||||||
proc createRecordVarAux(p: PProc, rec: PNode, excludedFieldIDs: IntSet, output: var Rope) =
|
proc createRecordVarAux(p: PProc, rec: PNode, excludedFieldIDs: IntSet, output: var Rope) =
|
||||||
case rec.kind
|
case rec.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(rec) - 1):
|
for i in 0 ..< sonsLen(rec):
|
||||||
createRecordVarAux(p, rec.sons[i], excludedFieldIDs, output)
|
createRecordVarAux(p, rec.sons[i], excludedFieldIDs, output)
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
createRecordVarAux(p, rec.sons[0], excludedFieldIDs, output)
|
createRecordVarAux(p, rec.sons[0], excludedFieldIDs, output)
|
||||||
for i in countup(1, sonsLen(rec) - 1):
|
for i in 1 ..< sonsLen(rec):
|
||||||
createRecordVarAux(p, lastSon(rec.sons[i]), excludedFieldIDs, output)
|
createRecordVarAux(p, lastSon(rec.sons[i]), excludedFieldIDs, output)
|
||||||
of nkSym:
|
of nkSym:
|
||||||
# Do not produce code for void types
|
# Do not produce code for void types
|
||||||
|
|
@ -1753,7 +1753,7 @@ proc genVarInit(p: PProc, v: PSym, n: PNode) =
|
||||||
lineF(p, "}$n")
|
lineF(p, "}$n")
|
||||||
|
|
||||||
proc genVarStmt(p: PProc, n: PNode) =
|
proc genVarStmt(p: PProc, n: PNode) =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind != nkCommentStmt:
|
if a.kind != nkCommentStmt:
|
||||||
if a.kind == nkVarTuple:
|
if a.kind == nkVarTuple:
|
||||||
|
|
@ -1831,7 +1831,7 @@ proc genToArray(p: PProc; n: PNode; r: var TCompRes) =
|
||||||
r.res = rope("array(")
|
r.res = rope("array(")
|
||||||
let x = skipConv(n[1])
|
let x = skipConv(n[1])
|
||||||
if x.kind == nkBracket:
|
if x.kind == nkBracket:
|
||||||
for i in countup(0, x.len - 1):
|
for i in 0 ..< x.len:
|
||||||
let it = x[i]
|
let it = x[i]
|
||||||
if it.kind in {nkPar, nkTupleConstr} and it.len == 2:
|
if it.kind in {nkPar, nkTupleConstr} and it.len == 2:
|
||||||
if i > 0: r.res.add(", ")
|
if i > 0: r.res.add(", ")
|
||||||
|
|
@ -2070,7 +2070,7 @@ proc genSetConstr(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
useMagic(p, "setConstr")
|
useMagic(p, "setConstr")
|
||||||
r.res = rope("setConstr(")
|
r.res = rope("setConstr(")
|
||||||
r.kind = resExpr
|
r.kind = resExpr
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if i > 0: add(r.res, ", ")
|
if i > 0: add(r.res, ", ")
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.kind == nkRange:
|
if it.kind == nkRange:
|
||||||
|
|
@ -2092,7 +2092,7 @@ proc genArrayConstr(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
var a: TCompRes
|
var a: TCompRes
|
||||||
r.res = rope("[")
|
r.res = rope("[")
|
||||||
r.kind = resExpr
|
r.kind = resExpr
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if i > 0: add(r.res, ", ")
|
if i > 0: add(r.res, ", ")
|
||||||
gen(p, n.sons[i], a)
|
gen(p, n.sons[i], a)
|
||||||
if a.typ == etyBaseIndex:
|
if a.typ == etyBaseIndex:
|
||||||
|
|
@ -2109,7 +2109,7 @@ proc genTupleConstr(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
var a: TCompRes
|
var a: TCompRes
|
||||||
r.res = rope("{")
|
r.res = rope("{")
|
||||||
r.kind = resExpr
|
r.kind = resExpr
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if i > 0: add(r.res, ", ")
|
if i > 0: add(r.res, ", ")
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.kind == nkExprColonExpr: it = it.sons[1]
|
if it.kind == nkExprColonExpr: it = it.sons[1]
|
||||||
|
|
@ -2129,7 +2129,7 @@ proc genObjConstr(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
r.kind = resExpr
|
r.kind = resExpr
|
||||||
var initList : Rope
|
var initList : Rope
|
||||||
var fieldIDs = initIntSet()
|
var fieldIDs = initIntSet()
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
if i > 1: add(initList, ", ")
|
if i > 1: add(initList, ", ")
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
internalAssert p.config, it.kind == nkExprColonExpr
|
internalAssert p.config, it.kind == nkExprColonExpr
|
||||||
|
|
@ -2463,7 +2463,7 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
# this shows the distinction is nice for backends and should be kept
|
# this shows the distinction is nice for backends and should be kept
|
||||||
# in the frontend
|
# in the frontend
|
||||||
let isExpr = not isEmptyType(n.typ)
|
let isExpr = not isEmptyType(n.typ)
|
||||||
for i in countup(0, sonsLen(n) - 1 - isExpr.ord):
|
for i in 0 ..< sonsLen(n) - isExpr.ord:
|
||||||
genStmt(p, n.sons[i])
|
genStmt(p, n.sons[i])
|
||||||
if isExpr:
|
if isExpr:
|
||||||
gen(p, lastSon(n), r)
|
gen(p, lastSon(n), r)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ proc genObjectFields(p: PProc, typ: PType, n: PNode): Rope =
|
||||||
result = genObjectFields(p, typ, n.sons[0])
|
result = genObjectFields(p, typ, n.sons[0])
|
||||||
else:
|
else:
|
||||||
s = nil
|
s = nil
|
||||||
for i in countup(0, length - 1):
|
for i in 0 ..< length:
|
||||||
if i > 0: add(s, ", \L")
|
if i > 0: add(s, ", \L")
|
||||||
add(s, genObjectFields(p, typ, n.sons[i]))
|
add(s, genObjectFields(p, typ, n.sons[i]))
|
||||||
result = ("{kind: 2, len: $1, offset: 0, " &
|
result = ("{kind: 2, len: $1, offset: 0, " &
|
||||||
|
|
@ -41,7 +41,7 @@ proc genObjectFields(p: PProc, typ: PType, n: PNode): Rope =
|
||||||
if (n.sons[0].kind != nkSym): internalError(p.config, n.info, "genObjectFields")
|
if (n.sons[0].kind != nkSym): internalError(p.config, n.info, "genObjectFields")
|
||||||
field = n.sons[0].sym
|
field = n.sons[0].sym
|
||||||
s = genTypeInfo(p, field.typ)
|
s = genTypeInfo(p, field.typ)
|
||||||
for i in countup(1, length - 1):
|
for i in 1 ..< length:
|
||||||
b = n.sons[i] # branch
|
b = n.sons[i] # branch
|
||||||
u = nil
|
u = nil
|
||||||
case b.kind
|
case b.kind
|
||||||
|
|
@ -103,7 +103,7 @@ proc genTupleInfo(p: PProc, typ: PType, name: Rope) =
|
||||||
proc genEnumInfo(p: PProc, typ: PType, name: Rope) =
|
proc genEnumInfo(p: PProc, typ: PType, name: Rope) =
|
||||||
let length = sonsLen(typ.n)
|
let length = sonsLen(typ.n)
|
||||||
var s: Rope = nil
|
var s: Rope = nil
|
||||||
for i in countup(0, length - 1):
|
for i in 0 ..< length:
|
||||||
if (typ.n.sons[i].kind != nkSym): internalError(p.config, typ.n.info, "genEnumInfo")
|
if (typ.n.sons[i].kind != nkSym): internalError(p.config, typ.n.info, "genEnumInfo")
|
||||||
let field = typ.n.sons[i].sym
|
let field = typ.n.sons[i].sym
|
||||||
if i > 0: add(s, ", \L")
|
if i > 0: add(s, ", \L")
|
||||||
|
|
|
||||||
|
|
@ -179,14 +179,14 @@ proc lookupInRecord(n: PNode, id: int): PSym =
|
||||||
result = nil
|
result = nil
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = lookupInRecord(n.sons[i], id)
|
result = lookupInRecord(n.sons[i], id)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
if n.sons[0].kind != nkSym: return
|
if n.sons[0].kind != nkSym: return
|
||||||
result = lookupInRecord(n.sons[0], id)
|
result = lookupInRecord(n.sons[0], id)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
result = lookupInRecord(lastSon(n.sons[i]), id)
|
result = lookupInRecord(lastSon(n.sons[i]), id)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ proc makeCString*(s: string): Rope =
|
||||||
result = nil
|
result = nil
|
||||||
var res = newStringOfCap(int(s.len.toFloat * 1.1) + 1)
|
var res = newStringOfCap(int(s.len.toFloat * 1.1) + 1)
|
||||||
add(res, "\"")
|
add(res, "\"")
|
||||||
for i in countup(0, len(s) - 1):
|
for i in 0 ..< len(s):
|
||||||
if (i + 1) mod MaxLineLength == 0:
|
if (i + 1) mod MaxLineLength == 0:
|
||||||
add(res, "\"\L\"")
|
add(res, "\"\L\"")
|
||||||
toCChar(s[i], res)
|
toCChar(s[i], res)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ proc inSet*(s: PNode, elem: PNode): bool =
|
||||||
if s.kind != nkCurly:
|
if s.kind != nkCurly:
|
||||||
#internalError(s.info, "inSet")
|
#internalError(s.info, "inSet")
|
||||||
return false
|
return false
|
||||||
for i in countup(0, sonsLen(s) - 1):
|
for i in 0 ..< sonsLen(s):
|
||||||
if s.sons[i].kind == nkRange:
|
if s.sons[i].kind == nkRange:
|
||||||
if leValue(s.sons[i].sons[0], elem) and
|
if leValue(s.sons[i].sons[0], elem) and
|
||||||
leValue(elem, s.sons[i].sons[1]):
|
leValue(elem, s.sons[i].sons[1]):
|
||||||
|
|
@ -48,7 +48,7 @@ proc someInSet*(s: PNode, a, b: PNode): bool =
|
||||||
if s.kind != nkCurly:
|
if s.kind != nkCurly:
|
||||||
#internalError(s.info, "SomeInSet")
|
#internalError(s.info, "SomeInSet")
|
||||||
return false
|
return false
|
||||||
for i in countup(0, sonsLen(s) - 1):
|
for i in 0 ..< sonsLen(s):
|
||||||
if s.sons[i].kind == nkRange:
|
if s.sons[i].kind == nkRange:
|
||||||
if leValue(s.sons[i].sons[0], b) and leValue(b, s.sons[i].sons[1]) or
|
if leValue(s.sons[i].sons[0], b) and leValue(b, s.sons[i].sons[1]) or
|
||||||
leValue(s.sons[i].sons[0], a) and leValue(a, s.sons[i].sons[1]):
|
leValue(s.sons[i].sons[0], a) and leValue(a, s.sons[i].sons[1]):
|
||||||
|
|
@ -63,7 +63,7 @@ proc toBitSet*(conf: ConfigRef; s: PNode, b: var TBitSet) =
|
||||||
var first, j: BiggestInt
|
var first, j: BiggestInt
|
||||||
first = firstOrd(conf, s.typ.sons[0])
|
first = firstOrd(conf, s.typ.sons[0])
|
||||||
bitSetInit(b, int(getSize(conf, s.typ)))
|
bitSetInit(b, int(getSize(conf, s.typ)))
|
||||||
for i in countup(0, sonsLen(s) - 1):
|
for i in 0 ..< sonsLen(s):
|
||||||
if s.sons[i].kind == nkRange:
|
if s.sons[i].kind == nkRange:
|
||||||
j = getOrdValue(s.sons[i].sons[0])
|
j = getOrdValue(s.sons[i].sons[0])
|
||||||
while j <= getOrdValue(s.sons[i].sons[1]):
|
while j <= getOrdValue(s.sons[i].sons[1]):
|
||||||
|
|
@ -150,7 +150,7 @@ proc setHasRange*(s: PNode): bool =
|
||||||
assert s.kind == nkCurly
|
assert s.kind == nkCurly
|
||||||
if s.kind != nkCurly:
|
if s.kind != nkCurly:
|
||||||
return false
|
return false
|
||||||
for i in countup(0, sonsLen(s) - 1):
|
for i in 0 ..< sonsLen(s):
|
||||||
if s.sons[i].kind == nkRange:
|
if s.sons[i].kind == nkRange:
|
||||||
return true
|
return true
|
||||||
result = false
|
result = false
|
||||||
|
|
|
||||||
|
|
@ -67,21 +67,21 @@ proc carryPasses*(g: ModuleGraph; nodes: PNode, module: PSym;
|
||||||
|
|
||||||
proc openPasses(g: ModuleGraph; a: var TPassContextArray;
|
proc openPasses(g: ModuleGraph; a: var TPassContextArray;
|
||||||
module: PSym) =
|
module: PSym) =
|
||||||
for i in countup(0, g.passes.len - 1):
|
for i in 0 ..< g.passes.len:
|
||||||
if not isNil(g.passes[i].open):
|
if not isNil(g.passes[i].open):
|
||||||
a[i] = g.passes[i].open(g, module)
|
a[i] = g.passes[i].open(g, module)
|
||||||
else: a[i] = nil
|
else: a[i] = nil
|
||||||
|
|
||||||
proc closePasses(graph: ModuleGraph; a: var TPassContextArray) =
|
proc closePasses(graph: ModuleGraph; a: var TPassContextArray) =
|
||||||
var m: PNode = nil
|
var m: PNode = nil
|
||||||
for i in countup(0, graph.passes.len - 1):
|
for i in 0 ..< graph.passes.len:
|
||||||
if not isNil(graph.passes[i].close): m = graph.passes[i].close(graph, a[i], m)
|
if not isNil(graph.passes[i].close): m = graph.passes[i].close(graph, a[i], m)
|
||||||
a[i] = nil # free the memory here
|
a[i] = nil # free the memory here
|
||||||
|
|
||||||
proc processTopLevelStmt(graph: ModuleGraph, n: PNode, a: var TPassContextArray): bool =
|
proc processTopLevelStmt(graph: ModuleGraph, n: PNode, a: var TPassContextArray): bool =
|
||||||
# this implements the code transformation pipeline
|
# this implements the code transformation pipeline
|
||||||
var m = n
|
var m = n
|
||||||
for i in countup(0, graph.passes.len - 1):
|
for i in 0 ..< graph.passes.len:
|
||||||
if not isNil(graph.passes[i].process):
|
if not isNil(graph.passes[i].process):
|
||||||
m = graph.passes[i].process(a[i], m)
|
m = graph.passes[i].process(a[i], m)
|
||||||
if isNil(m): return false
|
if isNil(m): return false
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ proc sameTrees*(a, b: PNode): bool =
|
||||||
of nkType: result = sameTypeOrNil(a.typ, b.typ)
|
of nkType: result = sameTypeOrNil(a.typ, b.typ)
|
||||||
else:
|
else:
|
||||||
if sonsLen(a) == sonsLen(b):
|
if sonsLen(a) == sonsLen(b):
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
if not sameTrees(a.sons[i], b.sons[i]): return
|
if not sameTrees(a.sons[i], b.sons[i]): return
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ proc matches(c: PPatternContext, p, n: PNode): bool =
|
||||||
arglist = newNodeI(nkArgList, n.info)
|
arglist = newNodeI(nkArgList, n.info)
|
||||||
return bindOrCheck(c, v.sym, arglist)
|
return bindOrCheck(c, v.sym, arglist)
|
||||||
if plen == sonsLen(n):
|
if plen == sonsLen(n):
|
||||||
for i in countup(0, sonsLen(p) - 1):
|
for i in 0 ..< sonsLen(p):
|
||||||
if not matches(c, p.sons[i], n.sons[i]): return
|
if not matches(c, p.sons[i], n.sons[i]): return
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ proc illegalCustomPragma*(c: PContext, n: PNode, s: PSym) =
|
||||||
proc pragmaAsm*(c: PContext, n: PNode): char =
|
proc pragmaAsm*(c: PContext, n: PNode): char =
|
||||||
result = '\0'
|
result = '\0'
|
||||||
if n != nil:
|
if n != nil:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
if it.kind in nkPragmaCallKinds and it.len == 2 and it.sons[0].kind == nkIdent:
|
if it.kind in nkPragmaCallKinds and it.len == 2 and it.sons[0].kind == nkIdent:
|
||||||
case whichKeyword(it.sons[0].ident)
|
case whichKeyword(it.sons[0].ident)
|
||||||
|
|
@ -423,7 +423,7 @@ proc processPush(c: PContext, n: PNode, start: int) =
|
||||||
x.notes = c.config.notes
|
x.notes = c.config.notes
|
||||||
x.features = c.features
|
x.features = c.features
|
||||||
c.optionStack.add(x)
|
c.optionStack.add(x)
|
||||||
for i in countup(start, sonsLen(n) - 1):
|
for i in start ..< sonsLen(n):
|
||||||
if not tryProcessOption(c, n.sons[i], c.config.options):
|
if not tryProcessOption(c, n.sons[i], c.config.options):
|
||||||
# simply store it somewhere:
|
# simply store it somewhere:
|
||||||
if x.otherPragmas.isNil:
|
if x.otherPragmas.isNil:
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import
|
||||||
|
|
||||||
proc equalGenericParams(procA, procB: PNode): bool =
|
proc equalGenericParams(procA, procB: PNode): bool =
|
||||||
if sonsLen(procA) != sonsLen(procB): return false
|
if sonsLen(procA) != sonsLen(procB): return false
|
||||||
for i in countup(0, sonsLen(procA) - 1):
|
for i in 0 ..< sonsLen(procA):
|
||||||
if procA.sons[i].kind != nkSym:
|
if procA.sons[i].kind != nkSym:
|
||||||
return false
|
return false
|
||||||
if procB.sons[i].kind != nkSym:
|
if procB.sons[i].kind != nkSym:
|
||||||
|
|
@ -98,7 +98,7 @@ when false:
|
||||||
var length = sonsLen(child)
|
var length = sonsLen(child)
|
||||||
result = false
|
result = false
|
||||||
if length == sonsLen(parent):
|
if length == sonsLen(parent):
|
||||||
for i in countup(1, length - 1):
|
for i in 1 ..< length:
|
||||||
var m = child.sons[i].sym
|
var m = child.sons[i].sym
|
||||||
var n = parent.sons[i].sym
|
var n = parent.sons[i].sym
|
||||||
assert((m.kind == skParam) and (n.kind == skParam))
|
assert((m.kind == skParam) and (n.kind == skParam))
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ proc putRawStr(g: var TSrcGen, kind: TTokType, s: string) =
|
||||||
put(g, kind, str)
|
put(g, kind, str)
|
||||||
|
|
||||||
proc containsNL(s: string): bool =
|
proc containsNL(s: string): bool =
|
||||||
for i in countup(0, len(s) - 1):
|
for i in 0 ..< len(s):
|
||||||
case s[i]
|
case s[i]
|
||||||
of '\x0D', '\x0A':
|
of '\x0D', '\x0A':
|
||||||
return true
|
return true
|
||||||
|
|
@ -554,7 +554,7 @@ proc hasCom(n: PNode): bool =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkEmpty..nkNilLit: discard
|
of nkEmpty..nkNilLit: discard
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if hasCom(n.sons[i]): return true
|
if hasCom(n.sons[i]): return true
|
||||||
|
|
||||||
proc putWithSpace(g: var TSrcGen, kind: TTokType, s: string) =
|
proc putWithSpace(g: var TSrcGen, kind: TTokType, s: string) =
|
||||||
|
|
@ -606,7 +606,7 @@ proc gsection(g: var TSrcGen, n: PNode, c: TContext, kind: TTokType,
|
||||||
putWithSpace(g, kind, k)
|
putWithSpace(g, kind, k)
|
||||||
gcoms(g)
|
gcoms(g)
|
||||||
indentNL(g)
|
indentNL(g)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
optNL(g)
|
optNL(g)
|
||||||
gsub(g, n.sons[i], c)
|
gsub(g, n.sons[i], c)
|
||||||
gcoms(g)
|
gcoms(g)
|
||||||
|
|
@ -662,7 +662,7 @@ proc gif(g: var TSrcGen, n: PNode) =
|
||||||
gcoms(g) # a good place for comments
|
gcoms(g) # a good place for comments
|
||||||
gstmts(g, n.sons[0].sons[1], c)
|
gstmts(g, n.sons[0].sons[1], c)
|
||||||
var length = sonsLen(n)
|
var length = sonsLen(n)
|
||||||
for i in countup(1, length - 1):
|
for i in 1 ..< length:
|
||||||
optNL(g)
|
optNL(g)
|
||||||
gsub(g, n.sons[i], c)
|
gsub(g, n.sons[i], c)
|
||||||
|
|
||||||
|
|
@ -1043,7 +1043,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||||
of nkClosedSymChoice, nkOpenSymChoice:
|
of nkClosedSymChoice, nkOpenSymChoice:
|
||||||
if renderIds in g.flags:
|
if renderIds in g.flags:
|
||||||
put(g, tkParLe, "(")
|
put(g, tkParLe, "(")
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if i > 0: put(g, tkOpr, "|")
|
if i > 0: put(g, tkOpr, "|")
|
||||||
if n.sons[i].kind == nkSym:
|
if n.sons[i].kind == nkSym:
|
||||||
let s = n[i].sym
|
let s = n[i].sym
|
||||||
|
|
@ -1240,7 +1240,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||||
put(g, tkObject, "object")
|
put(g, tkObject, "object")
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
indentNL(g)
|
indentNL(g)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
optNL(g)
|
optNL(g)
|
||||||
gsub(g, n.sons[i], c)
|
gsub(g, n.sons[i], c)
|
||||||
gcoms(g)
|
gcoms(g)
|
||||||
|
|
@ -1336,7 +1336,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||||
if L > 1:
|
if L > 1:
|
||||||
gcoms(g)
|
gcoms(g)
|
||||||
indentNL(g)
|
indentNL(g)
|
||||||
for i in countup(0, L - 1):
|
for i in 0 ..< L:
|
||||||
optNL(g)
|
optNL(g)
|
||||||
gsub(g, n.sons[i])
|
gsub(g, n.sons[i])
|
||||||
gcoms(g)
|
gcoms(g)
|
||||||
|
|
@ -1538,7 +1538,7 @@ proc renderModule*(n: PNode, infile, outfile: string,
|
||||||
g: TSrcGen
|
g: TSrcGen
|
||||||
initSrcGen(g, renderFlags, conf)
|
initSrcGen(g, renderFlags, conf)
|
||||||
g.fid = fid
|
g.fid = fid
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
gsub(g, n.sons[i])
|
gsub(g, n.sons[i])
|
||||||
optNL(g)
|
optNL(g)
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ proc encodeNode(g: ModuleGraph; fInfo: TLineInfo, n: PNode,
|
||||||
encodeVInt(n.sym.id, result)
|
encodeVInt(n.sym.id, result)
|
||||||
pushSym(w, n.sym)
|
pushSym(w, n.sym)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
encodeNode(g, n.info, n.sons[i], result)
|
encodeNode(g, n.info, n.sons[i], result)
|
||||||
add(result, ')')
|
add(result, ')')
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ proc encodeType(g: ModuleGraph, t: PType, result: var string) =
|
||||||
add(result, '\21')
|
add(result, '\21')
|
||||||
encodeVInt(t.typeInst.uniqueId, result)
|
encodeVInt(t.typeInst.uniqueId, result)
|
||||||
pushType(w, t.typeInst)
|
pushType(w, t.typeInst)
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
if t.sons[i] == nil:
|
if t.sons[i] == nil:
|
||||||
add(result, "^()")
|
add(result, "^()")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ proc toStrMaxPrecision*(f: BiggestFloat, literalPostfix = ""): string =
|
||||||
result = $buf.cstring
|
result = $buf.cstring
|
||||||
|
|
||||||
proc encodeStr*(s: string, result: var string) =
|
proc encodeStr*(s: string, result: var string) =
|
||||||
for i in countup(0, len(s) - 1):
|
for i in 0 ..< len(s):
|
||||||
case s[i]
|
case s[i]
|
||||||
of 'a'..'z', 'A'..'Z', '0'..'9', '_': add(result, s[i])
|
of 'a'..'z', 'A'..'Z', '0'..'9', '_': add(result, s[i])
|
||||||
else: add(result, '\\' & toHex(ord(s[i]), 2))
|
else: add(result, '\\' & toHex(ord(s[i]), 2))
|
||||||
|
|
|
||||||
|
|
@ -492,7 +492,7 @@ proc semConceptBody(c: PContext, n: PNode): PNode
|
||||||
include semtypes, semtempl, semgnrc, semstmts, semexprs
|
include semtypes, semtempl, semgnrc, semstmts, semexprs
|
||||||
|
|
||||||
proc addCodeForGenerics(c: PContext, n: PNode) =
|
proc addCodeForGenerics(c: PContext, n: PNode) =
|
||||||
for i in countup(c.lastGenericIdx, c.generics.len - 1):
|
for i in c.lastGenericIdx ..< c.generics.len:
|
||||||
var prc = c.generics[i].inst.sym
|
var prc = c.generics[i].inst.sym
|
||||||
if prc.kind in {skProc, skFunc, skMethod, skConverter} and prc.magic == mNone:
|
if prc.kind in {skProc, skFunc, skMethod, skConverter} and prc.magic == mNone:
|
||||||
if prc.ast == nil or prc.ast.sons[bodyPos] == nil:
|
if prc.ast == nil or prc.ast.sons[bodyPos] == nil:
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
|
||||||
for err in errors:
|
for err in errors:
|
||||||
var errProto = ""
|
var errProto = ""
|
||||||
let n = err.sym.typ.n
|
let n = err.sym.typ.n
|
||||||
for i in countup(1, n.len - 1):
|
for i in 1 ..< n.len:
|
||||||
var p = n.sons[i]
|
var p = n.sons[i]
|
||||||
if p.kind == nkSym:
|
if p.kind == nkSym:
|
||||||
add(errProto, typeToString(p.sym.typ, preferName))
|
add(errProto, typeToString(p.sym.typ, preferName))
|
||||||
|
|
@ -396,7 +396,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
|
||||||
elif c.config.errorCounter == 0:
|
elif c.config.errorCounter == 0:
|
||||||
# don't cascade errors
|
# don't cascade errors
|
||||||
var args = "("
|
var args = "("
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
if i > 1: add(args, ", ")
|
if i > 1: add(args, ", ")
|
||||||
add(args, typeToString(n.sons[i].typ))
|
add(args, typeToString(n.sons[i].typ))
|
||||||
add(args, ")")
|
add(args, ")")
|
||||||
|
|
@ -613,7 +613,7 @@ proc explicitGenericInstantiation(c: PContext, n: PNode, s: PSym): PNode =
|
||||||
# XXX I think this could be improved by reusing sigmatch.paramTypesMatch.
|
# XXX I think this could be improved by reusing sigmatch.paramTypesMatch.
|
||||||
# It's good enough for now.
|
# It's good enough for now.
|
||||||
result = newNodeI(a.kind, getCallLineInfo(n))
|
result = newNodeI(a.kind, getCallLineInfo(n))
|
||||||
for i in countup(0, len(a)-1):
|
for i in 0 ..< len(a):
|
||||||
var candidate = a.sons[i].sym
|
var candidate = a.sons[i].sym
|
||||||
if candidate.kind in {skProc, skMethod, skConverter,
|
if candidate.kind in {skProc, skMethod, skConverter,
|
||||||
skFunc, skIterator}:
|
skFunc, skIterator}:
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ proc newContext*(graph: ModuleGraph; module: PSym): PContext =
|
||||||
|
|
||||||
proc inclSym(sq: var seq[PSym], s: PSym) =
|
proc inclSym(sq: var seq[PSym], s: PSym) =
|
||||||
var L = len(sq)
|
var L = len(sq)
|
||||||
for i in countup(0, L - 1):
|
for i in 0 ..< L:
|
||||||
if sq[i].id == s.id: return
|
if sq[i].id == s.id: return
|
||||||
setLen(sq, L + 1)
|
setLen(sq, L + 1)
|
||||||
sq[L] = s
|
sq[L] = s
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@ proc semConv(c: PContext, n: PNode): PNode =
|
||||||
localError(c.config, n.info, "illegal conversion from '$1' to '$2'" %
|
localError(c.config, n.info, "illegal conversion from '$1' to '$2'" %
|
||||||
[op.typ.typeToString, result.typ.typeToString])
|
[op.typ.typeToString, result.typ.typeToString])
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(op) - 1):
|
for i in 0 ..< sonsLen(op):
|
||||||
let it = op.sons[i]
|
let it = op.sons[i]
|
||||||
let status = checkConvertible(c, result.typ, it.typ)
|
let status = checkConvertible(c, result.typ, it.typ)
|
||||||
if status in {convOK, convNotNeedeed}:
|
if status in {convOK, convNotNeedeed}:
|
||||||
|
|
@ -428,7 +428,7 @@ proc semIs(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
|
|
||||||
proc semOpAux(c: PContext, n: PNode) =
|
proc semOpAux(c: PContext, n: PNode) =
|
||||||
const flags = {efDetermineType}
|
const flags = {efDetermineType}
|
||||||
for i in countup(1, n.sonsLen-1):
|
for i in 1 ..< n.sonsLen:
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkExprEqExpr and sonsLen(a) == 2:
|
if a.kind == nkExprEqExpr and sonsLen(a) == 2:
|
||||||
let info = a.sons[0].info
|
let info = a.sons[0].info
|
||||||
|
|
@ -446,13 +446,13 @@ proc overloadedCallOpr(c: PContext, n: PNode): PNode =
|
||||||
else:
|
else:
|
||||||
result = newNodeI(nkCall, n.info)
|
result = newNodeI(nkCall, n.info)
|
||||||
addSon(result, newIdentNode(par, n.info))
|
addSon(result, newIdentNode(par, n.info))
|
||||||
for i in countup(0, sonsLen(n) - 1): addSon(result, n.sons[i])
|
for i in 0 ..< sonsLen(n): addSon(result, n.sons[i])
|
||||||
result = semExpr(c, result)
|
result = semExpr(c, result)
|
||||||
|
|
||||||
proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
|
proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkCurly, nkBracket:
|
of nkCurly, nkBracket:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
changeType(c, n.sons[i], elemType(newType), check)
|
changeType(c, n.sons[i], elemType(newType), check)
|
||||||
of nkPar, nkTupleConstr:
|
of nkPar, nkTupleConstr:
|
||||||
let tup = newType.skipTypes({tyGenericInst, tyAlias, tySink, tyDistinct})
|
let tup = newType.skipTypes({tyGenericInst, tyAlias, tySink, tyDistinct})
|
||||||
|
|
@ -461,7 +461,7 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
|
||||||
globalError(c.config, n.info, "no tuple type for constructor")
|
globalError(c.config, n.info, "no tuple type for constructor")
|
||||||
elif sonsLen(n) > 0 and n.sons[0].kind == nkExprColonExpr:
|
elif sonsLen(n) > 0 and n.sons[0].kind == nkExprColonExpr:
|
||||||
# named tuple?
|
# named tuple?
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var m = n.sons[i].sons[0]
|
var m = n.sons[i].sons[0]
|
||||||
if m.kind != nkSym:
|
if m.kind != nkSym:
|
||||||
globalError(c.config, m.info, "invalid tuple constructor")
|
globalError(c.config, m.info, "invalid tuple constructor")
|
||||||
|
|
@ -475,7 +475,7 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
|
||||||
else:
|
else:
|
||||||
changeType(c, n.sons[i].sons[1], tup.sons[i], check)
|
changeType(c, n.sons[i].sons[1], tup.sons[i], check)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
changeType(c, n.sons[i], tup.sons[i], check)
|
changeType(c, n.sons[i], tup.sons[i], check)
|
||||||
when false:
|
when false:
|
||||||
var m = n.sons[i]
|
var m = n.sons[i]
|
||||||
|
|
@ -523,7 +523,7 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
var typ = yy.typ
|
var typ = yy.typ
|
||||||
addSon(result, yy)
|
addSon(result, yy)
|
||||||
#var typ = skipTypes(result.sons[0].typ, {tyGenericInst, tyVar, tyLent, tyOrdinal})
|
#var typ = skipTypes(result.sons[0].typ, {tyGenericInst, tyVar, tyLent, tyOrdinal})
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
x = n.sons[i]
|
x = n.sons[i]
|
||||||
if x.kind == nkExprColonExpr and sonsLen(x) == 2:
|
if x.kind == nkExprColonExpr and sonsLen(x) == 2:
|
||||||
var idx = semConstExpr(c, x.sons[0])
|
var idx = semConstExpr(c, x.sons[0])
|
||||||
|
|
@ -640,7 +640,7 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
||||||
if n.sons[0].kind == nkSym and n.sons[0].sym.magic in FakeVarParams:
|
if n.sons[0].kind == nkSym and n.sons[0].sym.magic in FakeVarParams:
|
||||||
# BUGFIX: check for L-Value still needs to be done for the arguments!
|
# BUGFIX: check for L-Value still needs to be done for the arguments!
|
||||||
# note sometimes this is eval'ed twice so we check for nkHiddenAddr here:
|
# note sometimes this is eval'ed twice so we check for nkHiddenAddr here:
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
if i < sonsLen(t) and t.sons[i] != nil and
|
if i < sonsLen(t) and t.sons[i] != nil and
|
||||||
skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
|
skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
|
||||||
let it = n[i]
|
let it = n[i]
|
||||||
|
|
@ -656,7 +656,7 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
||||||
localError(c.config, n.info, errXStackEscape % renderTree(n[1], {renderNoComments}))
|
localError(c.config, n.info, errXStackEscape % renderTree(n[1], {renderNoComments}))
|
||||||
|
|
||||||
return
|
return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
let n = if n.kind == nkHiddenDeref: n[0] else: n
|
let n = if n.kind == nkHiddenDeref: n[0] else: n
|
||||||
if n.sons[i].kind == nkHiddenCallConv:
|
if n.sons[i].kind == nkHiddenCallConv:
|
||||||
# we need to recurse explicitly here as converters can create nested
|
# we need to recurse explicitly here as converters can create nested
|
||||||
|
|
@ -843,7 +843,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
result = n0
|
result = n0
|
||||||
result.kind = nkCall
|
result.kind = nkCall
|
||||||
result.flags.incl nfExplicitCall
|
result.flags.incl nfExplicitCall
|
||||||
for i in countup(1, sonsLen(n) - 1): addSon(result, n.sons[i])
|
for i in 1 ..< sonsLen(n): addSon(result, n.sons[i])
|
||||||
return semExpr(c, result, flags)
|
return semExpr(c, result, flags)
|
||||||
else:
|
else:
|
||||||
n.sons[0] = n0
|
n.sons[0] = n0
|
||||||
|
|
@ -874,7 +874,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
else:
|
else:
|
||||||
var hasErrorType = false
|
var hasErrorType = false
|
||||||
var msg = "type mismatch: got <"
|
var msg = "type mismatch: got <"
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
if i > 1: add(msg, ", ")
|
if i > 1: add(msg, ", ")
|
||||||
let nt = n.sons[i].typ
|
let nt = n.sons[i].typ
|
||||||
add(msg, typeToString(nt))
|
add(msg, typeToString(nt))
|
||||||
|
|
@ -962,7 +962,7 @@ proc lookupInRecordAndBuildCheck(c: PContext, n, r: PNode, field: PIdent,
|
||||||
result = nil
|
result = nil
|
||||||
case r.kind
|
case r.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(r) - 1):
|
for i in 0 ..< sonsLen(r):
|
||||||
result = lookupInRecordAndBuildCheck(c, n, r.sons[i], field, check)
|
result = lookupInRecordAndBuildCheck(c, n, r.sons[i], field, check)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
|
|
@ -972,7 +972,7 @@ proc lookupInRecordAndBuildCheck(c: PContext, n, r: PNode, field: PIdent,
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
let setType = createSetType(c, r.sons[0].typ)
|
let setType = createSetType(c, r.sons[0].typ)
|
||||||
var s = newNodeIT(nkCurly, r.info, setType)
|
var s = newNodeIT(nkCurly, r.info, setType)
|
||||||
for i in countup(1, sonsLen(r) - 1):
|
for i in 1 ..< sonsLen(r):
|
||||||
var it = r.sons[i]
|
var it = r.sons[i]
|
||||||
case it.kind
|
case it.kind
|
||||||
of nkOfBranch:
|
of nkOfBranch:
|
||||||
|
|
@ -1406,7 +1406,7 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
tyUncheckedArray:
|
tyUncheckedArray:
|
||||||
if n.len != 2: return nil
|
if n.len != 2: return nil
|
||||||
n.sons[0] = makeDeref(n.sons[0])
|
n.sons[0] = makeDeref(n.sons[0])
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
n.sons[i] = semExprWithType(c, n.sons[i],
|
n.sons[i] = semExprWithType(c, n.sons[i],
|
||||||
flags*{efInTypeof, efDetermineType})
|
flags*{efInTypeof, efDetermineType})
|
||||||
# Arrays index type is dictated by the range's type
|
# Arrays index type is dictated by the range's type
|
||||||
|
|
@ -1856,7 +1856,7 @@ proc semExpandToAst(c: PContext, n: PNode): PNode =
|
||||||
onUse(n.info, expandedSym)
|
onUse(n.info, expandedSym)
|
||||||
|
|
||||||
if isCallExpr(macroCall):
|
if isCallExpr(macroCall):
|
||||||
for i in countup(1, macroCall.len-1):
|
for i in 1 ..< macroCall.len:
|
||||||
#if macroCall.sons[0].typ.sons[i].kind != tyExpr:
|
#if macroCall.sons[0].typ.sons[i].kind != tyExpr:
|
||||||
macroCall.sons[i] = semExprWithType(c, macroCall[i], {})
|
macroCall.sons[i] = semExprWithType(c, macroCall[i], {})
|
||||||
# performing overloading resolution here produces too serious regressions:
|
# performing overloading resolution here produces too serious regressions:
|
||||||
|
|
@ -2195,7 +2195,7 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
|
||||||
whenNimvm = exprNode.sym.magic == mNimvm
|
whenNimvm = exprNode.sym.magic == mNimvm
|
||||||
if whenNimvm: n.flags.incl nfLL
|
if whenNimvm: n.flags.incl nfLL
|
||||||
|
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
case it.kind
|
case it.kind
|
||||||
of nkElifBranch, nkElifExpr:
|
of nkElifBranch, nkElifExpr:
|
||||||
|
|
@ -2238,7 +2238,7 @@ proc semSetConstr(c: PContext, n: PNode): PNode =
|
||||||
else:
|
else:
|
||||||
# only semantic checking for all elements, later type checking:
|
# only semantic checking for all elements, later type checking:
|
||||||
var typ: PType = nil
|
var typ: PType = nil
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if isRange(n.sons[i]):
|
if isRange(n.sons[i]):
|
||||||
checkSonsLen(n.sons[i], 3, c.config)
|
checkSonsLen(n.sons[i], 3, c.config)
|
||||||
n.sons[i].sons[1] = semExprWithType(c, n.sons[i].sons[1])
|
n.sons[i].sons[1] = semExprWithType(c, n.sons[i].sons[1])
|
||||||
|
|
@ -2262,7 +2262,7 @@ proc semSetConstr(c: PContext, n: PNode): PNode =
|
||||||
elif lengthOrd(c.config, typ) > MaxSetElements:
|
elif lengthOrd(c.config, typ) > MaxSetElements:
|
||||||
typ = makeRangeType(c, 0, MaxSetElements-1, n.info)
|
typ = makeRangeType(c, 0, MaxSetElements-1, n.info)
|
||||||
addSonSkipIntLit(result.typ, typ)
|
addSonSkipIntLit(result.typ, typ)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var m: PNode
|
var m: PNode
|
||||||
let info = n.sons[i].info
|
let info = n.sons[i].info
|
||||||
if isRange(n.sons[i]):
|
if isRange(n.sons[i]):
|
||||||
|
|
@ -2282,7 +2282,7 @@ proc semTableConstr(c: PContext, n: PNode): PNode =
|
||||||
for i in 0..n.len-1:
|
for i in 0..n.len-1:
|
||||||
var x = n.sons[i]
|
var x = n.sons[i]
|
||||||
if x.kind == nkExprColonExpr and sonsLen(x) == 2:
|
if x.kind == nkExprColonExpr and sonsLen(x) == 2:
|
||||||
for j in countup(lastKey, i-1):
|
for j in lastKey ..< i:
|
||||||
var pair = newNodeI(nkTupleConstr, x.info)
|
var pair = newNodeI(nkTupleConstr, x.info)
|
||||||
pair.add(n.sons[j])
|
pair.add(n.sons[j])
|
||||||
pair.add(x[1])
|
pair.add(x[1])
|
||||||
|
|
@ -2313,7 +2313,7 @@ proc checkPar(c: PContext; n: PNode): TParKind =
|
||||||
else:
|
else:
|
||||||
if n.sons[0].kind == nkExprColonExpr: result = paTupleFields
|
if n.sons[0].kind == nkExprColonExpr: result = paTupleFields
|
||||||
else: result = paTuplePositions
|
else: result = paTuplePositions
|
||||||
for i in countup(0, length - 1):
|
for i in 0 ..< length:
|
||||||
if result == paTupleFields:
|
if result == paTupleFields:
|
||||||
if (n.sons[i].kind != nkExprColonExpr) or
|
if (n.sons[i].kind != nkExprColonExpr) or
|
||||||
not (n.sons[i].sons[0].kind in {nkSym, nkIdent}):
|
not (n.sons[i].sons[0].kind in {nkSym, nkIdent}):
|
||||||
|
|
@ -2329,7 +2329,7 @@ proc semTupleFieldsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
var typ = newTypeS(tyTuple, c)
|
var typ = newTypeS(tyTuple, c)
|
||||||
typ.n = newNodeI(nkRecList, n.info) # nkIdentDefs
|
typ.n = newNodeI(nkRecList, n.info) # nkIdentDefs
|
||||||
var ids = initIntSet()
|
var ids = initIntSet()
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if n[i].kind != nkExprColonExpr or n[i][0].kind notin {nkSym, nkIdent}:
|
if n[i].kind != nkExprColonExpr or n[i][0].kind notin {nkSym, nkIdent}:
|
||||||
illFormedAst(n.sons[i], c.config)
|
illFormedAst(n.sons[i], c.config)
|
||||||
var id: PIdent
|
var id: PIdent
|
||||||
|
|
@ -2352,7 +2352,7 @@ proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
result = n # we don't modify n, but compute the type:
|
result = n # we don't modify n, but compute the type:
|
||||||
result.kind = nkTupleConstr
|
result.kind = nkTupleConstr
|
||||||
var typ = newTypeS(tyTuple, c) # leave typ.n nil!
|
var typ = newTypeS(tyTuple, c) # leave typ.n nil!
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
n.sons[i] = semExprWithType(c, n.sons[i], flags*{efAllowDestructor})
|
n.sons[i] = semExprWithType(c, n.sons[i], flags*{efAllowDestructor})
|
||||||
addSonSkipIntLit(typ, n.sons[i].typ)
|
addSonSkipIntLit(typ, n.sons[i].typ)
|
||||||
result.typ = typ
|
result.typ = typ
|
||||||
|
|
@ -2360,7 +2360,7 @@ proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
proc isTupleType(n: PNode): bool =
|
proc isTupleType(n: PNode): bool =
|
||||||
if n.len == 0:
|
if n.len == 0:
|
||||||
return false # don't interpret () as type
|
return false # don't interpret () as type
|
||||||
for i in countup(0, n.len - 1):
|
for i in 0 ..< n.len:
|
||||||
if n[i].typ == nil or n[i].typ.kind != tyTypeDesc:
|
if n[i].typ == nil or n[i].typ.kind != tyTypeDesc:
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ proc instFieldLoopBody(c: TFieldInstCtx, n: PNode, forLoop: PNode): PNode =
|
||||||
"'continue' not supported in a 'fields' loop")
|
"'continue' not supported in a 'fields' loop")
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
newSons(result, sonsLen(n))
|
newSons(result, sonsLen(n))
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result.sons[i] = instFieldLoopBody(c, n.sons[i], forLoop)
|
result.sons[i] = instFieldLoopBody(c, n.sons[i], forLoop)
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ proc ordinalValToString*(a: PNode; g: ModuleGraph): string =
|
||||||
result = $chr(int(x) and 0xff)
|
result = $chr(int(x) and 0xff)
|
||||||
of tyEnum:
|
of tyEnum:
|
||||||
var n = t.n
|
var n = t.n
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if n.sons[i].kind != nkSym: internalError(g.config, a.info, "ordinalValToString")
|
if n.sons[i].kind != nkSym: internalError(g.config, a.info, "ordinalValToString")
|
||||||
var field = n.sons[i].sym
|
var field = n.sons[i].sym
|
||||||
if field.position == x:
|
if field.position == x:
|
||||||
|
|
@ -356,7 +356,7 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode =
|
||||||
|
|
||||||
proc getConstIfExpr(c: PSym, n: PNode; g: ModuleGraph): PNode =
|
proc getConstIfExpr(c: PSym, n: PNode; g: ModuleGraph): PNode =
|
||||||
result = nil
|
result = nil
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.len == 2:
|
if it.len == 2:
|
||||||
var e = getConstExpr(c, it.sons[0], g)
|
var e = getConstExpr(c, it.sons[0], g)
|
||||||
|
|
@ -512,7 +512,7 @@ proc foldFieldAccess(m: PSym, n: PNode; g: ModuleGraph): PNode =
|
||||||
if x == nil or x.kind notin {nkObjConstr, nkPar, nkTupleConstr}: return
|
if x == nil or x.kind notin {nkObjConstr, nkPar, nkTupleConstr}: return
|
||||||
|
|
||||||
var field = n.sons[1].sym
|
var field = n.sons[1].sym
|
||||||
for i in countup(ord(x.kind == nkObjConstr), sonsLen(x) - 1):
|
for i in ord(x.kind == nkObjConstr) ..< sonsLen(x):
|
||||||
var it = x.sons[i]
|
var it = x.sons[i]
|
||||||
if it.kind != nkExprColonExpr:
|
if it.kind != nkExprColonExpr:
|
||||||
# lookup per index:
|
# lookup per index:
|
||||||
|
|
@ -527,7 +527,7 @@ proc foldFieldAccess(m: PSym, n: PNode; g: ModuleGraph): PNode =
|
||||||
proc foldConStrStr(m: PSym, n: PNode; g: ModuleGraph): PNode =
|
proc foldConStrStr(m: PSym, n: PNode; g: ModuleGraph): PNode =
|
||||||
result = newNodeIT(nkStrLit, n.info, n.typ)
|
result = newNodeIT(nkStrLit, n.info, n.typ)
|
||||||
result.strVal = ""
|
result.strVal = ""
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
let a = getConstExpr(m, n.sons[i], g)
|
let a = getConstExpr(m, n.sons[i], g)
|
||||||
if a == nil: return nil
|
if a == nil: return nil
|
||||||
result.strVal.add(getStrOrChar(a))
|
result.strVal.add(getStrOrChar(a))
|
||||||
|
|
@ -673,7 +673,7 @@ proc getConstExpr(m: PSym, n: PNode; g: ModuleGraph): PNode =
|
||||||
n.sons[0] = a
|
n.sons[0] = a
|
||||||
of nkBracket:
|
of nkBracket:
|
||||||
result = copyTree(n)
|
result = copyTree(n)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = getConstExpr(m, n.sons[i], g)
|
var a = getConstExpr(m, n.sons[i], g)
|
||||||
if a == nil: return nil
|
if a == nil: return nil
|
||||||
result.sons[i] = a
|
result.sons[i] = a
|
||||||
|
|
@ -688,14 +688,14 @@ proc getConstExpr(m: PSym, n: PNode; g: ModuleGraph): PNode =
|
||||||
addSon(result, b)
|
addSon(result, b)
|
||||||
of nkCurly:
|
of nkCurly:
|
||||||
result = copyTree(n)
|
result = copyTree(n)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = getConstExpr(m, n.sons[i], g)
|
var a = getConstExpr(m, n.sons[i], g)
|
||||||
if a == nil: return nil
|
if a == nil: return nil
|
||||||
result.sons[i] = a
|
result.sons[i] = a
|
||||||
incl(result.flags, nfAllConst)
|
incl(result.flags, nfAllConst)
|
||||||
#of nkObjConstr:
|
#of nkObjConstr:
|
||||||
# result = copyTree(n)
|
# result = copyTree(n)
|
||||||
# for i in countup(1, sonsLen(n) - 1):
|
# for i in 1 ..< sonsLen(n):
|
||||||
# var a = getConstExpr(m, n.sons[i].sons[1])
|
# var a = getConstExpr(m, n.sons[i].sons[1])
|
||||||
# if a == nil: return nil
|
# if a == nil: return nil
|
||||||
# result.sons[i].sons[1] = a
|
# result.sons[i].sons[1] = a
|
||||||
|
|
@ -704,12 +704,12 @@ proc getConstExpr(m: PSym, n: PNode; g: ModuleGraph): PNode =
|
||||||
# tuple constructor
|
# tuple constructor
|
||||||
result = copyTree(n)
|
result = copyTree(n)
|
||||||
if (sonsLen(n) > 0) and (n.sons[0].kind == nkExprColonExpr):
|
if (sonsLen(n) > 0) and (n.sons[0].kind == nkExprColonExpr):
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = getConstExpr(m, n.sons[i].sons[1], g)
|
var a = getConstExpr(m, n.sons[i].sons[1], g)
|
||||||
if a == nil: return nil
|
if a == nil: return nil
|
||||||
result.sons[i].sons[1] = a
|
result.sons[i].sons[1] = a
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = getConstExpr(m, n.sons[i], g)
|
var a = getConstExpr(m, n.sons[i], g)
|
||||||
if a == nil: return nil
|
if a == nil: return nil
|
||||||
result.sons[i] = a
|
result.sons[i] = a
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
# in threads.nim: the subtle preprocessing here binds 'globalsSlot' which
|
# in threads.nim: the subtle preprocessing here binds 'globalsSlot' which
|
||||||
# is not exported and yet the generic 'threadProcWrapper' works correctly.
|
# is not exported and yet the generic 'threadProcWrapper' works correctly.
|
||||||
let flags = if mixinContext: flags+{withinMixin} else: flags
|
let flags = if mixinContext: flags+{withinMixin} else: flags
|
||||||
for i in countup(first, sonsLen(result) - 1):
|
for i in first ..< sonsLen(result):
|
||||||
result.sons[i] = semGenericStmt(c, result.sons[i], flags, ctx)
|
result.sons[i] = semGenericStmt(c, result.sons[i], flags, ctx)
|
||||||
of nkCurlyExpr:
|
of nkCurlyExpr:
|
||||||
result = newNodeI(nkCall, n.info)
|
result = newNodeI(nkCall, n.info)
|
||||||
|
|
@ -316,13 +316,13 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
withBracketExpr ctx, a.sons[0]:
|
withBracketExpr ctx, a.sons[0]:
|
||||||
result = semGenericStmt(c, result, flags, ctx)
|
result = semGenericStmt(c, result, flags, ctx)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
|
result.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
|
||||||
of nkIfStmt:
|
of nkIfStmt:
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
n.sons[i] = semGenericStmtScope(c, n.sons[i], flags, ctx)
|
n.sons[i] = semGenericStmtScope(c, n.sons[i], flags, ctx)
|
||||||
of nkWhenStmt:
|
of nkWhenStmt:
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
# bug #8603: conditions of 'when' statements are not
|
# bug #8603: conditions of 'when' statements are not
|
||||||
# in a 'mixin' context:
|
# in a 'mixin' context:
|
||||||
let it = n[i]
|
let it = n[i]
|
||||||
|
|
@ -333,13 +333,13 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
n.sons[i] = semGenericStmt(c, it, flags+{withinMixin}, ctx)
|
n.sons[i] = semGenericStmt(c, it, flags+{withinMixin}, ctx)
|
||||||
of nkWhileStmt:
|
of nkWhileStmt:
|
||||||
openScope(c)
|
openScope(c)
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
n.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
|
n.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
of nkCaseStmt:
|
of nkCaseStmt:
|
||||||
openScope(c)
|
openScope(c)
|
||||||
n.sons[0] = semGenericStmt(c, n.sons[0], flags, ctx)
|
n.sons[0] = semGenericStmt(c, n.sons[0], flags, ctx)
|
||||||
for i in countup(1, sonsLen(n)-1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
checkMinSonsLen(a, 1, c.config)
|
checkMinSonsLen(a, 1, c.config)
|
||||||
var L = sonsLen(a)
|
var L = sonsLen(a)
|
||||||
|
|
@ -372,7 +372,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
of nkTryStmt, nkHiddenTryStmt:
|
of nkTryStmt, nkHiddenTryStmt:
|
||||||
checkMinSonsLen(n, 2, c.config)
|
checkMinSonsLen(n, 2, c.config)
|
||||||
n.sons[0] = semGenericStmtScope(c, n.sons[0], flags, ctx)
|
n.sons[0] = semGenericStmtScope(c, n.sons[0], flags, ctx)
|
||||||
for i in countup(1, sonsLen(n)-1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
checkMinSonsLen(a, 1, c.config)
|
checkMinSonsLen(a, 1, c.config)
|
||||||
var L = sonsLen(a)
|
var L = sonsLen(a)
|
||||||
|
|
@ -387,7 +387,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
|
|
||||||
of nkVarSection, nkLetSection:
|
of nkVarSection, nkLetSection:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
if (a.kind != nkIdentDefs) and (a.kind != nkVarTuple): illFormedAst(a, c.config)
|
if (a.kind != nkIdentDefs) and (a.kind != nkVarTuple): illFormedAst(a, c.config)
|
||||||
|
|
@ -398,7 +398,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
for j in countup(0, L-3):
|
for j in countup(0, L-3):
|
||||||
addTempDecl(c, getIdentNode(c, a.sons[j]), skVar)
|
addTempDecl(c, getIdentNode(c, a.sons[j]), skVar)
|
||||||
of nkGenericParams:
|
of nkGenericParams:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if (a.kind != nkIdentDefs): illFormedAst(a, c.config)
|
if (a.kind != nkIdentDefs): illFormedAst(a, c.config)
|
||||||
checkMinSonsLen(a, 3, c.config)
|
checkMinSonsLen(a, 3, c.config)
|
||||||
|
|
@ -408,7 +408,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
for j in countup(0, L-3):
|
for j in countup(0, L-3):
|
||||||
addTempDecl(c, getIdentNode(c, a.sons[j]), skType)
|
addTempDecl(c, getIdentNode(c, a.sons[j]), skType)
|
||||||
of nkConstSection:
|
of nkConstSection:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
if (a.kind != nkConstDef): illFormedAst(a, c.config)
|
if (a.kind != nkConstDef): illFormedAst(a, c.config)
|
||||||
|
|
@ -417,13 +417,13 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
a.sons[1] = semGenericStmt(c, a.sons[1], flags+{withinTypeDesc}, ctx)
|
a.sons[1] = semGenericStmt(c, a.sons[1], flags+{withinTypeDesc}, ctx)
|
||||||
a.sons[2] = semGenericStmt(c, a.sons[2], flags, ctx)
|
a.sons[2] = semGenericStmt(c, a.sons[2], flags, ctx)
|
||||||
of nkTypeSection:
|
of nkTypeSection:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
if (a.kind != nkTypeDef): illFormedAst(a, c.config)
|
if (a.kind != nkTypeDef): illFormedAst(a, c.config)
|
||||||
checkSonsLen(a, 3, c.config)
|
checkSonsLen(a, 3, c.config)
|
||||||
addTempDecl(c, getIdentNode(c, a.sons[0]), skType)
|
addTempDecl(c, getIdentNode(c, a.sons[0]), skType)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
if (a.kind != nkTypeDef): illFormedAst(a, c.config)
|
if (a.kind != nkTypeDef): illFormedAst(a, c.config)
|
||||||
|
|
@ -439,7 +439,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
if n.sonsLen > 0:
|
if n.sonsLen > 0:
|
||||||
if n.sons[0].kind != nkEmpty:
|
if n.sons[0].kind != nkEmpty:
|
||||||
n.sons[0] = semGenericStmt(c, n.sons[0], flags+{withinTypeDesc}, ctx)
|
n.sons[0] = semGenericStmt(c, n.sons[0], flags+{withinTypeDesc}, ctx)
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var a: PNode
|
var a: PNode
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkEnumFieldDef: a = n.sons[i].sons[0]
|
of nkEnumFieldDef: a = n.sons[i].sons[0]
|
||||||
|
|
@ -452,7 +452,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
checkMinSonsLen(n, 1, c.config)
|
checkMinSonsLen(n, 1, c.config)
|
||||||
if n.sons[0].kind != nkEmpty:
|
if n.sons[0].kind != nkEmpty:
|
||||||
n.sons[0] = semGenericStmt(c, n.sons[0], flags+{withinTypeDesc}, ctx)
|
n.sons[0] = semGenericStmt(c, n.sons[0], flags+{withinTypeDesc}, ctx)
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if (a.kind != nkIdentDefs): illFormedAst(a, c.config)
|
if (a.kind != nkIdentDefs): illFormedAst(a, c.config)
|
||||||
checkMinSonsLen(a, 3, c.config)
|
checkMinSonsLen(a, 3, c.config)
|
||||||
|
|
@ -489,7 +489,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
checkMinSonsLen(n, 2, c.config)
|
checkMinSonsLen(n, 2, c.config)
|
||||||
result.sons[1] = semGenericStmt(c, n.sons[1], flags, ctx)
|
result.sons[1] = semGenericStmt(c, n.sons[1], flags, ctx)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
|
result.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
|
||||||
|
|
||||||
when defined(nimsuggest):
|
when defined(nimsuggest):
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ proc addObjFieldsToLocalScope(c: PContext; n: PNode) =
|
||||||
template rec(n) = addObjFieldsToLocalScope(c, n)
|
template rec(n) = addObjFieldsToLocalScope(c, n)
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, len(n)-1):
|
for i in 0 ..< len(n):
|
||||||
rec n[i]
|
rec n[i]
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
if n.len > 0: rec n.sons[0]
|
if n.len > 0: rec n.sons[0]
|
||||||
for i in countup(1, len(n)-1):
|
for i in 1 ..< len(n):
|
||||||
if n[i].kind in {nkOfBranch, nkElse}: rec lastSon(n[i])
|
if n[i].kind in {nkOfBranch, nkElse}: rec lastSon(n[i])
|
||||||
of nkSym:
|
of nkSym:
|
||||||
let f = n.sym
|
let f = n.sym
|
||||||
|
|
@ -152,7 +152,7 @@ proc instantiateBody(c: PContext, n, params: PNode, result, orig: PSym) =
|
||||||
dec c.inGenericInst
|
dec c.inGenericInst
|
||||||
|
|
||||||
proc fixupInstantiatedSymbols(c: PContext, s: PSym) =
|
proc fixupInstantiatedSymbols(c: PContext, s: PSym) =
|
||||||
for i in countup(0, c.generics.len - 1):
|
for i in 0 ..< c.generics.len:
|
||||||
if c.generics[i].genericSym.id == s.id:
|
if c.generics[i].genericSym.id == s.id:
|
||||||
var oldPrc = c.generics[i].inst.sym
|
var oldPrc = c.generics[i].inst.sym
|
||||||
pushProcCon(c, oldPrc)
|
pushProcCon(c, oldPrc)
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@ proc ithField(n: PNode, field: var int): PSym =
|
||||||
result = nil
|
result = nil
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = ithField(n.sons[i], field)
|
result = ithField(n.sons[i], field)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
if n.sons[0].kind != nkSym: return
|
if n.sons[0].kind != nkSym: return
|
||||||
result = ithField(n.sons[0], field)
|
result = ithField(n.sons[0], field)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
result = ithField(lastSon(n.sons[i]), field)
|
result = ithField(lastSon(n.sons[i]), field)
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,7 @@ proc isForwardedProc(n: PNode): bool =
|
||||||
result = n.kind == nkSym and sfForward in n.sym.flags
|
result = n.kind == nkSym and sfForward in n.sym.flags
|
||||||
|
|
||||||
proc trackPragmaStmt(tracked: PEffects, n: PNode) =
|
proc trackPragmaStmt(tracked: PEffects, n: PNode) =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if whichPragma(it) == wEffects:
|
if whichPragma(it) == wEffects:
|
||||||
# list the computed effects up to here:
|
# list the computed effects up to here:
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ proc semIf(c: PContext, n: PNode; flags: TExprFlags): PNode =
|
||||||
result = n
|
result = n
|
||||||
var typ = commonTypeBegin
|
var typ = commonTypeBegin
|
||||||
var hasElse = false
|
var hasElse = false
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.len == 2:
|
if it.len == 2:
|
||||||
openScope(c)
|
openScope(c)
|
||||||
|
|
@ -356,7 +356,7 @@ proc isDiscardUnderscore(v: PSym): bool =
|
||||||
proc semUsing(c: PContext; n: PNode): PNode =
|
proc semUsing(c: PContext; n: PNode): PNode =
|
||||||
result = c.graph.emptyNode
|
result = c.graph.emptyNode
|
||||||
if not isTopLevel(c): localError(c.config, n.info, errXOnlyAtModuleScope % "using")
|
if not isTopLevel(c): localError(c.config, n.info, errXOnlyAtModuleScope % "using")
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if c.config.cmd == cmdIdeTools: suggestStmt(c, a)
|
if c.config.cmd == cmdIdeTools: suggestStmt(c, a)
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
|
|
@ -430,7 +430,7 @@ proc setVarType(c: PContext; v: PSym, typ: PType) =
|
||||||
proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
var b: PNode
|
var b: PNode
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if c.config.cmd == cmdIdeTools: suggestStmt(c, a)
|
if c.config.cmd == cmdIdeTools: suggestStmt(c, a)
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
|
|
@ -572,7 +572,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
proc semConst(c: PContext, n: PNode): PNode =
|
proc semConst(c: PContext, n: PNode): PNode =
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
inc c.inStaticContext
|
inc c.inStaticContext
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if c.config.cmd == cmdIdeTools: suggestStmt(c, a)
|
if c.config.cmd == cmdIdeTools: suggestStmt(c, a)
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
|
|
@ -879,7 +879,7 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode =
|
||||||
|
|
||||||
localError(c.config, n.info, errSelectorMustBeOfCertainTypes)
|
localError(c.config, n.info, errSelectorMustBeOfCertainTypes)
|
||||||
return
|
return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var x = n.sons[i]
|
var x = n.sons[i]
|
||||||
when defined(nimsuggest):
|
when defined(nimsuggest):
|
||||||
if c.config.ideCmd == ideSug and exactEquals(c.config.m.trackPos, x.info) and caseTyp.kind == tyEnum:
|
if c.config.ideCmd == ideSug and exactEquals(c.config.m.trackPos, x.info) and caseTyp.kind == tyEnum:
|
||||||
|
|
@ -948,7 +948,7 @@ proc semRaise(c: PContext, n: PNode): PNode =
|
||||||
|
|
||||||
proc addGenericParamListToScope(c: PContext, n: PNode) =
|
proc addGenericParamListToScope(c: PContext, n: PNode) =
|
||||||
if n.kind != nkGenericParams: illFormedAst(n, c.config)
|
if n.kind != nkGenericParams: illFormedAst(n, c.config)
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkSym: addDecl(c, a.sym)
|
if a.kind == nkSym: addDecl(c, a.sym)
|
||||||
else: illFormedAst(a, c.config)
|
else: illFormedAst(a, c.config)
|
||||||
|
|
@ -965,7 +965,7 @@ proc typeSectionTypeName(c: PContext; n: PNode): PNode =
|
||||||
proc typeSectionLeftSidePass(c: PContext, n: PNode) =
|
proc typeSectionLeftSidePass(c: PContext, n: PNode) =
|
||||||
# process the symbols on the left side for the whole type section, before
|
# process the symbols on the left side for the whole type section, before
|
||||||
# we even look at the type definitions on the right
|
# we even look at the type definitions on the right
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
when defined(nimsuggest):
|
when defined(nimsuggest):
|
||||||
if c.config.cmd == cmdIdeTools:
|
if c.config.cmd == cmdIdeTools:
|
||||||
|
|
@ -1099,7 +1099,7 @@ proc checkCovariantParamsUsages(c: PContext; genericType: PType) =
|
||||||
discard traverseSubTypes(c, body)
|
discard traverseSubTypes(c, body)
|
||||||
|
|
||||||
proc typeSectionRightSidePass(c: PContext, n: PNode) =
|
proc typeSectionRightSidePass(c: PContext, n: PNode) =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
if a.kind != nkTypeDef: illFormedAst(a, c.config)
|
if a.kind != nkTypeDef: illFormedAst(a, c.config)
|
||||||
|
|
@ -1226,7 +1226,7 @@ proc checkForMetaFields(c: PContext; n: PNode) =
|
||||||
internalAssert c.config, false
|
internalAssert c.config, false
|
||||||
|
|
||||||
proc typeSectionFinalPass(c: PContext, n: PNode) =
|
proc typeSectionFinalPass(c: PContext, n: PNode) =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
let name = typeSectionTypeName(c, a.sons[0])
|
let name = typeSectionTypeName(c, a.sons[0])
|
||||||
|
|
@ -1322,7 +1322,7 @@ proc semParamList(c: PContext, n, genericParams: PNode, s: PSym) =
|
||||||
s.typ = semProcTypeNode(c, n, genericParams, nil, s.kind)
|
s.typ = semProcTypeNode(c, n, genericParams, nil, s.kind)
|
||||||
|
|
||||||
proc addParams(c: PContext, n: PNode, kind: TSymKind) =
|
proc addParams(c: PContext, n: PNode, kind: TSymKind) =
|
||||||
for i in countup(1, sonsLen(n)-1):
|
for i in 1 ..< sonsLen(n):
|
||||||
if n.sons[i].kind == nkSym: addParamOrResult(c, n.sons[i].sym, kind)
|
if n.sons[i].kind == nkSym: addParamOrResult(c, n.sons[i].sym, kind)
|
||||||
else: illFormedAst(n, c.config)
|
else: illFormedAst(n, c.config)
|
||||||
|
|
||||||
|
|
@ -1358,7 +1358,7 @@ proc semProcAnnotation(c: PContext, prc: PNode;
|
||||||
validPragmas: TSpecialWords): PNode =
|
validPragmas: TSpecialWords): PNode =
|
||||||
var n = prc.sons[pragmasPos]
|
var n = prc.sons[pragmasPos]
|
||||||
if n == nil or n.kind == nkEmpty: return
|
if n == nil or n.kind == nkEmpty: return
|
||||||
for i in countup(0, n.len-1):
|
for i in 0 ..< n.len:
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
var key = if it.kind in nkPragmaCallKinds and it.len >= 1: it.sons[0] else: it
|
var key = if it.kind in nkPragmaCallKinds and it.len >= 1: it.sons[0] else: it
|
||||||
|
|
||||||
|
|
@ -1665,7 +1665,7 @@ type
|
||||||
|
|
||||||
proc hasObjParam(s: PSym): bool =
|
proc hasObjParam(s: PSym): bool =
|
||||||
var t = s.typ
|
var t = s.typ
|
||||||
for col in countup(1, sonsLen(t)-1):
|
for col in 1 ..< sonsLen(t):
|
||||||
if skipTypes(t.sons[col], skipPtrs).kind == tyObject:
|
if skipTypes(t.sons[col], skipPtrs).kind == tyObject:
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
@ -1679,7 +1679,7 @@ proc semMethodPrototype(c: PContext; s: PSym; n: PNode) =
|
||||||
var foundObj = false
|
var foundObj = false
|
||||||
# we start at 1 for now so that tparsecombnum continues to compile.
|
# we start at 1 for now so that tparsecombnum continues to compile.
|
||||||
# XXX Revisit this problem later.
|
# XXX Revisit this problem later.
|
||||||
for col in countup(1, sonsLen(tt)-1):
|
for col in 1 ..< sonsLen(tt):
|
||||||
let t = tt.sons[col]
|
let t = tt.sons[col]
|
||||||
if t != nil and t.kind == tyGenericInvocation:
|
if t != nil and t.kind == tyGenericInvocation:
|
||||||
var x = skipTypes(t.sons[0], {tyVar, tyLent, tyPtr, tyRef, tyGenericInst,
|
var x = skipTypes(t.sons[0], {tyVar, tyLent, tyPtr, tyRef, tyGenericInst,
|
||||||
|
|
@ -2006,7 +2006,7 @@ proc incMod(c: PContext, n: PNode, it: PNode, includeStmtResult: PNode) =
|
||||||
proc evalInclude(c: PContext, n: PNode): PNode =
|
proc evalInclude(c: PContext, n: PNode): PNode =
|
||||||
result = newNodeI(nkStmtList, n.info)
|
result = newNodeI(nkStmtList, n.info)
|
||||||
addSon(result, n)
|
addSon(result, n)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var imp: PNode
|
var imp: PNode
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket:
|
if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket:
|
||||||
|
|
@ -2095,7 +2095,7 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
#while last > 0 and n.sons[last].kind in {nkPragma, nkCommentStmt,
|
#while last > 0 and n.sons[last].kind in {nkPragma, nkCommentStmt,
|
||||||
# nkNilLit, nkEmpty}:
|
# nkNilLit, nkEmpty}:
|
||||||
# dec last
|
# dec last
|
||||||
for i in countup(0, length - 1):
|
for i in 0 ..< length:
|
||||||
var expr = semExpr(c, n.sons[i], flags)
|
var expr = semExpr(c, n.sons[i], flags)
|
||||||
n.sons[i] = expr
|
n.sons[i] = expr
|
||||||
if c.matchedConcept != nil and expr.typ != nil and
|
if c.matchedConcept != nil and expr.typ != nil and
|
||||||
|
|
@ -2131,7 +2131,7 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
if n.sons[i].kind in LastBlockStmts or
|
if n.sons[i].kind in LastBlockStmts or
|
||||||
n.sons[i].kind in nkCallKinds and n.sons[i][0].kind == nkSym and
|
n.sons[i].kind in nkCallKinds and n.sons[i][0].kind == nkSym and
|
||||||
sfNoReturn in n.sons[i][0].sym.flags:
|
sfNoReturn in n.sons[i][0].sym.flags:
|
||||||
for j in countup(i + 1, length - 1):
|
for j in i + 1 ..< length:
|
||||||
case n.sons[j].kind
|
case n.sons[j].kind
|
||||||
of nkPragma, nkCommentStmt, nkNilLit, nkEmpty, nkBlockExpr,
|
of nkPragma, nkCommentStmt, nkNilLit, nkEmpty, nkBlockExpr,
|
||||||
nkBlockStmt, nkState: discard
|
nkBlockStmt, nkState: discard
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ type
|
||||||
spNone, spGenSym, spInject
|
spNone, spGenSym, spInject
|
||||||
|
|
||||||
proc symBinding(n: PNode): TSymBinding =
|
proc symBinding(n: PNode): TSymBinding =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
var key = if it.kind == nkExprColonExpr: it.sons[0] else: it
|
var key = if it.kind == nkExprColonExpr: it.sons[0] else: it
|
||||||
if key.kind == nkIdent:
|
if key.kind == nkIdent:
|
||||||
|
|
@ -251,7 +251,7 @@ proc semRoutineInTemplName(c: var TemplCtx, n: PNode): PNode =
|
||||||
result = newSymNode(s, n.info)
|
result = newSymNode(s, n.info)
|
||||||
onUse(n.info, s)
|
onUse(n.info, s)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, safeLen(n) - 1):
|
for i in 0 ..< safeLen(n):
|
||||||
result.sons[i] = semRoutineInTemplName(c, n.sons[i])
|
result.sons[i] = semRoutineInTemplName(c, n.sons[i])
|
||||||
|
|
||||||
proc semRoutineInTemplBody(c: var TemplCtx, n: PNode, k: TSymKind): PNode =
|
proc semRoutineInTemplBody(c: var TemplCtx, n: PNode, k: TSymKind): PNode =
|
||||||
|
|
@ -286,7 +286,7 @@ proc semRoutineInTemplBody(c: var TemplCtx, n: PNode, k: TSymKind): PNode =
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
|
|
||||||
proc semTemplSomeDecl(c: var TemplCtx, n: PNode, symKind: TSymKind; start=0) =
|
proc semTemplSomeDecl(c: var TemplCtx, n: PNode, symKind: TSymKind; start=0) =
|
||||||
for i in countup(start, sonsLen(n) - 1):
|
for i in start ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
if (a.kind != nkIdentDefs) and (a.kind != nkVarTuple): illFormedAst(a, c.c.config)
|
if (a.kind != nkIdentDefs) and (a.kind != nkVarTuple): illFormedAst(a, c.c.config)
|
||||||
|
|
@ -342,7 +342,7 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
of nkEmpty, nkSym..nkNilLit, nkComesFrom:
|
of nkEmpty, nkSym..nkNilLit, nkComesFrom:
|
||||||
discard
|
discard
|
||||||
of nkIfStmt:
|
of nkIfStmt:
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.len == 2:
|
if it.len == 2:
|
||||||
openScope(c)
|
openScope(c)
|
||||||
|
|
@ -353,13 +353,13 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
n.sons[i] = semTemplBodyScope(c, it)
|
n.sons[i] = semTemplBodyScope(c, it)
|
||||||
of nkWhileStmt:
|
of nkWhileStmt:
|
||||||
openScope(c)
|
openScope(c)
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
n.sons[i] = semTemplBody(c, n.sons[i])
|
n.sons[i] = semTemplBody(c, n.sons[i])
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
of nkCaseStmt:
|
of nkCaseStmt:
|
||||||
openScope(c)
|
openScope(c)
|
||||||
n.sons[0] = semTemplBody(c, n.sons[0])
|
n.sons[0] = semTemplBody(c, n.sons[0])
|
||||||
for i in countup(1, sonsLen(n)-1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
checkMinSonsLen(a, 1, c.c.config)
|
checkMinSonsLen(a, 1, c.c.config)
|
||||||
var L = sonsLen(a)
|
var L = sonsLen(a)
|
||||||
|
|
@ -398,7 +398,7 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
of nkTryStmt, nkHiddenTryStmt:
|
of nkTryStmt, nkHiddenTryStmt:
|
||||||
checkMinSonsLen(n, 2, c.c.config)
|
checkMinSonsLen(n, 2, c.c.config)
|
||||||
n.sons[0] = semTemplBodyScope(c, n.sons[0])
|
n.sons[0] = semTemplBodyScope(c, n.sons[0])
|
||||||
for i in countup(1, sonsLen(n)-1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
checkMinSonsLen(a, 1, c.c.config)
|
checkMinSonsLen(a, 1, c.c.config)
|
||||||
var L = sonsLen(a)
|
var L = sonsLen(a)
|
||||||
|
|
@ -418,7 +418,7 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
n.sons[0] = semTemplBody(c, n.sons[0])
|
n.sons[0] = semTemplBody(c, n.sons[0])
|
||||||
semTemplSomeDecl(c, n, skParam, 1)
|
semTemplSomeDecl(c, n, skParam, 1)
|
||||||
of nkConstSection:
|
of nkConstSection:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
if (a.kind != nkConstDef): illFormedAst(a, c.c.config)
|
if (a.kind != nkConstDef): illFormedAst(a, c.c.config)
|
||||||
|
|
@ -427,13 +427,13 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
a.sons[1] = semTemplBody(c, a.sons[1])
|
a.sons[1] = semTemplBody(c, a.sons[1])
|
||||||
a.sons[2] = semTemplBody(c, a.sons[2])
|
a.sons[2] = semTemplBody(c, a.sons[2])
|
||||||
of nkTypeSection:
|
of nkTypeSection:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
if (a.kind != nkTypeDef): illFormedAst(a, c.c.config)
|
if (a.kind != nkTypeDef): illFormedAst(a, c.c.config)
|
||||||
checkSonsLen(a, 3, c.c.config)
|
checkSonsLen(a, 3, c.c.config)
|
||||||
addLocalDecl(c, a.sons[0], skType)
|
addLocalDecl(c, a.sons[0], skType)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind == nkCommentStmt: continue
|
if a.kind == nkCommentStmt: continue
|
||||||
if (a.kind != nkTypeDef): illFormedAst(a, c.c.config)
|
if (a.kind != nkTypeDef): illFormedAst(a, c.c.config)
|
||||||
|
|
@ -552,7 +552,7 @@ proc semTemplBodyDirty(c: var TemplCtx, n: PNode): PNode =
|
||||||
if s != nil and contains(c.toBind, s.id):
|
if s != nil and contains(c.toBind, s.id):
|
||||||
return symChoice(c.c, n, s, scClosed)
|
return symChoice(c.c, n, s, scClosed)
|
||||||
result = n
|
result = n
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result.sons[i] = semTemplBodyDirty(c, n.sons[i])
|
result.sons[i] = semTemplBodyDirty(c, n.sons[i])
|
||||||
|
|
||||||
proc semTemplateDef(c: PContext, n: PNode): PNode =
|
proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||||
|
|
@ -714,7 +714,7 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
if stupidStmtListExpr(n):
|
if stupidStmtListExpr(n):
|
||||||
result = semPatternBody(c, n.lastSon)
|
result = semPatternBody(c, n.lastSon)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result.sons[i] = semPatternBody(c, n.sons[i])
|
result.sons[i] = semPatternBody(c, n.sons[i])
|
||||||
of nkCallKinds:
|
of nkCallKinds:
|
||||||
let s = qualifiedLookUp(c.c, n.sons[0], {})
|
let s = qualifiedLookUp(c.c, n.sons[0], {})
|
||||||
|
|
@ -747,7 +747,7 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
result.sons[1] = semPatternBody(c, n.sons[1])
|
result.sons[1] = semPatternBody(c, n.sons[1])
|
||||||
return
|
return
|
||||||
|
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result.sons[i] = semPatternBody(c, n.sons[i])
|
result.sons[i] = semPatternBody(c, n.sons[i])
|
||||||
else:
|
else:
|
||||||
# dotExpr is ambiguous: note that we explicitly allow 'x.TemplateParam',
|
# dotExpr is ambiguous: note that we explicitly allow 'x.TemplateParam',
|
||||||
|
|
@ -763,7 +763,7 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
of nkPar:
|
of nkPar:
|
||||||
if n.len == 1: return semPatternBody(c, n.sons[0])
|
if n.len == 1: return semPatternBody(c, n.sons[0])
|
||||||
else: discard
|
else: discard
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result.sons[i] = semPatternBody(c, n.sons[i])
|
result.sons[i] = semPatternBody(c, n.sons[i])
|
||||||
|
|
||||||
proc semPattern(c: PContext, n: PNode): PNode =
|
proc semPattern(c: PContext, n: PNode): PNode =
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
|
||||||
var symbols: TStrTable
|
var symbols: TStrTable
|
||||||
if isPure: initStrTable(symbols)
|
if isPure: initStrTable(symbols)
|
||||||
var hasNull = false
|
var hasNull = false
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
if n.sons[i].kind == nkEmpty: continue
|
if n.sons[i].kind == nkEmpty: continue
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkEnumFieldDef:
|
of nkEnumFieldDef:
|
||||||
|
|
@ -419,7 +419,7 @@ proc semTuple(c: PContext, n: PNode, prev: PType): PType =
|
||||||
result.n = newNodeI(nkRecList, n.info)
|
result.n = newNodeI(nkRecList, n.info)
|
||||||
var check = initIntSet()
|
var check = initIntSet()
|
||||||
var counter = 0
|
var counter = 0
|
||||||
for i in countup(ord(n.kind == nkBracketExpr), sonsLen(n) - 1):
|
for i in ord(n.kind == nkBracketExpr) ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if (a.kind != nkIdentDefs): illFormedAst(a, c.config)
|
if (a.kind != nkIdentDefs): illFormedAst(a, c.config)
|
||||||
checkMinSonsLen(a, 3, c.config)
|
checkMinSonsLen(a, 3, c.config)
|
||||||
|
|
@ -613,7 +613,7 @@ proc semRecordCase(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
else:
|
else:
|
||||||
if not isOrdinalType(typ):
|
if not isOrdinalType(typ):
|
||||||
localError(c.config, n.info, "selector must be of an ordinal type, float or string")
|
localError(c.config, n.info, "selector must be of an ordinal type, float or string")
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var b = copyTree(n.sons[i])
|
var b = copyTree(n.sons[i])
|
||||||
addSon(a, b)
|
addSon(a, b)
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
|
|
@ -642,7 +642,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecWhen:
|
of nkRecWhen:
|
||||||
var branch: PNode = nil # the branch to take
|
var branch: PNode = nil # the branch to take
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it == nil: illFormedAst(n, c.config)
|
if it == nil: illFormedAst(n, c.config)
|
||||||
var idx = 1
|
var idx = 1
|
||||||
|
|
@ -679,7 +679,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
# attempt to keep the nesting at a sane level:
|
# attempt to keep the nesting at a sane level:
|
||||||
var a = if father.kind == nkRecList: father else: copyNode(n)
|
var a = if father.kind == nkRecList: father else: copyNode(n)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
semRecordNodeAux(c, n.sons[i], check, pos, a, rectype)
|
semRecordNodeAux(c, n.sons[i], check, pos, a, rectype)
|
||||||
if a != father: addSon(father, a)
|
if a != father: addSon(father, a)
|
||||||
of nkIdentDefs:
|
of nkIdentDefs:
|
||||||
|
|
@ -733,13 +733,13 @@ proc addInheritedFieldsAux(c: PContext, check: var IntSet, pos: var int,
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
if (n.sons[0].kind != nkSym): internalError(c.config, n.info, "addInheritedFieldsAux")
|
if (n.sons[0].kind != nkSym): internalError(c.config, n.info, "addInheritedFieldsAux")
|
||||||
addInheritedFieldsAux(c, check, pos, n.sons[0])
|
addInheritedFieldsAux(c, check, pos, n.sons[0])
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
addInheritedFieldsAux(c, check, pos, lastSon(n.sons[i]))
|
addInheritedFieldsAux(c, check, pos, lastSon(n.sons[i]))
|
||||||
else: internalError(c.config, n.info, "addInheritedFieldsAux(record case branch)")
|
else: internalError(c.config, n.info, "addInheritedFieldsAux(record case branch)")
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
addInheritedFieldsAux(c, check, pos, n.sons[i])
|
addInheritedFieldsAux(c, check, pos, n.sons[i])
|
||||||
of nkSym:
|
of nkSym:
|
||||||
incl(check, n.sym.name.id)
|
incl(check, n.sym.name.id)
|
||||||
|
|
@ -894,7 +894,7 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
|
||||||
let finalTypId = if typId != nil: typId
|
let finalTypId = if typId != nil: typId
|
||||||
else: getIdent(c.cache, paramName & ":type")
|
else: getIdent(c.cache, paramName & ":type")
|
||||||
# is this a bindOnce type class already present in the param list?
|
# is this a bindOnce type class already present in the param list?
|
||||||
for i in countup(0, genericParams.len - 1):
|
for i in 0 ..< genericParams.len:
|
||||||
if genericParams.sons[i].sym.name.id == finalTypId.id:
|
if genericParams.sons[i].sym.name.id == finalTypId.id:
|
||||||
return genericParams.sons[i].typ
|
return genericParams.sons[i].typ
|
||||||
|
|
||||||
|
|
@ -1086,7 +1086,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
||||||
var check = initIntSet()
|
var check = initIntSet()
|
||||||
var counter = 0
|
var counter = 0
|
||||||
|
|
||||||
for i in countup(1, n.len - 1):
|
for i in 1 ..< n.len:
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind != nkIdentDefs:
|
if a.kind != nkIdentDefs:
|
||||||
# for some generic instantiations the passed ':env' parameter
|
# for some generic instantiations the passed ':env' parameter
|
||||||
|
|
@ -1301,7 +1301,7 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
|
||||||
else: addSonSkipIntLit(result, typ)
|
else: addSonSkipIntLit(result, typ)
|
||||||
|
|
||||||
if t.kind == tyForward:
|
if t.kind == tyForward:
|
||||||
for i in countup(1, sonsLen(n)-1):
|
for i in 1 ..< sonsLen(n):
|
||||||
var elem = semGenericParamInInvocation(c, n.sons[i])
|
var elem = semGenericParamInInvocation(c, n.sons[i])
|
||||||
addToResult(elem)
|
addToResult(elem)
|
||||||
return
|
return
|
||||||
|
|
@ -1640,7 +1640,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||||
result = semTypeNode(c, n.sons[0], nil)
|
result = semTypeNode(c, n.sons[0], nil)
|
||||||
if result != nil:
|
if result != nil:
|
||||||
result = copyType(result, getCurrOwner(c), false)
|
result = copyType(result, getCurrOwner(c), false)
|
||||||
for i in countup(1, n.len - 1):
|
for i in 1 ..< n.len:
|
||||||
result.rawAddSon(semTypeNode(c, n.sons[i], nil))
|
result.rawAddSon(semTypeNode(c, n.sons[i], nil))
|
||||||
of mDistinct:
|
of mDistinct:
|
||||||
result = newOrPrevType(tyDistinct, prev, c)
|
result = newOrPrevType(tyDistinct, prev, c)
|
||||||
|
|
@ -1881,7 +1881,7 @@ proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode =
|
||||||
if n.kind != nkGenericParams:
|
if n.kind != nkGenericParams:
|
||||||
illFormedAst(n, c.config)
|
illFormedAst(n, c.config)
|
||||||
return
|
return
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind != nkIdentDefs: illFormedAst(n, c.config)
|
if a.kind != nkIdentDefs: illFormedAst(n, c.config)
|
||||||
let L = a.len
|
let L = a.len
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ proc replaceObjBranches(cl: TReplTypeVars, n: PNode): PNode =
|
||||||
discard
|
discard
|
||||||
of nkRecWhen:
|
of nkRecWhen:
|
||||||
var branch: PNode = nil # the branch to take
|
var branch: PNode = nil # the branch to take
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it == nil: illFormedAst(n, cl.c.config)
|
if it == nil: illFormedAst(n, cl.c.config)
|
||||||
case it.kind
|
case it.kind
|
||||||
|
|
@ -208,7 +208,7 @@ proc replaceTypeVarsN(cl: var TReplTypeVars, n: PNode; start=0): PNode =
|
||||||
result = newNode(nkRecList, n.info)
|
result = newNode(nkRecList, n.info)
|
||||||
of nkRecWhen:
|
of nkRecWhen:
|
||||||
var branch: PNode = nil # the branch to take
|
var branch: PNode = nil # the branch to take
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it == nil: illFormedAst(n, cl.c.config)
|
if it == nil: illFormedAst(n, cl.c.config)
|
||||||
case it.kind
|
case it.kind
|
||||||
|
|
@ -238,7 +238,7 @@ proc replaceTypeVarsN(cl: var TReplTypeVars, n: PNode; start=0): PNode =
|
||||||
newSons(result, length)
|
newSons(result, length)
|
||||||
if start > 0:
|
if start > 0:
|
||||||
result.sons[0] = n.sons[0]
|
result.sons[0] = n.sons[0]
|
||||||
for i in countup(start, length - 1):
|
for i in start ..< length:
|
||||||
result.sons[i] = replaceTypeVarsN(cl, n.sons[i])
|
result.sons[i] = replaceTypeVarsN(cl, n.sons[i])
|
||||||
|
|
||||||
proc replaceTypeVarsS(cl: var TReplTypeVars, s: PSym): PSym =
|
proc replaceTypeVarsS(cl: var TReplTypeVars, s: PSym): PSym =
|
||||||
|
|
@ -310,7 +310,7 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
when defined(reportCacheHits):
|
when defined(reportCacheHits):
|
||||||
echo "Generic instantiation cached ", typeToString(result), " for ", typeToString(t)
|
echo "Generic instantiation cached ", typeToString(result), " for ", typeToString(t)
|
||||||
return
|
return
|
||||||
for i in countup(1, sonsLen(t) - 1):
|
for i in 1 ..< sonsLen(t):
|
||||||
var x = t.sons[i]
|
var x = t.sons[i]
|
||||||
if x.kind in {tyGenericParam}:
|
if x.kind in {tyGenericParam}:
|
||||||
x = lookupTypeVar(cl, x)
|
x = lookupTypeVar(cl, x)
|
||||||
|
|
@ -350,14 +350,14 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
var typeMapLayer = newTypeMapLayer(cl)
|
var typeMapLayer = newTypeMapLayer(cl)
|
||||||
cl.typeMap = addr(typeMapLayer)
|
cl.typeMap = addr(typeMapLayer)
|
||||||
|
|
||||||
for i in countup(1, sonsLen(t) - 1):
|
for i in 1 ..< sonsLen(t):
|
||||||
var x = replaceTypeVarsT(cl, t.sons[i])
|
var x = replaceTypeVarsT(cl, t.sons[i])
|
||||||
assert x.kind != tyGenericInvocation
|
assert x.kind != tyGenericInvocation
|
||||||
header.sons[i] = x
|
header.sons[i] = x
|
||||||
propagateToOwner(header, x)
|
propagateToOwner(header, x)
|
||||||
cl.typeMap.put(body.sons[i-1], x)
|
cl.typeMap.put(body.sons[i-1], x)
|
||||||
|
|
||||||
for i in countup(1, sonsLen(t) - 1):
|
for i in 1 ..< sonsLen(t):
|
||||||
# if one of the params is not concrete, we cannot do anything
|
# if one of the params is not concrete, we cannot do anything
|
||||||
# but we already raised an error!
|
# but we already raised an error!
|
||||||
rawAddSon(result, header.sons[i])
|
rawAddSon(result, header.sons[i])
|
||||||
|
|
@ -562,7 +562,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
||||||
#if not cl.allowMetaTypes:
|
#if not cl.allowMetaTypes:
|
||||||
idTablePut(cl.localCache, t, result)
|
idTablePut(cl.localCache, t, result)
|
||||||
|
|
||||||
for i in countup(0, sonsLen(result) - 1):
|
for i in 0 ..< sonsLen(result):
|
||||||
if result.sons[i] != nil:
|
if result.sons[i] != nil:
|
||||||
if result.sons[i].kind == tyGenericBody:
|
if result.sons[i].kind == tyGenericBody:
|
||||||
localError(cl.c.config, t.sym.info,
|
localError(cl.c.config, t.sym.info,
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
||||||
|
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyGenericInvocation:
|
of tyGenericInvocation:
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
c.hashType t.sons[i], flags
|
c.hashType t.sons[i], flags
|
||||||
of tyDistinct:
|
of tyDistinct:
|
||||||
if CoDistinct in flags:
|
if CoDistinct in flags:
|
||||||
|
|
@ -183,14 +183,14 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
||||||
c &= char(t.kind)
|
c &= char(t.kind)
|
||||||
if t.n != nil and CoType notin flags:
|
if t.n != nil and CoType notin flags:
|
||||||
assert(sonsLen(t.n) == sonsLen(t))
|
assert(sonsLen(t.n) == sonsLen(t))
|
||||||
for i in countup(0, sonsLen(t.n) - 1):
|
for i in 0 ..< sonsLen(t.n):
|
||||||
assert(t.n.sons[i].kind == nkSym)
|
assert(t.n.sons[i].kind == nkSym)
|
||||||
c &= t.n.sons[i].sym.name.s
|
c &= t.n.sons[i].sym.name.s
|
||||||
c &= ':'
|
c &= ':'
|
||||||
c.hashType(t.sons[i], flags+{CoIgnoreRange})
|
c.hashType(t.sons[i], flags+{CoIgnoreRange})
|
||||||
c &= ','
|
c &= ','
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(t) - 1): c.hashType t.sons[i], flags+{CoIgnoreRange}
|
for i in 0 ..< sonsLen(t): c.hashType t.sons[i], flags+{CoIgnoreRange}
|
||||||
of tyRange:
|
of tyRange:
|
||||||
if CoIgnoreRange notin flags:
|
if CoIgnoreRange notin flags:
|
||||||
c &= char(t.kind)
|
c &= char(t.kind)
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ proc argTypeToString(arg: PNode; prefer: TPreferedDesc): string =
|
||||||
proc describeArgs*(c: PContext, n: PNode, startIdx = 1;
|
proc describeArgs*(c: PContext, n: PNode, startIdx = 1;
|
||||||
prefer: TPreferedDesc = preferName): string =
|
prefer: TPreferedDesc = preferName): string =
|
||||||
result = ""
|
result = ""
|
||||||
for i in countup(startIdx, n.len - 1):
|
for i in startIdx ..< n.len:
|
||||||
var arg = n.sons[i]
|
var arg = n.sons[i]
|
||||||
if n.sons[i].kind == nkExprEqExpr:
|
if n.sons[i].kind == nkExprEqExpr:
|
||||||
add(result, renderTree(n.sons[i].sons[0]))
|
add(result, renderTree(n.sons[i].sons[0]))
|
||||||
|
|
@ -435,7 +435,7 @@ proc handleFloatRange(f, a: PType): TTypeRelation =
|
||||||
proc genericParamPut(c: var TCandidate; last, fGenericOrigin: PType) =
|
proc genericParamPut(c: var TCandidate; last, fGenericOrigin: PType) =
|
||||||
if fGenericOrigin != nil and last.kind == tyGenericInst and
|
if fGenericOrigin != nil and last.kind == tyGenericInst and
|
||||||
last.len-1 == fGenericOrigin.len:
|
last.len-1 == fGenericOrigin.len:
|
||||||
for i in countup(1, sonsLen(fGenericOrigin) - 1):
|
for i in 1 ..< sonsLen(fGenericOrigin):
|
||||||
let x = PType(idTableGet(c.bindings, fGenericOrigin.sons[i]))
|
let x = PType(idTableGet(c.bindings, fGenericOrigin.sons[i]))
|
||||||
if x == nil:
|
if x == nil:
|
||||||
put(c, fGenericOrigin.sons[i], last.sons[i])
|
put(c, fGenericOrigin.sons[i], last.sons[i])
|
||||||
|
|
@ -517,12 +517,12 @@ proc recordRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||||
result = isEqual
|
result = isEqual
|
||||||
let firstField = if f.kind == tyTuple: 0
|
let firstField = if f.kind == tyTuple: 0
|
||||||
else: 1
|
else: 1
|
||||||
for i in countup(firstField, sonsLen(f) - 1):
|
for i in firstField ..< sonsLen(f):
|
||||||
var m = typeRel(c, f.sons[i], a.sons[i])
|
var m = typeRel(c, f.sons[i], a.sons[i])
|
||||||
if m < isSubtype: return isNone
|
if m < isSubtype: return isNone
|
||||||
result = minRel(result, m)
|
result = minRel(result, m)
|
||||||
if f.n != nil and a.n != nil:
|
if f.n != nil and a.n != nil:
|
||||||
for i in countup(0, sonsLen(f.n) - 1):
|
for i in 0 ..< sonsLen(f.n):
|
||||||
# check field names:
|
# check field names:
|
||||||
if f.n.sons[i].kind != nkSym: return isNone
|
if f.n.sons[i].kind != nkSym: return isNone
|
||||||
elif a.n.sons[i].kind != nkSym: return isNone
|
elif a.n.sons[i].kind != nkSym: return isNone
|
||||||
|
|
@ -1484,7 +1484,7 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
||||||
elif x.kind == tyGenericInst and
|
elif x.kind == tyGenericInst and
|
||||||
((f.sons[0] == x.sons[0]) or isGenericSubType(c, x, f, depth)) and
|
((f.sons[0] == x.sons[0]) or isGenericSubType(c, x, f, depth)) and
|
||||||
(sonsLen(x) - 1 == sonsLen(f)):
|
(sonsLen(x) - 1 == sonsLen(f)):
|
||||||
for i in countup(1, sonsLen(f) - 1):
|
for i in 1 ..< sonsLen(f):
|
||||||
if x.sons[i].kind == tyGenericParam:
|
if x.sons[i].kind == tyGenericParam:
|
||||||
internalError(c.c.graph.config, "wrong instantiated type!")
|
internalError(c.c.graph.config, "wrong instantiated type!")
|
||||||
elif typeRel(c, f.sons[i], x.sons[i]) <= isSubtype:
|
elif typeRel(c, f.sons[i], x.sons[i]) <= isSubtype:
|
||||||
|
|
@ -1513,7 +1513,7 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
||||||
# var it1 = internalFind(root, 312) # cannot instantiate: 'D'
|
# var it1 = internalFind(root, 312) # cannot instantiate: 'D'
|
||||||
#
|
#
|
||||||
# we steal the generic parameters from the tyGenericBody:
|
# we steal the generic parameters from the tyGenericBody:
|
||||||
for i in countup(1, sonsLen(f) - 1):
|
for i in 1 ..< sonsLen(f):
|
||||||
let x = PType(idTableGet(c.bindings, genericBody.sons[i-1]))
|
let x = PType(idTableGet(c.bindings, genericBody.sons[i-1]))
|
||||||
if x == nil:
|
if x == nil:
|
||||||
discard "maybe fine (for eg. a==tyNil)"
|
discard "maybe fine (for eg. a==tyNil)"
|
||||||
|
|
@ -1830,7 +1830,7 @@ proc implicitConv(kind: TNodeKind, f: PType, arg: PNode, m: TCandidate,
|
||||||
proc userConvMatch(c: PContext, m: var TCandidate, f, a: PType,
|
proc userConvMatch(c: PContext, m: var TCandidate, f, a: PType,
|
||||||
arg: PNode): PNode =
|
arg: PNode): PNode =
|
||||||
result = nil
|
result = nil
|
||||||
for i in countup(0, len(c.converters) - 1):
|
for i in 0 ..< len(c.converters):
|
||||||
var src = c.converters[i].typ.sons[1]
|
var src = c.converters[i].typ.sons[1]
|
||||||
var dest = c.converters[i].typ.sons[0]
|
var dest = c.converters[i].typ.sons[0]
|
||||||
# for generic type converters we need to check 'src <- a' before
|
# for generic type converters we need to check 'src <- a' before
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ proc computeSizeAlign(conf: ConfigRef; typ: PType) =
|
||||||
of tyTuple:
|
of tyTuple:
|
||||||
maxAlign = 1
|
maxAlign = 1
|
||||||
sizeAccum = 0
|
sizeAccum = 0
|
||||||
for i in countup(0, sonsLen(typ) - 1):
|
for i in 0 ..< sonsLen(typ):
|
||||||
let child = typ.sons[i]
|
let child = typ.sons[i]
|
||||||
computeSizeAlign(conf, child)
|
computeSizeAlign(conf, child)
|
||||||
if child.size < 0:
|
if child.size < 0:
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ template wholeSymTab(cond, section: untyped) =
|
||||||
pm, c.inTypeContext > 0, scopeN))
|
pm, c.inTypeContext > 0, scopeN))
|
||||||
|
|
||||||
proc suggestSymList(c: PContext, list, f: PNode; info: TLineInfo, outputs: var Suggestions) =
|
proc suggestSymList(c: PContext, list, f: PNode; info: TLineInfo, outputs: var Suggestions) =
|
||||||
for i in countup(0, sonsLen(list) - 1):
|
for i in 0 ..< sonsLen(list):
|
||||||
if list.sons[i].kind == nkSym:
|
if list.sons[i].kind == nkSym:
|
||||||
suggestField(c, list.sons[i].sym, f, info, outputs)
|
suggestField(c, list.sons[i].sym, f, info, outputs)
|
||||||
#else: InternalError(list.info, "getSymFromList")
|
#else: InternalError(list.info, "getSymFromList")
|
||||||
|
|
@ -283,12 +283,12 @@ proc suggestSymList(c: PContext, list, f: PNode; info: TLineInfo, outputs: var S
|
||||||
proc suggestObject(c: PContext, n, f: PNode; info: TLineInfo, outputs: var Suggestions) =
|
proc suggestObject(c: PContext, n, f: PNode; info: TLineInfo, outputs: var Suggestions) =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n)-1): suggestObject(c, n.sons[i], f, info, outputs)
|
for i in 0 ..< sonsLen(n): suggestObject(c, n.sons[i], f, info, outputs)
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
var L = sonsLen(n)
|
var L = sonsLen(n)
|
||||||
if L > 0:
|
if L > 0:
|
||||||
suggestObject(c, n.sons[0], f, info, outputs)
|
suggestObject(c, n.sons[0], f, info, outputs)
|
||||||
for i in countup(1, L-1): suggestObject(c, lastSon(n.sons[i]), f, info, outputs)
|
for i in 1 ..< L: suggestObject(c, lastSon(n.sons[i]), f, info, outputs)
|
||||||
of nkSym: suggestField(c, n.sym, f, info, outputs)
|
of nkSym: suggestField(c, n.sym, f, info, outputs)
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ proc transform(c: PTransf, n: PNode): PTransNode
|
||||||
|
|
||||||
proc transformSons(c: PTransf, n: PNode): PTransNode =
|
proc transformSons(c: PTransf, n: PNode): PTransNode =
|
||||||
result = newTransNode(n)
|
result = newTransNode(n)
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result[i] = transform(c, n.sons[i])
|
result[i] = transform(c, n.sons[i])
|
||||||
|
|
||||||
proc newAsgnStmt(c: PTransf, kind: TNodeKind, le: PNode, ri: PTransNode): PTransNode =
|
proc newAsgnStmt(c: PTransf, kind: TNodeKind, le: PNode, ri: PTransNode): PTransNode =
|
||||||
|
|
@ -176,7 +176,7 @@ proc freshVar(c: PTransf; v: PSym): PNode =
|
||||||
|
|
||||||
proc transformVarSection(c: PTransf, v: PNode): PTransNode =
|
proc transformVarSection(c: PTransf, v: PNode): PTransNode =
|
||||||
result = newTransNode(v)
|
result = newTransNode(v)
|
||||||
for i in countup(0, sonsLen(v)-1):
|
for i in 0 ..< sonsLen(v):
|
||||||
var it = v.sons[i]
|
var it = v.sons[i]
|
||||||
if it.kind == nkCommentStmt:
|
if it.kind == nkCommentStmt:
|
||||||
result[i] = PTransNode(it)
|
result[i] = PTransNode(it)
|
||||||
|
|
@ -219,7 +219,7 @@ proc transformConstSection(c: PTransf, v: PNode): PTransNode =
|
||||||
result = PTransNode(v)
|
result = PTransNode(v)
|
||||||
when false:
|
when false:
|
||||||
result = newTransNode(v)
|
result = newTransNode(v)
|
||||||
for i in countup(0, sonsLen(v)-1):
|
for i in 0 ..< sonsLen(v):
|
||||||
var it = v.sons[i]
|
var it = v.sons[i]
|
||||||
if it.kind == nkCommentStmt:
|
if it.kind == nkCommentStmt:
|
||||||
result[i] = PTransNode(it)
|
result[i] = PTransNode(it)
|
||||||
|
|
@ -236,7 +236,7 @@ proc hasContinue(n: PNode): bool =
|
||||||
of nkEmpty..nkNilLit, nkForStmt, nkParForStmt, nkWhileStmt: discard
|
of nkEmpty..nkNilLit, nkForStmt, nkParForStmt, nkWhileStmt: discard
|
||||||
of nkContinueStmt: result = true
|
of nkContinueStmt: result = true
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
if hasContinue(n.sons[i]): return true
|
if hasContinue(n.sons[i]): return true
|
||||||
|
|
||||||
proc newLabel(c: PTransf, n: PNode): PSym =
|
proc newLabel(c: PTransf, n: PNode): PSym =
|
||||||
|
|
@ -318,7 +318,7 @@ proc introduceNewLocalVars(c: PTransf, n: PNode): PTransNode =
|
||||||
return PTransNode(n)
|
return PTransNode(n)
|
||||||
else:
|
else:
|
||||||
result = newTransNode(n)
|
result = newTransNode(n)
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result[i] = introduceNewLocalVars(c, n.sons[i])
|
result[i] = introduceNewLocalVars(c, n.sons[i])
|
||||||
|
|
||||||
proc transformAsgn(c: PTransf, n: PNode): PTransNode =
|
proc transformAsgn(c: PTransf, n: PNode): PTransNode =
|
||||||
|
|
@ -375,7 +375,7 @@ proc transformYield(c: PTransf, n: PNode): PTransNode =
|
||||||
c.transCon.forStmt.len != 3:
|
c.transCon.forStmt.len != 3:
|
||||||
e = skipConv(e)
|
e = skipConv(e)
|
||||||
if e.kind in {nkPar, nkTupleConstr}:
|
if e.kind in {nkPar, nkTupleConstr}:
|
||||||
for i in countup(0, sonsLen(e) - 1):
|
for i in 0 ..< sonsLen(e):
|
||||||
var v = e.sons[i]
|
var v = e.sons[i]
|
||||||
if v.kind == nkExprColonExpr: v = v.sons[1]
|
if v.kind == nkExprColonExpr: v = v.sons[1]
|
||||||
if c.transCon.forStmt[i].kind == nkVarTuple:
|
if c.transCon.forStmt[i].kind == nkVarTuple:
|
||||||
|
|
@ -570,7 +570,7 @@ proc putArgInto(arg: PNode, formal: PType): TPutArgInto =
|
||||||
result = paDirectMapping
|
result = paDirectMapping
|
||||||
of nkPar, nkTupleConstr, nkCurly, nkBracket:
|
of nkPar, nkTupleConstr, nkCurly, nkBracket:
|
||||||
result = paFastAsgn
|
result = paFastAsgn
|
||||||
for i in countup(0, sonsLen(arg) - 1):
|
for i in 0 ..< sonsLen(arg):
|
||||||
if putArgInto(arg.sons[i], formal) != paDirectMapping: return
|
if putArgInto(arg.sons[i], formal) != paDirectMapping: return
|
||||||
result = paDirectMapping
|
result = paDirectMapping
|
||||||
else:
|
else:
|
||||||
|
|
@ -638,7 +638,7 @@ proc transformFor(c: PTransf, n: PNode): PTransNode =
|
||||||
if iter.kind != skIterator: return result
|
if iter.kind != skIterator: return result
|
||||||
# generate access statements for the parameters (unless they are constant)
|
# generate access statements for the parameters (unless they are constant)
|
||||||
pushTransCon(c, newC)
|
pushTransCon(c, newC)
|
||||||
for i in countup(1, sonsLen(call) - 1):
|
for i in 1 ..< sonsLen(call):
|
||||||
var arg = transform(c, call.sons[i]).PNode
|
var arg = transform(c, call.sons[i]).PNode
|
||||||
let ff = skipTypes(iter.typ, abstractInst)
|
let ff = skipTypes(iter.typ, abstractInst)
|
||||||
# can happen for 'nim check':
|
# can happen for 'nim check':
|
||||||
|
|
@ -736,7 +736,7 @@ proc flattenTreeAux(d, a: PNode, op: PSym) =
|
||||||
let op2 = getMergeOp(a)
|
let op2 = getMergeOp(a)
|
||||||
if op2 != nil and
|
if op2 != nil and
|
||||||
(op2.id == op.id or op.magic != mNone and op2.magic == op.magic):
|
(op2.id == op.id or op.magic != mNone and op2.magic == op.magic):
|
||||||
for i in countup(1, sonsLen(a)-1): flattenTreeAux(d, a.sons[i], op)
|
for i in 1 ..< sonsLen(a): flattenTreeAux(d, a.sons[i], op)
|
||||||
else:
|
else:
|
||||||
addSon(d, copyTree(a))
|
addSon(d, copyTree(a))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ proc exprStructuralEquivalent*(a, b: PNode; strictSymEquality=false): bool =
|
||||||
of nkEmpty, nkNilLit, nkType: result = true
|
of nkEmpty, nkNilLit, nkType: result = true
|
||||||
else:
|
else:
|
||||||
if sonsLen(a) == sonsLen(b):
|
if sonsLen(a) == sonsLen(b):
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
if not exprStructuralEquivalent(a.sons[i], b.sons[i],
|
if not exprStructuralEquivalent(a.sons[i], b.sons[i],
|
||||||
strictSymEquality): return
|
strictSymEquality): return
|
||||||
result = true
|
result = true
|
||||||
|
|
@ -69,7 +69,7 @@ proc sameTree*(a, b: PNode): bool =
|
||||||
of nkEmpty, nkNilLit, nkType: result = true
|
of nkEmpty, nkNilLit, nkType: result = true
|
||||||
else:
|
else:
|
||||||
if sonsLen(a) == sonsLen(b):
|
if sonsLen(a) == sonsLen(b):
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
if not sameTree(a.sons[i], b.sons[i]): return
|
if not sameTree(a.sons[i], b.sons[i]): return
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
|
|
@ -121,7 +121,7 @@ proc whichPragma*(n: PNode): TSpecialWord =
|
||||||
if key.kind == nkIdent: result = whichKeyword(key.ident)
|
if key.kind == nkIdent: result = whichKeyword(key.ident)
|
||||||
|
|
||||||
proc effectSpec*(n: PNode, effectType: TSpecialWord): PNode =
|
proc effectSpec*(n: PNode, effectType: TSpecialWord): PNode =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.kind == nkExprColonExpr and whichPragma(it) == effectType:
|
if it.kind == nkExprColonExpr and whichPragma(it) == effectType:
|
||||||
result = it.sons[1]
|
result = it.sons[1]
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ proc hashTree(n: PNode): Hash =
|
||||||
of nkStrLit..nkTripleStrLit:
|
of nkStrLit..nkTripleStrLit:
|
||||||
result = result !& hash(n.strVal)
|
result = result !& hash(n.strVal)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = result !& hashTree(n.sons[i])
|
result = result !& hashTree(n.sons[i])
|
||||||
|
|
||||||
proc treesEquivalent(a, b: PNode): bool =
|
proc treesEquivalent(a, b: PNode): bool =
|
||||||
|
|
@ -47,7 +47,7 @@ proc treesEquivalent(a, b: PNode): bool =
|
||||||
of nkStrLit..nkTripleStrLit: result = a.strVal == b.strVal
|
of nkStrLit..nkTripleStrLit: result = a.strVal == b.strVal
|
||||||
else:
|
else:
|
||||||
if sonsLen(a) == sonsLen(b):
|
if sonsLen(a) == sonsLen(b):
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
if not treesEquivalent(a.sons[i], b.sons[i]): return
|
if not treesEquivalent(a.sons[i], b.sons[i]): return
|
||||||
result = true
|
result = true
|
||||||
if result: result = sameTypeOrNil(a.typ, b.typ)
|
if result: result = sameTypeOrNil(a.typ, b.typ)
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ proc getProcHeader*(conf: ConfigRef; sym: PSym; prefer: TPreferedDesc = preferNa
|
||||||
if sym.kind in routineKinds:
|
if sym.kind in routineKinds:
|
||||||
result.add '('
|
result.add '('
|
||||||
var n = sym.typ.n
|
var n = sym.typ.n
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
let p = n.sons[i]
|
let p = n.sons[i]
|
||||||
if p.kind == nkSym:
|
if p.kind == nkSym:
|
||||||
add(result, p.sym.name.s)
|
add(result, p.sym.name.s)
|
||||||
|
|
@ -150,7 +150,7 @@ proc iterOverNode(marker: var IntSet, n: PNode, iter: TTypeIter,
|
||||||
# a leaf
|
# a leaf
|
||||||
result = iterOverTypeAux(marker, n.typ, iter, closure)
|
result = iterOverTypeAux(marker, n.typ, iter, closure)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = iterOverNode(marker, n.sons[i], iter, closure)
|
result = iterOverNode(marker, n.sons[i], iter, closure)
|
||||||
if result: return
|
if result: return
|
||||||
|
|
||||||
|
|
@ -165,7 +165,7 @@ proc iterOverTypeAux(marker: var IntSet, t: PType, iter: TTypeIter,
|
||||||
of tyGenericInst, tyGenericBody, tyAlias, tySink, tyInferred:
|
of tyGenericInst, tyGenericBody, tyAlias, tySink, tyInferred:
|
||||||
result = iterOverTypeAux(marker, lastSon(t), iter, closure)
|
result = iterOverTypeAux(marker, lastSon(t), iter, closure)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
result = iterOverTypeAux(marker, t.sons[i], iter, closure)
|
result = iterOverTypeAux(marker, t.sons[i], iter, closure)
|
||||||
if result: return
|
if result: return
|
||||||
if t.n != nil: result = iterOverNode(marker, t.n, iter, closure)
|
if t.n != nil: result = iterOverNode(marker, t.n, iter, closure)
|
||||||
|
|
@ -182,14 +182,14 @@ proc searchTypeNodeForAux(n: PNode, p: TTypePredicate,
|
||||||
result = false
|
result = false
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = searchTypeNodeForAux(n.sons[i], p, marker)
|
result = searchTypeNodeForAux(n.sons[i], p, marker)
|
||||||
if result: return
|
if result: return
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
assert(n.sons[0].kind == nkSym)
|
assert(n.sons[0].kind == nkSym)
|
||||||
result = searchTypeNodeForAux(n.sons[0], p, marker)
|
result = searchTypeNodeForAux(n.sons[0], p, marker)
|
||||||
if result: return
|
if result: return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
result = searchTypeNodeForAux(lastSon(n.sons[i]), p, marker)
|
result = searchTypeNodeForAux(lastSon(n.sons[i]), p, marker)
|
||||||
|
|
@ -215,7 +215,7 @@ proc searchTypeForAux(t: PType, predicate: TTypePredicate,
|
||||||
of tyGenericInst, tyDistinct, tyAlias, tySink:
|
of tyGenericInst, tyDistinct, tyAlias, tySink:
|
||||||
result = searchTypeForAux(lastSon(t), predicate, marker)
|
result = searchTypeForAux(lastSon(t), predicate, marker)
|
||||||
of tyArray, tySet, tyTuple:
|
of tyArray, tySet, tyTuple:
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
result = searchTypeForAux(t.sons[i], predicate, marker)
|
result = searchTypeForAux(t.sons[i], predicate, marker)
|
||||||
if result: return
|
if result: return
|
||||||
else:
|
else:
|
||||||
|
|
@ -252,7 +252,7 @@ proc analyseObjectWithTypeFieldAux(t: PType,
|
||||||
if t.n != nil:
|
if t.n != nil:
|
||||||
if searchTypeNodeForAux(t.n, isObjectWithTypeFieldPredicate, marker):
|
if searchTypeNodeForAux(t.n, isObjectWithTypeFieldPredicate, marker):
|
||||||
return frEmbedded
|
return frEmbedded
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
var x = t.sons[i]
|
var x = t.sons[i]
|
||||||
if x != nil: x = x.skipTypes(skipPtrs)
|
if x != nil: x = x.skipTypes(skipPtrs)
|
||||||
res = analyseObjectWithTypeFieldAux(x, marker)
|
res = analyseObjectWithTypeFieldAux(x, marker)
|
||||||
|
|
@ -264,7 +264,7 @@ proc analyseObjectWithTypeFieldAux(t: PType,
|
||||||
of tyGenericInst, tyDistinct, tyAlias, tySink:
|
of tyGenericInst, tyDistinct, tyAlias, tySink:
|
||||||
result = analyseObjectWithTypeFieldAux(lastSon(t), marker)
|
result = analyseObjectWithTypeFieldAux(lastSon(t), marker)
|
||||||
of tyArray, tyTuple:
|
of tyArray, tyTuple:
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
res = analyseObjectWithTypeFieldAux(t.sons[i], marker)
|
res = analyseObjectWithTypeFieldAux(t.sons[i], marker)
|
||||||
if res != frNone:
|
if res != frNone:
|
||||||
return frEmbedded
|
return frEmbedded
|
||||||
|
|
@ -314,7 +314,7 @@ proc canFormAcycleNode(marker: var IntSet, n: PNode, startId: int): bool =
|
||||||
of nkNone..nkNilLit:
|
of nkNone..nkNilLit:
|
||||||
discard
|
discard
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = canFormAcycleNode(marker, n.sons[i], startId)
|
result = canFormAcycleNode(marker, n.sons[i], startId)
|
||||||
if result: return
|
if result: return
|
||||||
|
|
||||||
|
|
@ -325,7 +325,7 @@ proc canFormAcycleAux(marker: var IntSet, typ: PType, startId: int): bool =
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyTuple, tyObject, tyRef, tySequence, tyArray, tyOpenArray, tyVarargs:
|
of tyTuple, tyObject, tyRef, tySequence, tyArray, tyOpenArray, tyVarargs:
|
||||||
if not containsOrIncl(marker, t.id):
|
if not containsOrIncl(marker, t.id):
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
result = canFormAcycleAux(marker, t.sons[i], startId)
|
result = canFormAcycleAux(marker, t.sons[i], startId)
|
||||||
if result: return
|
if result: return
|
||||||
if t.n != nil: result = canFormAcycleNode(marker, t.n, startId)
|
if t.n != nil: result = canFormAcycleNode(marker, t.n, startId)
|
||||||
|
|
@ -361,7 +361,7 @@ proc mutateNode(marker: var IntSet, n: PNode, iter: TTypeMutator,
|
||||||
# a leaf
|
# a leaf
|
||||||
discard
|
discard
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
addSon(result, mutateNode(marker, n.sons[i], iter, closure))
|
addSon(result, mutateNode(marker, n.sons[i], iter, closure))
|
||||||
|
|
||||||
proc mutateTypeAux(marker: var IntSet, t: PType, iter: TTypeMutator,
|
proc mutateTypeAux(marker: var IntSet, t: PType, iter: TTypeMutator,
|
||||||
|
|
@ -370,7 +370,7 @@ proc mutateTypeAux(marker: var IntSet, t: PType, iter: TTypeMutator,
|
||||||
if t == nil: return
|
if t == nil: return
|
||||||
result = iter(t, closure)
|
result = iter(t, closure)
|
||||||
if not containsOrIncl(marker, t.id):
|
if not containsOrIncl(marker, t.id):
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
result.sons[i] = mutateTypeAux(marker, result.sons[i], iter, closure)
|
result.sons[i] = mutateTypeAux(marker, result.sons[i], iter, closure)
|
||||||
if t.n != nil: result.n = mutateNode(marker, t.n, iter, closure)
|
if t.n != nil: result.n = mutateNode(marker, t.n, iter, closure)
|
||||||
assert(result != nil)
|
assert(result != nil)
|
||||||
|
|
@ -459,7 +459,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
result = "int literal(" & $t.n.intVal & ")"
|
result = "int literal(" & $t.n.intVal & ")"
|
||||||
of tyGenericInst, tyGenericInvocation:
|
of tyGenericInst, tyGenericInvocation:
|
||||||
result = typeToString(t.sons[0]) & '['
|
result = typeToString(t.sons[0]) & '['
|
||||||
for i in countup(1, sonsLen(t)-1-ord(t.kind != tyGenericInvocation)):
|
for i in 1 ..< sonsLen(t)-ord(t.kind != tyGenericInvocation):
|
||||||
if i > 1: add(result, ", ")
|
if i > 1: add(result, ", ")
|
||||||
add(result, typeToString(t.sons[i], preferGenericArg))
|
add(result, typeToString(t.sons[i], preferGenericArg))
|
||||||
add(result, ']')
|
add(result, ']')
|
||||||
|
|
@ -557,7 +557,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
if t.n != nil:
|
if t.n != nil:
|
||||||
result = "tuple["
|
result = "tuple["
|
||||||
assert(sonsLen(t.n) == sonsLen(t))
|
assert(sonsLen(t.n) == sonsLen(t))
|
||||||
for i in countup(0, sonsLen(t.n) - 1):
|
for i in 0 ..< sonsLen(t.n):
|
||||||
assert(t.n.sons[i].kind == nkSym)
|
assert(t.n.sons[i].kind == nkSym)
|
||||||
add(result, t.n.sons[i].sym.name.s & ": " & typeToString(t.sons[i]))
|
add(result, t.n.sons[i].sym.name.s & ": " & typeToString(t.sons[i]))
|
||||||
if i < sonsLen(t.n) - 1: add(result, ", ")
|
if i < sonsLen(t.n) - 1: add(result, ", ")
|
||||||
|
|
@ -567,7 +567,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
else:
|
else:
|
||||||
if prefer == preferTypeName: result = "("
|
if prefer == preferTypeName: result = "("
|
||||||
else: result = "tuple of ("
|
else: result = "tuple of ("
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
add(result, typeToString(t.sons[i]))
|
add(result, typeToString(t.sons[i]))
|
||||||
if i < sonsLen(t) - 1: add(result, ", ")
|
if i < sonsLen(t) - 1: add(result, ", ")
|
||||||
add(result, ')')
|
add(result, ')')
|
||||||
|
|
@ -576,7 +576,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
if t.len >= 2:
|
if t.len >= 2:
|
||||||
setLen(result, result.len-1)
|
setLen(result, result.len-1)
|
||||||
result.add '['
|
result.add '['
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
add(result, typeToString(t.sons[i]))
|
add(result, typeToString(t.sons[i]))
|
||||||
if i < sonsLen(t) - 1: add(result, ", ")
|
if i < sonsLen(t) - 1: add(result, ", ")
|
||||||
result.add ']'
|
result.add ']'
|
||||||
|
|
@ -600,7 +600,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
"proc "
|
"proc "
|
||||||
if tfUnresolved in t.flags: result.add "[*missing parameters*]"
|
if tfUnresolved in t.flags: result.add "[*missing parameters*]"
|
||||||
result.add "("
|
result.add "("
|
||||||
for i in countup(1, sonsLen(t) - 1):
|
for i in 1 ..< sonsLen(t):
|
||||||
if t.n != nil and i < t.n.len and t.n[i].kind == nkSym:
|
if t.n != nil and i < t.n.len and t.n[i].kind == nkSym:
|
||||||
add(result, t.n[i].sym.name.s)
|
add(result, t.n[i].sym.name.s)
|
||||||
add(result, ": ")
|
add(result, ": ")
|
||||||
|
|
@ -843,7 +843,7 @@ proc equalParams(a, b: PNode): TParamsEquality =
|
||||||
if length != sonsLen(b):
|
if length != sonsLen(b):
|
||||||
result = paramsNotEqual
|
result = paramsNotEqual
|
||||||
else:
|
else:
|
||||||
for i in countup(1, length - 1):
|
for i in 1 ..< length:
|
||||||
var m = a.sons[i].sym
|
var m = a.sons[i].sym
|
||||||
var n = b.sons[i].sym
|
var n = b.sons[i].sym
|
||||||
assert((m.kind == skParam) and (n.kind == skParam))
|
assert((m.kind == skParam) and (n.kind == skParam))
|
||||||
|
|
@ -872,7 +872,7 @@ proc sameTuple(a, b: PType, c: var TSameTypeClosure): bool =
|
||||||
# complicates the matter a bit.
|
# complicates the matter a bit.
|
||||||
if sonsLen(a) == sonsLen(b):
|
if sonsLen(a) == sonsLen(b):
|
||||||
result = true
|
result = true
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
var x = a.sons[i]
|
var x = a.sons[i]
|
||||||
var y = b.sons[i]
|
var y = b.sons[i]
|
||||||
if IgnoreTupleFields in c.flags:
|
if IgnoreTupleFields in c.flags:
|
||||||
|
|
@ -882,7 +882,7 @@ proc sameTuple(a, b: PType, c: var TSameTypeClosure): bool =
|
||||||
result = sameTypeAux(x, y, c)
|
result = sameTypeAux(x, y, c)
|
||||||
if not result: return
|
if not result: return
|
||||||
if a.n != nil and b.n != nil and IgnoreTupleFields notin c.flags:
|
if a.n != nil and b.n != nil and IgnoreTupleFields notin c.flags:
|
||||||
for i in countup(0, sonsLen(a.n) - 1):
|
for i in 0 ..< sonsLen(a.n):
|
||||||
# check field names:
|
# check field names:
|
||||||
if a.n.sons[i].kind == nkSym and b.n.sons[i].kind == nkSym:
|
if a.n.sons[i].kind == nkSym and b.n.sons[i].kind == nkSym:
|
||||||
var x = a.n.sons[i].sym
|
var x = a.n.sons[i].sym
|
||||||
|
|
@ -946,14 +946,14 @@ proc sameObjectTree(a, b: PNode, c: var TSameTypeClosure): bool =
|
||||||
of nkEmpty, nkNilLit, nkType: result = true
|
of nkEmpty, nkNilLit, nkType: result = true
|
||||||
else:
|
else:
|
||||||
if sonsLen(a) == sonsLen(b):
|
if sonsLen(a) == sonsLen(b):
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
if not sameObjectTree(a.sons[i], b.sons[i], c): return
|
if not sameObjectTree(a.sons[i], b.sons[i], c): return
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
proc sameObjectStructures(a, b: PType, c: var TSameTypeClosure): bool =
|
proc sameObjectStructures(a, b: PType, c: var TSameTypeClosure): bool =
|
||||||
# check base types:
|
# check base types:
|
||||||
if sonsLen(a) != sonsLen(b): return
|
if sonsLen(a) != sonsLen(b): return
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
if not sameTypeOrNilAux(a.sons[i], b.sons[i], c): return
|
if not sameTypeOrNilAux(a.sons[i], b.sons[i], c): return
|
||||||
if not sameObjectTree(a.n, b.n, c): return
|
if not sameObjectTree(a.n, b.n, c): return
|
||||||
result = true
|
result = true
|
||||||
|
|
@ -961,7 +961,7 @@ proc sameObjectStructures(a, b: PType, c: var TSameTypeClosure): bool =
|
||||||
proc sameChildrenAux(a, b: PType, c: var TSameTypeClosure): bool =
|
proc sameChildrenAux(a, b: PType, c: var TSameTypeClosure): bool =
|
||||||
if sonsLen(a) != sonsLen(b): return false
|
if sonsLen(a) != sonsLen(b): return false
|
||||||
result = true
|
result = true
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
result = sameTypeOrNilAux(a.sons[i], b.sons[i], c)
|
result = sameTypeOrNilAux(a.sons[i], b.sons[i], c)
|
||||||
if not result: return
|
if not result: return
|
||||||
|
|
||||||
|
|
@ -1168,7 +1168,7 @@ proc typeAllowedNode(marker: var IntSet, n: PNode, kind: TSymKind,
|
||||||
else:
|
else:
|
||||||
if n.kind == nkRecCase and kind in {skProc, skFunc, skConst}:
|
if n.kind == nkRecCase and kind in {skProc, skFunc, skConst}:
|
||||||
return n[0].typ
|
return n[0].typ
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
result = typeAllowedNode(marker, it, kind, flags)
|
result = typeAllowedNode(marker, it, kind, flags)
|
||||||
if result != nil: break
|
if result != nil: break
|
||||||
|
|
@ -1207,7 +1207,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
||||||
else: result = typeAllowedAux(marker, t2, kind, flags)
|
else: result = typeAllowedAux(marker, t2, kind, flags)
|
||||||
of tyProc:
|
of tyProc:
|
||||||
if kind == skConst and t.callConv == ccClosure: return t
|
if kind == skConst and t.callConv == ccClosure: return t
|
||||||
for i in countup(1, sonsLen(t) - 1):
|
for i in 1 ..< sonsLen(t):
|
||||||
result = typeAllowedAux(marker, t.sons[i], skParam, flags)
|
result = typeAllowedAux(marker, t.sons[i], skParam, flags)
|
||||||
if result != nil: break
|
if result != nil: break
|
||||||
if result.isNil and t.sons[0] != nil:
|
if result.isNil and t.sons[0] != nil:
|
||||||
|
|
@ -1259,14 +1259,14 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
||||||
of tyPtr:
|
of tyPtr:
|
||||||
result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap})
|
result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap})
|
||||||
of tySet:
|
of tySet:
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
result = typeAllowedAux(marker, t.sons[i], kind, flags)
|
result = typeAllowedAux(marker, t.sons[i], kind, flags)
|
||||||
if result != nil: break
|
if result != nil: break
|
||||||
of tyObject, tyTuple:
|
of tyObject, tyTuple:
|
||||||
if kind in {skProc, skFunc, skConst} and
|
if kind in {skProc, skFunc, skConst} and
|
||||||
t.kind == tyObject and t.sons[0] != nil: return t
|
t.kind == tyObject and t.sons[0] != nil: return t
|
||||||
let flags = flags+{taField}
|
let flags = flags+{taField}
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
result = typeAllowedAux(marker, t.sons[i], kind, flags)
|
result = typeAllowedAux(marker, t.sons[i], kind, flags)
|
||||||
if result != nil: break
|
if result != nil: break
|
||||||
if result.isNil and t.n != nil:
|
if result.isNil and t.n != nil:
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ proc copyValue(src: PNode): PNode =
|
||||||
of nkStrLit..nkTripleStrLit: result.strVal = src.strVal
|
of nkStrLit..nkTripleStrLit: result.strVal = src.strVal
|
||||||
else:
|
else:
|
||||||
newSeq(result.sons, sonsLen(src))
|
newSeq(result.sons, sonsLen(src))
|
||||||
for i in countup(0, sonsLen(src) - 1):
|
for i in 0 ..< sonsLen(src):
|
||||||
result.sons[i] = copyValue(src.sons[i])
|
result.sons[i] = copyValue(src.sons[i])
|
||||||
|
|
||||||
proc asgnComplex(x: var TFullReg, y: TFullReg) =
|
proc asgnComplex(x: var TFullReg, y: TFullReg) =
|
||||||
|
|
@ -778,7 +778,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
addSon(b, regs[rb].regToNode)
|
addSon(b, regs[rb].regToNode)
|
||||||
var r = diffSets(c.config, regs[ra].node, b)
|
var r = diffSets(c.config, regs[ra].node, b)
|
||||||
discardSons(regs[ra].node)
|
discardSons(regs[ra].node)
|
||||||
for i in countup(0, sonsLen(r) - 1): addSon(regs[ra].node, r.sons[i])
|
for i in 0 ..< sonsLen(r): addSon(regs[ra].node, r.sons[i])
|
||||||
of opcCard:
|
of opcCard:
|
||||||
decodeB(rkInt)
|
decodeB(rkInt)
|
||||||
regs[ra].intVal = nimsets.cardSet(c.config, regs[rb].node)
|
regs[ra].intVal = nimsets.cardSet(c.config, regs[rb].node)
|
||||||
|
|
@ -1756,7 +1756,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
of opcNDel:
|
of opcNDel:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
let bb = regs[rb].intVal.int
|
let bb = regs[rb].intVal.int
|
||||||
for i in countup(0, regs[rc].intVal.int-1):
|
for i in 0 ..< regs[rc].intVal.int:
|
||||||
delSon(regs[ra].node, bb)
|
delSon(regs[ra].node, bb)
|
||||||
of opcGenSym:
|
of opcGenSym:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,7 @@ proc genIf(c: PCtx, n: PNode; dest: var TDest) =
|
||||||
# Lend:
|
# Lend:
|
||||||
if dest < 0 and not isEmptyType(n.typ): dest = getTemp(c, n.typ)
|
if dest < 0 and not isEmptyType(n.typ): dest = getTemp(c, n.typ)
|
||||||
var endings: seq[TPosition] = @[]
|
var endings: seq[TPosition] = @[]
|
||||||
for i in countup(0, len(n) - 1):
|
for i in 0 ..< len(n):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.len == 2:
|
if it.len == 2:
|
||||||
withTemp(tmp, it.sons[0].typ):
|
withTemp(tmp, it.sons[0].typ):
|
||||||
|
|
@ -436,7 +436,7 @@ proc sameConstant*(a, b: PNode): bool =
|
||||||
of nkEmpty: result = true
|
of nkEmpty: result = true
|
||||||
else:
|
else:
|
||||||
if sonsLen(a) == sonsLen(b):
|
if sonsLen(a) == sonsLen(b):
|
||||||
for i in countup(0, sonsLen(a) - 1):
|
for i in 0 ..< sonsLen(a):
|
||||||
if not sameConstant(a.sons[i], b.sons[i]): return
|
if not sameConstant(a.sons[i], b.sons[i]): return
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
|
|
@ -1739,10 +1739,10 @@ proc genArrAccess(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
|
||||||
proc getNullValueAux(obj: PNode, result: PNode; conf: ConfigRef) =
|
proc getNullValueAux(obj: PNode, result: PNode; conf: ConfigRef) =
|
||||||
case obj.kind
|
case obj.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(obj) - 1): getNullValueAux(obj.sons[i], result, conf)
|
for i in 0 ..< sonsLen(obj): getNullValueAux(obj.sons[i], result, conf)
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
getNullValueAux(obj.sons[0], result, conf)
|
getNullValueAux(obj.sons[0], result, conf)
|
||||||
for i in countup(1, sonsLen(obj) - 1):
|
for i in 1 ..< sonsLen(obj):
|
||||||
getNullValueAux(lastSon(obj.sons[i]), result, conf)
|
getNullValueAux(lastSon(obj.sons[i]), result, conf)
|
||||||
of nkSym:
|
of nkSym:
|
||||||
let field = newNodeI(nkExprColonExpr, result.info)
|
let field = newNodeI(nkExprColonExpr, result.info)
|
||||||
|
|
@ -1784,11 +1784,11 @@ proc getNullValue(typ: PType, info: TLineInfo; conf: ConfigRef): PNode =
|
||||||
getNullValueAux(t.n, result, conf)
|
getNullValueAux(t.n, result, conf)
|
||||||
of tyArray:
|
of tyArray:
|
||||||
result = newNodeIT(nkBracket, info, t)
|
result = newNodeIT(nkBracket, info, t)
|
||||||
for i in countup(0, int(lengthOrd(conf, t)) - 1):
|
for i in 0 ..< int(lengthOrd(conf, t)):
|
||||||
addSon(result, getNullValue(elemType(t), info, conf))
|
addSon(result, getNullValue(elemType(t), info, conf))
|
||||||
of tyTuple:
|
of tyTuple:
|
||||||
result = newNodeIT(nkTupleConstr, info, t)
|
result = newNodeIT(nkTupleConstr, info, t)
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in 0 ..< sonsLen(t):
|
||||||
addSon(result, getNullValue(t.sons[i], info, conf))
|
addSon(result, getNullValue(t.sons[i], info, conf))
|
||||||
of tySet:
|
of tySet:
|
||||||
result = newNodeIT(nkCurly, info, t)
|
result = newNodeIT(nkCurly, info, t)
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@ proc ptrToInt(x: PNode): int {.inline.} =
|
||||||
proc getField(n: PNode; position: int): PSym =
|
proc getField(n: PNode; position: int): PSym =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkRecList:
|
of nkRecList:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in 0 ..< sonsLen(n):
|
||||||
result = getField(n.sons[i], position)
|
result = getField(n.sons[i], position)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
of nkRecCase:
|
of nkRecCase:
|
||||||
result = getField(n.sons[0], position)
|
result = getField(n.sons[0], position)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in 1 ..< sonsLen(n):
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
result = getField(lastSon(n.sons[i]), position)
|
result = getField(lastSon(n.sons[i]), position)
|
||||||
|
|
@ -39,7 +39,7 @@ proc storeAny(s: var string; t: PType; a: PNode; stored: var IntSet; conf: Confi
|
||||||
proc storeObj(s: var string; typ: PType; x: PNode; stored: var IntSet; conf: ConfigRef) =
|
proc storeObj(s: var string; typ: PType; x: PNode; stored: var IntSet; conf: ConfigRef) =
|
||||||
assert x.kind == nkObjConstr
|
assert x.kind == nkObjConstr
|
||||||
let start = 1
|
let start = 1
|
||||||
for i in countup(start, sonsLen(x) - 1):
|
for i in start ..< sonsLen(x):
|
||||||
if i > start: s.add(", ")
|
if i > start: s.add(", ")
|
||||||
var it = x.sons[i]
|
var it = x.sons[i]
|
||||||
if it.kind == nkExprColonExpr:
|
if it.kind == nkExprColonExpr:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue