diff options
Diffstat (limited to 'compiler/trees.nim')
-rw-r--r-- | compiler/trees.nim | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/compiler/trees.nim b/compiler/trees.nim index fd06425cb..4e6461b51 100644 --- a/compiler/trees.nim +++ b/compiler/trees.nim @@ -44,9 +44,9 @@ proc exprStructuralEquivalent*(a, b: PNode; strictSymEquality=false): bool = of nkCommentStmt: result = a.comment == b.comment of nkEmpty, nkNilLit, nkType: result = true else: - if len(a) == len(b): - for i in 0 ..< len(a): - if not exprStructuralEquivalent(a.sons[i], b.sons[i], + if a.len == b.len: + for i in 0..<a.len: + if not exprStructuralEquivalent(a[i], b[i], strictSymEquality): return result = true @@ -68,16 +68,16 @@ proc sameTree*(a, b: PNode): bool = of nkStrLit..nkTripleStrLit: result = a.strVal == b.strVal of nkEmpty, nkNilLit, nkType: result = true else: - if len(a) == len(b): - for i in 0 ..< len(a): - if not sameTree(a.sons[i], b.sons[i]): return + if a.len == b.len: + for i in 0..<a.len: + if not sameTree(a[i], b[i]): return result = true proc getMagic*(op: PNode): TMagic = case op.kind of nkCallKinds: - case op.sons[0].kind - of nkSym: result = op.sons[0].sym.magic + case op[0].kind + of nkSym: result = op[0].sym.magic else: result = mNone else: result = mNone @@ -87,7 +87,7 @@ proc isConstExpr*(n: PNode): bool = proc isCaseObj*(n: PNode): bool = if n.kind == nkRecCase: return true - for i in 0..<safeLen(n): + for i in 0..<n.safeLen: if n[i].isCaseObj: return true proc isDeepConstExpr*(n: PNode): bool = @@ -95,10 +95,10 @@ proc isDeepConstExpr*(n: PNode): bool = of nkCharLit..nkNilLit: result = true of nkExprEqExpr, nkExprColonExpr, nkHiddenStdConv, nkHiddenSubConv: - result = isDeepConstExpr(n.sons[1]) + result = isDeepConstExpr(n[1]) of nkCurly, nkBracket, nkPar, nkTupleConstr, nkObjConstr, nkClosure, nkRange: - for i in ord(n.kind == nkObjConstr) ..< n.len: - if not isDeepConstExpr(n.sons[i]): return false + for i in ord(n.kind == nkObjConstr)..<n.len: + if not isDeepConstExpr(n[i]): return false if n.typ.isNil: result = true else: let t = n.typ.skipTypes({tyGenericInst, tyDistinct, tyAlias, tySink, tyOwned}) @@ -117,7 +117,7 @@ proc isRange*(n: PNode): bool {.inline.} = result = true proc whichPragma*(n: PNode): TSpecialWord = - let key = if n.kind in nkPragmaCallKinds and n.len > 0: n.sons[0] else: n + let key = if n.kind in nkPragmaCallKinds and n.len > 0: n[0] else: n if key.kind == nkIdent: result = whichKeyword(key.ident) proc findPragma*(n: PNode, which: TSpecialWord): PNode = @@ -127,13 +127,13 @@ proc findPragma*(n: PNode, which: TSpecialWord): PNode = return son proc effectSpec*(n: PNode, effectType: TSpecialWord): PNode = - for i in 0 ..< len(n): - var it = n.sons[i] + for i in 0..<n.len: + var it = n[i] if it.kind == nkExprColonExpr and whichPragma(it) == effectType: - result = it.sons[1] + result = it[1] if result.kind notin {nkCurly, nkBracket}: result = newNodeI(nkCurly, result.info) - result.add(it.sons[1]) + result.add(it[1]) return proc unnestStmts(n, result: PNode) = @@ -146,8 +146,8 @@ proc flattenStmts*(n: PNode): PNode = result = newNodeI(nkStmtList, n.info) unnestStmts(n, result) if result.len == 1: - result = result.sons[0] + result = result[0] proc extractRange*(k: TNodeKind, n: PNode, a, b: int): PNode = result = newNodeI(k, n.info, b-a+1) - for i in 0 .. b-a: result.sons[i] = n.sons[i+a] + for i in 0..b-a: result[i] = n[i+a] |