ARC: use the new .cursor annotation for 'up' pointers
This commit is contained in:
parent
6ad0238fd7
commit
3020e49b75
2 changed files with 7 additions and 3 deletions
|
|
@ -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.
|
# 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
|
# This seems to be generally correct but since it's a bit risky it's disabled
|
||||||
# for now.
|
# for now.
|
||||||
let fieldType = if isDefined(c.graph.config, "nimCycleBreaker") or
|
let fieldType = if isDefined(c.graph.config, "nimCycleBreaker"):
|
||||||
c.graph.config.selectedGC == gcDestructors:
|
|
||||||
c.getEnvTypeForOwnerUp(dep, info) #getHiddenParam(dep).typ
|
c.getEnvTypeForOwnerUp(dep, info) #getHiddenParam(dep).typ
|
||||||
else:
|
else:
|
||||||
c.getEnvTypeForOwner(dep, info)
|
c.getEnvTypeForOwner(dep, info)
|
||||||
|
|
@ -360,9 +359,14 @@ proc createUpField(c: var DetectionPass; dest, dep: PSym; info: TLineInfo) =
|
||||||
if upField != nil:
|
if upField != nil:
|
||||||
if upField.typ.skipTypes({tyOwned, tyRef, tyPtr}) != fieldType.skipTypes({tyOwned, tyRef, tyPtr}):
|
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")
|
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:
|
else:
|
||||||
let result = newSym(skField, upIdent, obj.owner, obj.owner.info)
|
let result = newSym(skField, upIdent, obj.owner, obj.owner.info)
|
||||||
result.typ = fieldType
|
result.typ = fieldType
|
||||||
|
if c.graph.config.selectedGC == gcDestructors:
|
||||||
|
result.flags.incl sfCursor
|
||||||
rawAddField(obj, result)
|
rawAddField(obj, result)
|
||||||
|
|
||||||
discard """
|
discard """
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ proc fillBodyObj(c: var TLiftCtx; n, body, x, y: PNode) =
|
||||||
of nkSym:
|
of nkSym:
|
||||||
let f = n.sym
|
let f = n.sym
|
||||||
if sfCursor in f.flags and f.typ.skipTypes(abstractInst).kind in {tyRef, tyProc} and
|
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))
|
defaultOp(c, f.typ, body, x.dotField(f), y.dotField(f))
|
||||||
else:
|
else:
|
||||||
fillBody(c, f.typ, body, x.dotField(f), y.dotField(f))
|
fillBody(c, f.typ, body, x.dotField(f), y.dotField(f))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue