From 6e6a9a721fc039c88851650e4ab989aeff04fc9f Mon Sep 17 00:00:00 2001 From: Araq Date: Sat, 6 Apr 2019 17:32:33 +0200 Subject: [PATCH] destructors: we are cooking now --- compiler/ast.nim | 3 +++ compiler/commands.nim | 13 ++++++------ compiler/injectdestructors.nim | 18 ++++++++++++++-- compiler/liftdestructors.nim | 14 +++++++----- compiler/transf.nim | 2 ++ lib/core/runtime_v2.nim | 8 ------- lib/core/strs.nim | 20 ++++++++--------- lib/system.nim | 33 +++++++++++++++++++++-------- tests/destructor/tgcdestructors.nim | 5 +++-- 9 files changed, 73 insertions(+), 43 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index a21d9f7389..0aeb94bb5a 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1808,3 +1808,6 @@ template getBody*(s: PSym): PNode = s.ast[bodyPos] template detailedInfo*(sym: PSym): string = sym.name.s + +proc isInlineIterator*(s: PSym): bool {.inline.} = + s.kind == skIterator and s.typ.callConv != ccClosure diff --git a/compiler/commands.nim b/compiler/commands.nim index 0c574a0794..6935e7747f 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -745,12 +745,13 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; conf.cppDefine(arg) of "newruntime": expectNoArg(conf, switch, arg, pass, info) - doAssert(conf != nil) - incl(conf.features, destructor) - incl(conf.globalOptions, optNimV2) - defineSymbol(conf.symbols, "nimV2") - conf.selectedGC = gcDestructors - defineSymbol(conf.symbols, "gcdestructors") + if pass in {passCmd2, passPP}: + doAssert(conf != nil) + incl(conf.features, destructor) + incl(conf.globalOptions, optNimV2) + defineSymbol(conf.symbols, "nimV2") + conf.selectedGC = gcDestructors + defineSymbol(conf.symbols, "gcdestructors") of "stylecheck": case arg.normalize of "off": conf.globalOptions = conf.globalOptions - {optStyleHint, optStyleError} diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index f1bda866b1..350fd9c8d2 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -456,7 +456,7 @@ proc pArg(arg: PNode; c: var Con; isSink: bool): PNode = result.add arg[0] for i in 1..