Small ast.nim cleanup (#12156)

* Remove sonsLen
* Use Indexable
This commit is contained in:
Clyybber 2019-09-09 11:54:15 +02:00 • committed by Andreas Rumpf
commit ed1d41c51e
54 changed files with 559 additions and 573 deletions

View file

@ -44,8 +44,8 @@ proc exprStructuralEquivalent*(a, b: PNode; strictSymEquality=false): bool =
of nkCommentStmt: result = a.comment == b.comment
of nkEmpty, nkNilLit, nkType: result = true
else:
if sonsLen(a) == sonsLen(b):
for i in 0 ..< sonsLen(a):
if len(a) == len(b):
for i in 0 ..< len(a):
if not exprStructuralEquivalent(a.sons[i], b.sons[i],
strictSymEquality): return
result = true
@ -68,8 +68,8 @@ proc sameTree*(a, b: PNode): bool =
of nkStrLit..nkTripleStrLit: result = a.strVal == b.strVal
of nkEmpty, nkNilLit, nkType: result = true
else:
if sonsLen(a) == sonsLen(b):
for i in 0 ..< sonsLen(a):
if len(a) == len(b):
for i in 0 ..< len(a):
if not sameTree(a.sons[i], b.sons[i]): return
result = true
@ -127,7 +127,7 @@ proc findPragma*(n: PNode, which: TSpecialWord): PNode =
return son
proc effectSpec*(n: PNode, effectType: TSpecialWord): PNode =
for i in 0 ..< sonsLen(n):
for i in 0 ..< len(n):
var it = n.sons[i]
if it.kind == nkExprColonExpr and whichPragma(it) == effectType:
result = it.sons[1]