diff options
author | Clyybber <darkmine956@gmail.com> | 2019-09-09 11:54:15 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-09-09 11:54:15 +0200 |
commit | ed1d41c51e5b3772fdea9e08733dbf46dfb4428e (patch) | |
tree | 48add0b4f759aad5f212894000424df82751eeaa /compiler/astalgo.nim | |
parent | aa95ae6af93e04c5465d76347ab2150bf13d9669 (diff) | |
download | Nim-ed1d41c51e5b3772fdea9e08733dbf46dfb4428e.tar.gz |
Small ast.nim cleanup (#12156)
* Remove sonsLen * Use Indexable
Diffstat (limited to 'compiler/astalgo.nim')
-rw-r--r-- | compiler/astalgo.nim | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index 700092e67..cfa1a67fd 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -160,14 +160,14 @@ proc lookupInRecord(n: PNode, field: PIdent): PSym = result = nil case n.kind of nkRecList: - for i in 0 ..< sonsLen(n): + for i in 0 ..< len(n): result = lookupInRecord(n.sons[i], field) if result != nil: return of nkRecCase: if (n.sons[0].kind != nkSym): return nil result = lookupInRecord(n.sons[0], field) if result != nil: return - for i in 1 ..< sonsLen(n): + for i in 1 ..< len(n): case n.sons[i].kind of nkOfBranch, nkElse: result = lookupInRecord(lastSon(n.sons[i]), field) @@ -183,7 +183,7 @@ proc getModule*(s: PSym): PSym = while result != nil and result.kind != skModule: result = result.owner proc getSymFromList*(list: PNode, ident: PIdent, start: int = 0): PSym = - for i in start ..< sonsLen(list): + for i in start ..< len(list): if list.sons[i].kind == nkSym: result = list.sons[i].sym if result.name.id == ident.id: return @@ -326,9 +326,9 @@ proc typeToYamlAux(conf: ConfigRef; n: PType, marker: var IntSet, indent: int, sonsRope = "\"$1 @$2\"" % [rope($n.kind), rope( strutils.toHex(cast[ByteAddress](n), sizeof(n) * 2))] else: - if sonsLen(n) > 0: + if len(n) > 0: sonsRope = rope("[") - for i in 0 ..< sonsLen(n): + for i in 0 ..< len(n): if i > 0: add(sonsRope, ",") addf(sonsRope, "$N$1$2", [rspaces(indent + 4), typeToYamlAux(conf, n.sons[i], marker, indent + 4, maxRecDepth - 1)]) @@ -375,9 +375,9 @@ proc treeToYamlAux(conf: ConfigRef; n: PNode, marker: var IntSet, indent: int, else: addf(result, ",$N$1\"ident\": null", [istr]) else: - if sonsLen(n) > 0: + if len(n) > 0: addf(result, ",$N$1\"sons\": [", [istr]) - for i in 0 ..< sonsLen(n): + for i in 0 ..< len(n): if i > 0: add(result, ",") addf(result, "$N$1$2", [rspaces(indent + 4), treeToYamlAux(conf, n.sons[i], marker, indent + 4, maxRecDepth - 1)]) @@ -562,12 +562,12 @@ proc value(this: var DebugPrinter; value: PType) = this.key "n" this.value value.n - if sonsLen(value) > 0: + if len(value) > 0: this.key "sons" this.openBracket - for i in 0 ..< sonsLen(value): + for i in 0 ..< len(value): this.value value.sons[i] - if i != sonsLen(value) - 1: + if i != len(value) - 1: this.comma this.closeBracket @@ -615,12 +615,12 @@ proc value(this: var DebugPrinter; value: PNode) = if this.renderSymType and value.typ != nil: this.key "typ" this.value value.typ - if sonsLen(value) > 0: + if len(value) > 0: this.key "sons" this.openBracket - for i in 0 ..< sonsLen(value): + for i in 0 ..< len(value): this.value value.sons[i] - if i != sonsLen(value) - 1: + if i != len(value) - 1: this.comma this.closeBracket |