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/ccgcalls.nim | |
parent | aa95ae6af93e04c5465d76347ab2150bf13d9669 (diff) | |
download | Nim-ed1d41c51e5b3772fdea9e08733dbf46dfb4428e.tar.gz |
Small ast.nim cleanup (#12156)
* Remove sonsLen * Use Indexable
Diffstat (limited to 'compiler/ccgcalls.nim')
-rw-r--r-- | compiler/ccgcalls.nim | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 53ebc2806..84b59d632 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -186,7 +186,7 @@ proc genArgNoParam(p: BProc, n: PNode): Rope = result = rdLoc(a) template genParamLoop(params) {.dirty.} = - if i < sonsLen(typ): + if i < len(typ): assert(typ.n.sons[i].kind == nkSym) let paramType = typ.n.sons[i] if not paramType.typ.isCompileTimeOnly: @@ -209,8 +209,8 @@ proc genPrefixCall(p: BProc, le, ri: PNode, d: var TLoc) = # getUniqueType() is too expensive here: var typ = skipTypes(ri.sons[0].typ, abstractInstOwned) assert(typ.kind == tyProc) - assert(sonsLen(typ) == sonsLen(typ.n)) - var length = sonsLen(ri) + assert(len(typ) == len(typ.n)) + var length = len(ri) for i in 1 ..< length: genParamLoop(params) var callee = rdLoc(op) @@ -234,9 +234,9 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) = var typ = skipTypes(ri.sons[0].typ, abstractInst) assert(typ.kind == tyProc) - var length = sonsLen(ri) + var length = len(ri) for i in 1 ..< length: - assert(sonsLen(typ) == sonsLen(typ.n)) + assert(len(typ) == len(typ.n)) genParamLoop(pl) template genCallPattern {.dirty.} = @@ -248,7 +248,7 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) = let rawProc = getRawProcType(p, typ) if typ.sons[0] != nil: if isInvalidReturnType(p.config, typ.sons[0]): - if sonsLen(ri) > 1: add(pl, ~", ") + if len(ri) > 1: add(pl, ~", ") # beware of 'result = p(result)'. We may need to allocate a temporary: if d.k in {locTemp, locNone} or not leftAppearsOnRightSide(le, ri): # Great, we can use 'd': @@ -280,7 +280,7 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) = genCallPattern() proc genOtherArg(p: BProc; ri: PNode; i: int; typ: PType): Rope = - if i < sonsLen(typ): + if i < len(typ): # 'var T' is 'T&' in C++. This means we ignore the request of # any nkHiddenAddr when it's a 'var T'. let paramType = typ.n.sons[i] @@ -357,7 +357,7 @@ proc genThisArg(p: BProc; ri: PNode; i: int; typ: PType): Rope = # for better or worse c2nim translates the 'this' argument to a 'var T'. # However manual wrappers may also use 'ptr T'. In any case we support both # for convenience. - internalAssert p.config, i < sonsLen(typ) + internalAssert p.config, i < len(typ) assert(typ.n.sons[i].kind == nkSym) # if the parameter is lying (tyVar) and thus we required an additional deref, # skip the deref: @@ -448,8 +448,8 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) = # getUniqueType() is too expensive here: var typ = skipTypes(ri.sons[0].typ, abstractInst) assert(typ.kind == tyProc) - var length = sonsLen(ri) - assert(sonsLen(typ) == sonsLen(typ.n)) + var length = len(ri) + assert(len(typ) == len(typ.n)) # don't call '$' here for efficiency: let pat = ri.sons[0].sym.loc.r.data internalAssert p.config, pat.len > 0 @@ -484,7 +484,7 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) = var params: Rope for i in 2 ..< length: if params != nil: params.add(~", ") - assert(sonsLen(typ) == sonsLen(typ.n)) + assert(len(typ) == len(typ.n)) add(params, genOtherArg(p, ri, i, typ)) fixupCall(p, le, ri, d, pl, params) @@ -496,8 +496,8 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) = # getUniqueType() is too expensive here: var typ = skipTypes(ri.sons[0].typ, abstractInst) assert(typ.kind == tyProc) - var length = sonsLen(ri) - assert(sonsLen(typ) == sonsLen(typ.n)) + var length = len(ri) + assert(len(typ) == len(typ.n)) # don't call '$' here for efficiency: let pat = ri.sons[0].sym.loc.r.data @@ -519,8 +519,8 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) = add(pl, ~": ") add(pl, genArg(p, ri.sons[2], typ.n.sons[2].sym, ri)) for i in start ..< length: - assert(sonsLen(typ) == sonsLen(typ.n)) - if i >= sonsLen(typ): + assert(len(typ) == len(typ.n)) + if i >= len(typ): internalError(p.config, ri.info, "varargs for objective C method?") assert(typ.n.sons[i].kind == nkSym) var param = typ.n.sons[i].sym @@ -530,7 +530,7 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) = add(pl, genArg(p, ri.sons[i], param, ri)) if typ.sons[0] != nil: if isInvalidReturnType(p.config, typ.sons[0]): - if sonsLen(ri) > 1: add(pl, ~" ") + if len(ri) > 1: add(pl, ~" ") # beware of 'result = p(result)'. We always allocate a temporary: if d.k in {locTemp, locNone}: # We already got a temp. Great, special case it: |