newruntime: refchecks:on|off switch

This commit is contained in:
Araq 2019-07-12 21:05:33 +02:00
commit 423e8cca91
5 changed files with 14 additions and 6 deletions

View file

@ -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)