topttree destructor finally works
This commit is contained in:
parent
b407f083ba
commit
4f2b79a380
5 changed files with 16 additions and 60 deletions
|
|
@ -164,26 +164,22 @@ proc isHarmlessVar*(s: PSym; c: Con): bool =
|
|||
template interestingSym(s: PSym): bool =
|
||||
s.owner == c.owner and s.kind in InterestingSyms and hasDestructor(s.typ)
|
||||
|
||||
proc patchHead(n: PNode; alreadyPatched: var IntSet) =
|
||||
proc patchHead(n: PNode) =
|
||||
if n.kind in nkCallKinds and n[0].kind == nkSym and n.len > 1:
|
||||
let s = n[0].sym
|
||||
if sfFromGeneric in s.flags or true:
|
||||
if s.name.s[0] == '=' and not containsOrIncl(alreadyPatched, s.id):
|
||||
patchHead(s.getBody, alreadyPatched)
|
||||
if sfFromGeneric in s.flags and s.name.s[0] == '=' and
|
||||
s.name.s in ["=sink", "=", "=destroy"]:
|
||||
excl(s.flags, sfFromGeneric)
|
||||
patchHead(s.getBody)
|
||||
let t = n[1].typ.skipTypes({tyVar, tyGenericInst, tyAlias, tyInferred})
|
||||
template patch(op, field) =
|
||||
if s.name.s == op and field != nil: #and field != s:
|
||||
if s.name.s == op and field != nil and field != s:
|
||||
n.sons[0].sym = field
|
||||
patch "=sink", t.sink
|
||||
patch "=", t.assignment
|
||||
patch "=destroy", t.destructor
|
||||
for x in n:
|
||||
patchHead(x, alreadyPatched)
|
||||
|
||||
template patchHead(n: PNode) =
|
||||
when false:
|
||||
var alreadyPatched = initIntSet()
|
||||
patchHead(n, alreadyPatched)
|
||||
patchHead(x)
|
||||
|
||||
proc genSink(t: PType; dest: PNode): PNode =
|
||||
let t = t.skipTypes({tyGenericInst, tyAlias})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue