enable destructors without the --newruntime switch
This commit is contained in:
parent
db35ac435b
commit
04b3f8f24a
3 changed files with 4 additions and 16 deletions
|
|
@ -101,10 +101,7 @@ proc newOpCall(op: PSym; x: PNode): PNode =
|
||||||
proc destructorCall(c: PContext; op: PSym; x: PNode): PNode =
|
proc destructorCall(c: PContext; op: PSym; x: PNode): PNode =
|
||||||
result = newNodeIT(nkCall, x.info, op.typ.sons[0])
|
result = newNodeIT(nkCall, x.info, op.typ.sons[0])
|
||||||
result.add(newSymNode(op))
|
result.add(newSymNode(op))
|
||||||
if destructor in c.features:
|
|
||||||
result.add genAddr(c, x)
|
result.add genAddr(c, x)
|
||||||
else:
|
|
||||||
result.add x
|
|
||||||
|
|
||||||
proc newDeepCopyCall(op: PSym; x, y: PNode): PNode =
|
proc newDeepCopyCall(op: PSym; x, y: PNode): PNode =
|
||||||
result = newAsgnStmt(x, newOpCall(op, y))
|
result = newAsgnStmt(x, newOpCall(op, y))
|
||||||
|
|
@ -319,7 +316,7 @@ proc liftTypeBoundOps*(c: PContext; typ: PType; info: TLineInfo) =
|
||||||
## In the semantic pass this is called in strategic places
|
## In the semantic pass this is called in strategic places
|
||||||
## to ensure we lift assignment, destructors and moves properly.
|
## to ensure we lift assignment, destructors and moves properly.
|
||||||
## The later 'destroyer' pass depends on it.
|
## The later 'destroyer' pass depends on it.
|
||||||
if destructor notin c.features or not hasDestructor(typ): return
|
if not hasDestructor(typ): return
|
||||||
when false:
|
when false:
|
||||||
# do not produce wrong liftings while we're still instantiating generics:
|
# do not produce wrong liftings while we're still instantiating generics:
|
||||||
# now disabled; breaks topttree.nim!
|
# now disabled; breaks topttree.nim!
|
||||||
|
|
|
||||||
|
|
@ -1556,11 +1556,6 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
|
||||||
typeMismatch(c.config, n.info, lhs.typ, rhsTyp)
|
typeMismatch(c.config, n.info, lhs.typ, rhsTyp)
|
||||||
|
|
||||||
n.sons[1] = fitNode(c, le, rhs, n.info)
|
n.sons[1] = fitNode(c, le, rhs, n.info)
|
||||||
if destructor notin c.features:
|
|
||||||
if tfHasAsgn in lhs.typ.flags and not lhsIsResult and
|
|
||||||
mode != noOverloadedAsgn:
|
|
||||||
return overloadedAsgn(c, lhs, n.sons[1])
|
|
||||||
else:
|
|
||||||
liftTypeBoundOps(c, lhs.typ, lhs.info)
|
liftTypeBoundOps(c, lhs.typ, lhs.info)
|
||||||
|
|
||||||
fixAbstractType(c, n)
|
fixAbstractType(c, n)
|
||||||
|
|
|
||||||
|
|
@ -369,10 +369,7 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
assert newbody.kind in {tyRef, tyPtr}
|
assert newbody.kind in {tyRef, tyPtr}
|
||||||
assert newbody.lastSon.typeInst == nil
|
assert newbody.lastSon.typeInst == nil
|
||||||
newbody.lastSon.typeInst = result
|
newbody.lastSon.typeInst = result
|
||||||
if destructor in cl.c.features:
|
|
||||||
cl.c.typesWithOps.add((newbody, result))
|
cl.c.typesWithOps.add((newbody, result))
|
||||||
else:
|
|
||||||
typeBound(cl.c, newbody, result, assignment, cl.info)
|
|
||||||
let methods = skipTypes(bbody, abstractPtrs).methods
|
let methods = skipTypes(bbody, abstractPtrs).methods
|
||||||
for col, meth in items(methods):
|
for col, meth in items(methods):
|
||||||
# we instantiate the known methods belonging to that type, this causes
|
# we instantiate the known methods belonging to that type, this causes
|
||||||
|
|
@ -546,7 +543,6 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
proc instAllTypeBoundOp*(c: PContext, info: TLineInfo) =
|
proc instAllTypeBoundOp*(c: PContext, info: TLineInfo) =
|
||||||
if destructor notin c.features: return
|
|
||||||
var i = 0
|
var i = 0
|
||||||
while i < c.typesWithOps.len:
|
while i < c.typesWithOps.len:
|
||||||
let (newty, oldty) = c.typesWithOps[i]
|
let (newty, oldty) = c.typesWithOps[i]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue