destructors: work in progress

This commit is contained in:
Araq
2017-10-24 09:40:28 +02:00
parent 1b695a67f8
commit b407f083ba
8 changed files with 109 additions and 27 deletions

View File

@@ -664,6 +664,19 @@ proc afterCallActions(c: PContext; n, orig: PNode, flags: TExprFlags): PNode =
of skMacro: result = semMacroExpr(c, result, orig, callee, flags)
of skTemplate: result = semTemplateExpr(c, result, callee, flags)
else:
when false:
if callee.name.s[0] == '=' and result.len > 1:
# careful, do not skip tyDistinct here:
let t = result[1].typ.skipTypes({tyVar, tyGenericInst, tyAlias, tyInferred})
proc patchHead(callee: PSym; name: string; field: PSym; result: PNode) =
if callee.name.s == name and field != nil:
result.sons[0].sym = field
patchHead(callee, "=destroy", t.destructor, result)
patchHead(callee, "=sink", t.sink, result)
patchHead(callee, "=", t.assignment, result)
semFinishOperands(c, result)
activate(c, result)
fixAbstractType(c, result)