--gc:destructors: next steps; WIP

This commit is contained in:
Andreas Rumpf 2018-07-21 13:16:53 +02:00
commit f485ebe162
8 changed files with 108 additions and 64 deletions

View file

@ -334,7 +334,9 @@ proc resetLoc(p: BProc, loc: var TLoc) =
proc constructLoc(p: BProc, loc: TLoc, isTemp = false) =
let typ = loc.t
if not isComplexValueType(typ):
if p.config.selectedGc == gcDestructors and skipTypes(typ, abstractInst).kind in {tyString, tySequence}:
linefmt(p, cpsStmts, "$1.len = 0; $1.p = NIM_NIL;$n", rdLoc(loc))
elif not isComplexValueType(typ):
linefmt(p, cpsStmts, "$1 = ($2)0;$n", rdLoc(loc),
getTypeDesc(p.module, typ))
else: