diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-03-14 07:26:38 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-03-14 07:59:44 +0100 |
commit | 62ab338900b6f0e80c10a81792301789a6465e20 (patch) | |
tree | 95bb15acc6fd6b600616d21ccc7a590a14850314 /compiler | |
parent | 1f614982389da147876722bf66c238c82b55d1c2 (diff) | |
download | Nim-62ab338900b6f0e80c10a81792301789a6465e20.tar.gz |
added lowerings.genLen helper proc
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/lowerings.nim | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/lowerings.nim b/compiler/lowerings.nim index 2c1c3c48d..b78bccceb 100644 --- a/compiler/lowerings.nim +++ b/compiler/lowerings.nim @@ -550,6 +550,15 @@ proc genHigh*(g: ModuleGraph; n: PNode): PNode = result.sons[0] = newSymNode(getSysMagic(g, n.info, "high", mHigh)) result.sons[1] = n +proc genLen*(g: ModuleGraph; n: PNode): PNode = + if skipTypes(n.typ, abstractVar).kind == tyArray: + result = newIntLit(g, n.info, lastOrd(g.config, skipTypes(n.typ, abstractVar)) + 1) + else: + result = newNodeI(nkCall, n.info, 2) + result.typ = getSysType(g, n.info, tyInt) + result.sons[0] = newSymNode(getSysMagic(g, n.info, "len", mLengthSeq)) + result.sons[1] = n + proc setupArgsForParallelism(g: ModuleGraph; n: PNode; objType: PType; scratchObj: PSym; castExpr, call, varSection, varInit, result: PNode) = |