* fixes #13708 * differentiate between arc and rest of GC Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
parent
b6e04eafce
commit
586ebb090b
2 changed files with 20 additions and 10 deletions
|
|
@ -312,10 +312,10 @@ proc indirectAccess*(a: PNode, b: PSym, info: TLineInfo): PNode =
|
||||||
proc indirectAccess*(a, b: PSym, info: TLineInfo): PNode =
|
proc indirectAccess*(a, b: PSym, info: TLineInfo): PNode =
|
||||||
result = indirectAccess(newSymNode(a), b, info)
|
result = indirectAccess(newSymNode(a), b, info)
|
||||||
|
|
||||||
proc genAddrOf*(n: PNode): PNode =
|
proc genAddrOf*(n: PNode, typeKind = tyPtr): PNode =
|
||||||
result = newNodeI(nkAddr, n.info, 1)
|
result = newNodeI(nkAddr, n.info, 1)
|
||||||
result[0] = n
|
result[0] = n
|
||||||
result.typ = newType(tyPtr, n.typ.owner)
|
result.typ = newType(typeKind, n.typ.owner)
|
||||||
result.typ.rawAddSon(n.typ)
|
result.typ.rawAddSon(n.typ)
|
||||||
|
|
||||||
proc genDeref*(n: PNode; k = nkHiddenDeref): PNode =
|
proc genDeref*(n: PNode; k = nkHiddenDeref): PNode =
|
||||||
|
|
|
||||||
|
|
@ -65,14 +65,24 @@ proc addLocalVar(g: ModuleGraph; varSection, varInit: PNode; owner: PSym; typ: P
|
||||||
vpart[2] = if varInit.isNil: v else: vpart[1]
|
vpart[2] = if varInit.isNil: v else: vpart[1]
|
||||||
varSection.add vpart
|
varSection.add vpart
|
||||||
if varInit != nil:
|
if varInit != nil:
|
||||||
if useShallowCopy and typeNeedsNoDeepCopy(typ) or optTinyRtti in g.config.globalOptions:
|
if g.config.selectedGC in {gcArc, gcOrc}:
|
||||||
varInit.add newFastAsgnStmt(newSymNode(result), v)
|
if typ.attachedOps[attachedAsgn] != nil:
|
||||||
|
var call = newNode(nkCall)
|
||||||
|
call.add newSymNode(typ.attachedOps[attachedAsgn])
|
||||||
|
call.add genAddrOf(newSymNode(result), tyVar)
|
||||||
|
call.add v
|
||||||
|
varInit.add call
|
||||||
|
else:
|
||||||
|
varInit.add newFastAsgnStmt(newSymNode(result), v)
|
||||||
else:
|
else:
|
||||||
let deepCopyCall = newNodeI(nkCall, varInit.info, 3)
|
if useShallowCopy and typeNeedsNoDeepCopy(typ) or optTinyRtti in g.config.globalOptions:
|
||||||
deepCopyCall[0] = newSymNode(getSysMagic(g, varSection.info, "deepCopy", mDeepCopy))
|
varInit.add newFastAsgnStmt(newSymNode(result), v)
|
||||||
deepCopyCall[1] = newSymNode(result)
|
else:
|
||||||
deepCopyCall[2] = v
|
let deepCopyCall = newNodeI(nkCall, varInit.info, 3)
|
||||||
varInit.add deepCopyCall
|
deepCopyCall[0] = newSymNode(getSysMagic(g, varSection.info, "deepCopy", mDeepCopy))
|
||||||
|
deepCopyCall[1] = newSymNode(result)
|
||||||
|
deepCopyCall[2] = v
|
||||||
|
varInit.add deepCopyCall
|
||||||
|
|
||||||
discard """
|
discard """
|
||||||
We generate roughly this:
|
We generate roughly this:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue