diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-04-14 23:13:40 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-04-14 23:13:49 +0200 |
commit | 0e6eb7d483fe1b975bd51a4900946130edf506e7 (patch) | |
tree | 8174cbb76b02e79d8eec197f0806fcdd27cf4bb9 | |
parent | 485d5448fa325b74b3636ffd53ede4066c3aad96 (diff) | |
download | Nim-0e6eb7d483fe1b975bd51a4900946130edf506e7.tar.gz |
make strscans module work with --newruntime
-rw-r--r-- | compiler/lambdalifting.nim | 9 | ||||
-rw-r--r-- | compiler/transf.nim | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 3054b1f2e..180c5531b 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -291,7 +291,7 @@ type DetectionPass = object processed, capturedVars: IntSet ownerToType: Table[int, PType] - somethingToDo: bool + somethingToDo, noDestructors: bool graph: ModuleGraph proc initDetectionPass(g: ModuleGraph; fn: PSym): DetectionPass = @@ -404,7 +404,8 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) = if innerProc: if s.isIterator: c.somethingToDo = true if not c.processed.containsOrIncl(s.id): - let body = transformBody(c.graph, s) + let body = transformBody(c.graph, s, cache = true, + noDestructors = c.noDestructors) detectCapturedVars(body, s, c) let ow = s.skipGenericOwner if ow == owner: @@ -777,7 +778,8 @@ proc liftIterToProc*(g: ModuleGraph; fn: PSym; body: PNode; ptrType: PType): PNo fn.kind = oldKind fn.typ.callConv = oldCC -proc liftLambdas*(g: ModuleGraph; fn: PSym, body: PNode; tooEarly: var bool): PNode = +proc liftLambdas*(g: ModuleGraph; fn: PSym, body: PNode; tooEarly: var bool; + noDestructors: bool): PNode = # XXX gCmd == cmdCompileToJS does not suffice! The compiletime stuff needs # the transformation even when compiling to JS ... @@ -793,6 +795,7 @@ proc liftLambdas*(g: ModuleGraph; fn: PSym, body: PNode; tooEarly: var bool): PN tooEarly = true else: var d = initDetectionPass(g, fn) + d.noDestructors = noDestructors detectCapturedVars(body, fn, d) if not d.somethingToDo and fn.isIterator: addClosureParam(d, fn, body.info) diff --git a/compiler/transf.nim b/compiler/transf.nim index 30c77fed9..febe65d73 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -1115,7 +1115,7 @@ proc transformBody*(g: ModuleGraph, prc: PSym, cache = true; prc.transformedBody = newNode(nkEmpty) # protects from recursion var c = openTransf(g, prc.getModule, "") c.noDestructors = noDestructors - result = liftLambdas(g, prc, prc.ast[bodyPos], c.tooEarly) + result = liftLambdas(g, prc, prc.ast[bodyPos], c.tooEarly, noDestructors) result = processTransf(c, result, prc) liftDefer(c, result) result = liftLocalsIfRequested(prc, result, g.cache, g.config) |