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

@ -31,7 +31,7 @@ proc hashTree(n: PNode): Hash =
of nkStrLit..nkTripleStrLit:
result = result !& hash(n.strVal)
else:
for i in 0 ..< sonsLen(n):
for i in 0 ..< len(n):
result = result !& hashTree(n.sons[i])
proc treesEquivalent(a, b: PNode): bool =
@ -46,8 +46,8 @@ proc treesEquivalent(a, b: PNode): bool =
of nkFloatLit..nkFloat64Lit: result = a.floatVal == b.floatVal
of nkStrLit..nkTripleStrLit: result = a.strVal == b.strVal
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 treesEquivalent(a.sons[i], b.sons[i]): return
result = true
if result: result = sameTypeOrNil(a.typ, b.typ)