diff options
author | Araq <rumpf_a@web.de> | 2019-11-13 11:23:07 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-11-13 23:29:21 +0100 |
commit | 3020e49b7554c1bd465811864cb781abdd89ec0b (patch) | |
tree | 795e6b24d59b75a2c323bb977759ccda89fba51d | |
parent | 6ad0238fd7cbf35d2200767efe97d764834114bc (diff) | |
download | Nim-3020e49b7554c1bd465811864cb781abdd89ec0b.tar.gz |
ARC: use the new .cursor annotation for 'up' pointers
-rw-r--r-- | compiler/lambdalifting.nim | 8 | ||||
-rw-r--r-- | compiler/liftdestructors.nim | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index ebd884324..a3535010d 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -347,8 +347,7 @@ proc createUpField(c: var DetectionPass; dest, dep: PSym; info: TLineInfo) = # with cycles properly, so it's better to produce a weak ref (=ptr) here. # This seems to be generally correct but since it's a bit risky it's disabled # for now. - let fieldType = if isDefined(c.graph.config, "nimCycleBreaker") or - c.graph.config.selectedGC == gcDestructors: + let fieldType = if isDefined(c.graph.config, "nimCycleBreaker"): c.getEnvTypeForOwnerUp(dep, info) #getHiddenParam(dep).typ else: c.getEnvTypeForOwner(dep, info) @@ -360,9 +359,14 @@ proc createUpField(c: var DetectionPass; dest, dep: PSym; info: TLineInfo) = if upField != nil: if upField.typ.skipTypes({tyOwned, tyRef, tyPtr}) != fieldType.skipTypes({tyOwned, tyRef, tyPtr}): localError(c.graph.config, dep.info, "internal error: up references do not agree") + + if c.graph.config.selectedGC == gcDestructors and sfCursor notin upField.flags: + localError(c.graph.config, dep.info, "internal error: up reference is not a .cursor") else: let result = newSym(skField, upIdent, obj.owner, obj.owner.info) result.typ = fieldType + if c.graph.config.selectedGC == gcDestructors: + result.flags.incl sfCursor rawAddField(obj, result) discard """ diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim index 3787fe6a7..5ef62f531 100644 --- a/compiler/liftdestructors.nim +++ b/compiler/liftdestructors.nim @@ -66,7 +66,7 @@ proc fillBodyObj(c: var TLiftCtx; n, body, x, y: PNode) = of nkSym: let f = n.sym if sfCursor in f.flags and f.typ.skipTypes(abstractInst).kind in {tyRef, tyProc} and - c.g.config.selectedGC == gcDestructors: + c.g.config.selectedGC in {gcDestructors, gcHooks}: defaultOp(c, f.typ, body, x.dotField(f), y.dotField(f)) else: fillBody(c, f.typ, body, x.dotField(f), y.dotField(f)) |