From 9309f8101d5acf349611314267dbdf1f9a352022 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 27 Dec 2015 00:17:48 +0100 Subject: new-ll: further progress (bootstrapping still fails) --- compiler/lambdalifting.nim | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'compiler/lambdalifting.nim') diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 139a3f9ce..613fb8555 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -169,7 +169,7 @@ proc addHiddenParam(routine: PSym, param: PSym) = proc getHiddenParam(routine: PSym): PSym = let params = routine.ast.sons[paramsPos] let hidden = lastSon(params) - if hidden.kind == nkSym and hidden.sym.kind == skParam: + if hidden.kind == nkSym and hidden.sym.kind == skParam and hidden.sym.name.s == paramName: result = hidden.sym assert sfFromGeneric in result.flags else: @@ -194,7 +194,7 @@ proc illegalCapture(s: PSym): bool {.inline.} = s.kind == skResult proc isInnerProc(s: PSym): bool = - if s.kind in {skProc, skMethod, skConverter, skIterator}: + if s.kind in {skProc, skMethod, skConverter, skIterator} and s.magic == mNone: result = s.skipGenericOwner.kind in routineKinds proc createUpField(obj, fieldType: PType): PSym = @@ -327,7 +327,7 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) = # ow != owner: return # direct or indirect dependency: - if innerProc or interestingVar(s): + if (innerProc and s.typ.callConv == ccClosure) or interestingVar(s): discard """ proc outer() = var x: int @@ -371,8 +371,11 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) = of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit, nkClosure, nkTemplateDef, nkTypeSection: discard - of nkProcDef, nkMethodDef, nkIteratorDef, nkConverterDef, nkMacroDef: + of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef: discard + of nkLambdaKinds, nkIteratorDef: + if n.typ != nil: + detectCapturedVars(n[namePos], owner, c) else: for i in 0..