introduce --newruntime switch for the upcoming destructors and move semantics

This commit is contained in:
Andreas Rumpf 2017-10-13 06:38:59 +02:00
commit 63530be0b8
6 changed files with 19 additions and 11 deletions

View file

@ -100,7 +100,7 @@ proc semProc(c: PContext, n: PNode): PNode
include semdestruct
proc semDestructorCheck(c: PContext, n: PNode, flags: TExprFlags) {.inline.} =
when not newDestructors:
if not newDestructors:
if efAllowDestructor notin flags and
n.kind in nkCallKinds+{nkObjConstr,nkBracket}:
if instantiateDestructor(c, n.typ) != nil:
@ -608,7 +608,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
if def.kind == nkPar: v.ast = def[j]
setVarType(v, tup.sons[j])
b.sons[j] = newSymNode(v)
when not newDestructors: addDefer(c, result, v)
if not newDestructors: addDefer(c, result, v)
checkNilable(v)
if sfCompileTime in v.flags: hasCompileTime = true
if hasCompileTime: vm.setupCompileTimeVar(c.module, c.cache, result)
@ -1278,9 +1278,8 @@ proc semOverride(c: PContext, s: PSym, n: PNode) =
case s.name.s.normalize
of "destroy", "=destroy":
doDestructorStuff(c, s, n)
when not newDestructors:
if not experimentalMode(c):
localError n.info, "use the {.experimental.} pragma to enable destructors"
if not newDestructors and not experimentalMode(c):
localError n.info, "use the {.experimental.} pragma to enable destructors"
incl(s.flags, sfUsed)
of "deepcopy", "=deepcopy":
if s.typ.len == 2 and