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

@ -200,8 +200,8 @@ proc copyValue(src: PNode): PNode =
of nkIdent: result.ident = src.ident
of nkStrLit..nkTripleStrLit: result.strVal = src.strVal
else:
newSeq(result.sons, sonsLen(src))
for i in 0 ..< sonsLen(src):
newSeq(result.sons, len(src))
for i in 0 ..< len(src):
result.sons[i] = copyValue(src.sons[i])
proc asgnComplex(x: var TFullReg, y: TFullReg) =
@ -782,7 +782,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
addSon(b, regs[rb].regToNode)
var r = diffSets(c.config, regs[ra].node, b)
discardSons(regs[ra].node)
for i in 0 ..< sonsLen(r): addSon(regs[ra].node, r.sons[i])
for i in 0 ..< len(r): addSon(regs[ra].node, r.sons[i])
of opcCard:
decodeB(rkInt)
regs[ra].intVal = nimsets.cardSet(c.config, regs[rb].node)
@ -1164,7 +1164,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
# we know the next instruction is a 'fjmp':
let branch = c.constants[instr.regBx-wordExcess]
var cond = false
for j in 0 .. sonsLen(branch) - 2:
for j in 0 .. len(branch) - 2:
if overlap(regs[ra].regToNode, branch.sons[j]):
cond = true
break
@ -1589,7 +1589,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
error = formatMsg(conf, info, msg, arg))
if error.len > 0:
c.errorFlag = error
elif sonsLen(ast) != 1:
elif len(ast) != 1:
c.errorFlag = formatMsg(c.config, c.debug[pc], errGenerated,
"expected expression, but got multiple statements")
else: