summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-07-12 21:05:33 +0200
committerAraq <rumpf_a@web.de>2019-07-12 21:53:46 +0200
commit423e8cca91d06983fd0bd65419c00a6ae6da2d80 (patch)
tree9e0e56b41bb21df037ed797acfb192a8aef1106e /compiler
parent416ba133ad1e62cc8ce7241c85e89d5707b5736f (diff)
downloadNim-423e8cca91d06983fd0bd65419c00a6ae6da2d80.tar.gz
newruntime: refchecks:on|off switch
Diffstat (limited to 'compiler')
-rw-r--r--compiler/commands.nim2
-rw-r--r--compiler/injectdestructors.nim2
-rw-r--r--compiler/liftdestructors.nim6
-rw-r--r--compiler/options.nim6
-rw-r--r--compiler/pragmas.nim4
5 files changed, 14 insertions, 6 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim
index d0f7cc7eb..ff76fff71 100644
--- a/compiler/commands.nim
+++ b/compiler/commands.nim
@@ -276,6 +276,7 @@ proc testCompileOption*(conf: ConfigRef; switch: string, info: TLineInfo): bool
   of "fieldchecks": result = contains(conf.options, optFieldCheck)
   of "rangechecks": result = contains(conf.options, optRangeCheck)
   of "boundchecks": result = contains(conf.options, optBoundsCheck)
+  of "refchecks": result = contains(conf.options, optRefCheck)
   of "overflowchecks": result = contains(conf.options, optOverflowCheck)
   of "stylechecks": result = contains(conf.options, optStyleCheck)
   of "linedir": result = contains(conf.options, optLineDir)
@@ -530,6 +531,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
   of "fieldchecks": processOnOffSwitch(conf, {optFieldCheck}, arg, pass, info)
   of "rangechecks": processOnOffSwitch(conf, {optRangeCheck}, arg, pass, info)
   of "boundchecks": processOnOffSwitch(conf, {optBoundsCheck}, arg, pass, info)
+  of "refchecks": processOnOffSwitch(conf, {optRefCheck}, arg, pass, info)
   of "overflowchecks": processOnOffSwitch(conf, {optOverflowCheck}, arg, pass, info)
   of "stylechecks": processOnOffSwitch(conf, {optStyleCheck}, arg, pass, info)
   of "linedir": processOnOffSwitch(conf, {optLineDir}, arg, pass, info)
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim
index 7c4e7f62b..2f883a8b3 100644
--- a/compiler/injectdestructors.nim
+++ b/compiler/injectdestructors.nim
@@ -154,7 +154,7 @@ type
     uninit: IntSet # set of uninit'ed vars
     uninitComputed: bool
 
-const toDebug = "" # "server_continue"
+const toDebug = "" # "serverNimAsyncContinue"
 
 template dbg(body) =
   when toDebug.len > 0:
diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim
index e9be2ed18..97c2636ac 100644
--- a/compiler/liftdestructors.nim
+++ b/compiler/liftdestructors.nim
@@ -403,7 +403,8 @@ proc closureOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
     call.sons[0] = newSymNode(createMagic(c.g, "deepCopy", mDeepCopy))
     call.sons[1] = y
     body.add newAsgnStmt(x, call)
-  elif optNimV2 in c.g.config.globalOptions:
+  elif optNimV2 in c.g.config.globalOptions and
+      optRefCheck in c.g.config.options:
     let xx = genBuiltin(c.g, mAccessEnv, "accessEnv", x)
     xx.typ = getSysType(c.g, c.info, tyPointer)
     case c.kind
@@ -448,7 +449,8 @@ proc fillBody(c: var TLiftCtx; t: PType; body, x, y: PNode) =
       tyPtr, tyOpt, tyUncheckedArray:
     defaultOp(c, t, body, x, y)
   of tyRef:
-    if optNimV2 in c.g.config.globalOptions:
+    if optNimV2 in c.g.config.globalOptions and
+        optRefCheck in c.g.config.options:
       weakrefOp(c, t, body, x, y)
     else:
       defaultOp(c, t, body, x, y)
diff --git a/compiler/options.nim b/compiler/options.nim
index 9688bdf73..7b391f4e9 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -25,7 +25,7 @@ type                          # please make sure we have under 32 options
                               # (improves code efficiency a lot!)
   TOption* = enum             # **keep binary compatible**
     optNone, optObjCheck, optFieldCheck, optRangeCheck, optBoundsCheck,
-    optOverflowCheck, optNilCheck,
+    optOverflowCheck, optNilCheck, optRefCheck,
     optNaNCheck, optInfCheck, optStyleCheck,
     optAssert, optLineDir, optWarns, optHints,
     optOptimizeSpeed, optOptimizeSize, optStackTrace, # stack tracing support
@@ -270,10 +270,10 @@ const oldExperimentalFeatures* = {implicitDeref, dotOperators, callOperator, par
 const
   ChecksOptions* = {optObjCheck, optFieldCheck, optRangeCheck, optNilCheck,
     optOverflowCheck, optBoundsCheck, optAssert, optNaNCheck, optInfCheck,
-    optStyleCheck}
+    optStyleCheck, optRefCheck}
 
   DefaultOptions* = {optObjCheck, optFieldCheck, optRangeCheck,
-    optBoundsCheck, optOverflowCheck, optAssert, optWarns,
+    optBoundsCheck, optOverflowCheck, optAssert, optWarns, optRefCheck,
     optHints, optStackTrace, optLineTrace,
     optTrMacros, optNilCheck, optStyleCheck}
   DefaultGlobalOptions* = {optThreadAnalysis,
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim
index 938881842..9e3976e73 100644
--- a/compiler/pragmas.nim
+++ b/compiler/pragmas.nim
@@ -434,6 +434,8 @@ proc processPush(c: PContext, n: PNode, start: int) =
   # If stacktrace is disabled globally we should not enable it
   if optStackTrace notin c.optionStack[0].options:
     c.config.options.excl(optStackTrace)
+  when defined(debugOptions):
+    echo c.config $ n.info, " PUSH config is now ", c.config.options
 
 proc processPop(c: PContext, n: PNode) =
   if c.optionStack.len <= 1:
@@ -443,6 +445,8 @@ proc processPop(c: PContext, n: PNode) =
     c.config.notes = c.optionStack[^1].notes
     c.features = c.optionStack[^1].features
     c.optionStack.setLen(c.optionStack.len - 1)
+  when defined(debugOptions):
+    echo c.config $ n.info, " POP config is now ", c.config.options
 
 proc processDefine(c: PContext, n: PNode) =
   if (n.kind in nkPragmaCallKinds and n.len == 2) and (n[1].kind == nkIdent):