From 62ab338900b6f0e80c10a81792301789a6465e20 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 14 Mar 2019 07:26:38 +0100 Subject: [PATCH] added lowerings.genLen helper proc --- compiler/lowerings.nim | 9 +++++++++ 1 file changed, 9 insertions(+) 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) =