make strscans module work with --newruntime
This commit is contained in:
parent
485d5448fa
commit
0e6eb7d483
2 changed files with 7 additions and 4 deletions
|
|
@ -291,7 +291,7 @@ type
|
||||||
DetectionPass = object
|
DetectionPass = object
|
||||||
processed, capturedVars: IntSet
|
processed, capturedVars: IntSet
|
||||||
ownerToType: Table[int, PType]
|
ownerToType: Table[int, PType]
|
||||||
somethingToDo: bool
|
somethingToDo, noDestructors: bool
|
||||||
graph: ModuleGraph
|
graph: ModuleGraph
|
||||||
|
|
||||||
proc initDetectionPass(g: ModuleGraph; fn: PSym): DetectionPass =
|
proc initDetectionPass(g: ModuleGraph; fn: PSym): DetectionPass =
|
||||||
|
|
@ -404,7 +404,8 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) =
|
||||||
if innerProc:
|
if innerProc:
|
||||||
if s.isIterator: c.somethingToDo = true
|
if s.isIterator: c.somethingToDo = true
|
||||||
if not c.processed.containsOrIncl(s.id):
|
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)
|
detectCapturedVars(body, s, c)
|
||||||
let ow = s.skipGenericOwner
|
let ow = s.skipGenericOwner
|
||||||
if ow == owner:
|
if ow == owner:
|
||||||
|
|
@ -777,7 +778,8 @@ proc liftIterToProc*(g: ModuleGraph; fn: PSym; body: PNode; ptrType: PType): PNo
|
||||||
fn.kind = oldKind
|
fn.kind = oldKind
|
||||||
fn.typ.callConv = oldCC
|
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
|
# XXX gCmd == cmdCompileToJS does not suffice! The compiletime stuff needs
|
||||||
# the transformation even when compiling to JS ...
|
# 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
|
tooEarly = true
|
||||||
else:
|
else:
|
||||||
var d = initDetectionPass(g, fn)
|
var d = initDetectionPass(g, fn)
|
||||||
|
d.noDestructors = noDestructors
|
||||||
detectCapturedVars(body, fn, d)
|
detectCapturedVars(body, fn, d)
|
||||||
if not d.somethingToDo and fn.isIterator:
|
if not d.somethingToDo and fn.isIterator:
|
||||||
addClosureParam(d, fn, body.info)
|
addClosureParam(d, fn, body.info)
|
||||||
|
|
|
||||||
|
|
@ -1115,7 +1115,7 @@ proc transformBody*(g: ModuleGraph, prc: PSym, cache = true;
|
||||||
prc.transformedBody = newNode(nkEmpty) # protects from recursion
|
prc.transformedBody = newNode(nkEmpty) # protects from recursion
|
||||||
var c = openTransf(g, prc.getModule, "")
|
var c = openTransf(g, prc.getModule, "")
|
||||||
c.noDestructors = noDestructors
|
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)
|
result = processTransf(c, result, prc)
|
||||||
liftDefer(c, result)
|
liftDefer(c, result)
|
||||||
result = liftLocalsIfRequested(prc, result, g.cache, g.config)
|
result = liftLocalsIfRequested(prc, result, g.cache, g.config)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue