[refactoring] liftdestructors.nim is callable from lambdalifting; refs #11217
This commit is contained in:
parent
e4d0f4fee0
commit
b056d32a79
3 changed files with 120 additions and 104 deletions
|
|
@ -709,7 +709,7 @@ proc track(tracked: PEffects, n: PNode) =
|
|||
return
|
||||
if n.typ != nil:
|
||||
if tracked.owner.kind != skMacro and n.typ.skipTypes(abstractVar).kind != tyOpenArray:
|
||||
createTypeBoundOps(tracked.c, n.typ, n.info)
|
||||
createTypeBoundOps(tracked.graph, tracked.c, n.typ, n.info)
|
||||
if a.kind == nkCast and a[1].typ.kind == tyProc:
|
||||
a = a[1]
|
||||
# XXX: in rare situations, templates and macros will reach here after
|
||||
|
|
@ -770,18 +770,18 @@ proc track(tracked: PEffects, n: PNode) =
|
|||
notNilCheck(tracked, n.sons[1], n.sons[0].typ)
|
||||
when false: cstringCheck(tracked, n)
|
||||
if tracked.owner.kind != skMacro:
|
||||
createTypeBoundOps(tracked.c, n[0].typ, n.info)
|
||||
createTypeBoundOps(tracked.graph, tracked.c, n[0].typ, n.info)
|
||||
of nkVarSection, nkLetSection:
|
||||
for child in n:
|
||||
let last = lastSon(child)
|
||||
if last.kind != nkEmpty: track(tracked, last)
|
||||
if tracked.owner.kind != skMacro:
|
||||
if child.kind == nkVarTuple:
|
||||
createTypeBoundOps(tracked.c, child[^1].typ, child.info)
|
||||
createTypeBoundOps(tracked.graph, tracked.c, child[^1].typ, child.info)
|
||||
for i in 0..child.len-3:
|
||||
createTypeBoundOps(tracked.c, child[i].typ, child.info)
|
||||
createTypeBoundOps(tracked.graph, tracked.c, child[i].typ, child.info)
|
||||
else:
|
||||
createTypeBoundOps(tracked.c, child[0].typ, child.info)
|
||||
createTypeBoundOps(tracked.graph, tracked.c, child[0].typ, child.info)
|
||||
if child.kind == nkIdentDefs and last.kind != nkEmpty:
|
||||
for i in 0 .. child.len-3:
|
||||
initVar(tracked, child.sons[i], volatileCheck=false)
|
||||
|
|
@ -827,15 +827,15 @@ proc track(tracked: PEffects, n: PNode) =
|
|||
if tracked.owner.kind != skMacro:
|
||||
if it.kind == nkVarTuple:
|
||||
for x in it:
|
||||
createTypeBoundOps(tracked.c, x.typ, x.info)
|
||||
createTypeBoundOps(tracked.graph, tracked.c, x.typ, x.info)
|
||||
else:
|
||||
createTypeBoundOps(tracked.c, it.typ, it.info)
|
||||
createTypeBoundOps(tracked.graph, tracked.c, it.typ, it.info)
|
||||
let iterCall = n[n.len-2]
|
||||
let loopBody = n[n.len-1]
|
||||
if tracked.owner.kind != skMacro and iterCall.safelen > 1:
|
||||
# XXX this is a bit hacky:
|
||||
if iterCall[1].typ != nil and iterCall[1].typ.skipTypes(abstractVar).kind notin {tyVarargs, tyOpenArray}:
|
||||
createTypeBoundOps(tracked.c, iterCall[1].typ, iterCall[1].info)
|
||||
createTypeBoundOps(tracked.graph, tracked.c, iterCall[1].typ, iterCall[1].info)
|
||||
track(tracked, iterCall)
|
||||
track(tracked, loopBody)
|
||||
setLen(tracked.init, oldState)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue