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

@ -47,7 +47,7 @@ proc rawImportSymbol(c: PContext, s, origin: PSym) =
if s.kind == skType:
var etyp = s.typ
if etyp.kind in {tyBool, tyEnum}:
for j in 0 ..< sonsLen(etyp.n):
for j in 0 ..< len(etyp.n):
var e = etyp.n.sons[j].sym
if e.kind != skEnumField:
internalError(c.config, s.info, "rawImportSymbol")
@ -191,7 +191,7 @@ proc impMod(c: PContext; it: PNode; importStmtResult: PNode) =
proc evalImport*(c: PContext, n: PNode): PNode =
result = newNodeI(nkImportStmt, n.info)
for i in 0 ..< sonsLen(n):
for i in 0 ..< len(n):
let it = n.sons[i]
if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket:
let sep = it[0]
@ -221,7 +221,7 @@ proc evalFrom*(c: PContext, n: PNode): PNode =
if m != nil:
n.sons[0] = newSymNode(m)
addDecl(c, m, n.info) # add symbol to symbol table of module
for i in 1 ..< sonsLen(n):
for i in 1 ..< len(n):
if n.sons[i].kind != nkNilLit:
importSymbol(c, n.sons[i], m)