summary refs log tree commit diff stats
path: root/compiler/transf.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-01-03 15:23:07 +0100
committerAndreas Rumpf <rumpf_a@web.de>2016-01-03 15:23:07 +0100
commit1ad69be98863aa6f73ec205dee8c0a344a337adb (patch)
treeb459bc7739bc3426055d0df84a3b52fd2dcf1208 /compiler/transf.nim
parent307a6095fa69104e3b21aa796095f4b5bda12041 (diff)
downloadNim-1ad69be98863aa6f73ec205dee8c0a344a337adb.tar.gz
next steps to produce working closure iterators
Diffstat (limited to 'compiler/transf.nim')
-rw-r--r--compiler/transf.nim9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 9a762e04e..9ba52bb2d 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -45,7 +45,7 @@ type
     inlining: int            # > 0 if we are in inlining context (copy vars)
     nestedProcs: int         # > 0 if we are in a nested proc
     contSyms, breakSyms: seq[PSym]  # to transform 'continue' and 'break'
-    deferDetected: bool
+    deferDetected, tooEarly: bool
   PTransf = ref TTransfContext
 
 proc newTransNode(a: PNode): PTransNode {.inline.} =
@@ -112,7 +112,8 @@ proc newAsgnStmt(c: PTransf, le: PNode, ri: PTransNode): PTransNode =
 
 proc transformSymAux(c: PTransf, n: PNode): PNode =
   if n.sym.kind == skIterator and n.sym.typ.callConv == ccClosure:
-    return liftIterSym(n, getCurrOwner(c))
+    if c.tooEarly: return n
+    else: return liftIterSym(n, getCurrOwner(c))
   var b: PNode
   var tc = c.transCon
   if sfBorrow in n.sym.flags and n.sym.kind in routineKinds:
@@ -883,9 +884,9 @@ proc transformBody*(module: PSym, n: PNode, prc: PSym): PNode =
   if nfTransf in n.flags or prc.kind in {skTemplate}:
     result = n
   else:
-    result = liftLambdas(prc, n)
-    #result = n
     var c = openTransf(module, "")
+    result = liftLambdas(prc, n, c.tooEarly)
+    #result = n
     result = processTransf(c, result, prc)
     liftDefer(c, result)
     #result = liftLambdas(prc, result)