refactoring: --newruntime consists of 3 different switches
This commit is contained in:
parent
832b0a0232
commit
61ea85687c
17 changed files with 48 additions and 41 deletions
|
|
@ -1206,7 +1206,7 @@ proc rawGenNew(p: BProc, a: TLoc, sizeExpr: Rope) =
|
||||||
if sizeExpr.isNil:
|
if sizeExpr.isNil:
|
||||||
sizeExpr = "sizeof($1)" % [getTypeDesc(p.module, bt)]
|
sizeExpr = "sizeof($1)" % [getTypeDesc(p.module, bt)]
|
||||||
|
|
||||||
if optNimV2 in p.config.globalOptions:
|
if optOwnedRefs in p.config.globalOptions:
|
||||||
b.r = ropecg(p.module, "($1) #nimNewObj($2)",
|
b.r = ropecg(p.module, "($1) #nimNewObj($2)",
|
||||||
[getTypeDesc(p.module, typ), sizeExpr])
|
[getTypeDesc(p.module, typ), sizeExpr])
|
||||||
genAssignment(p, a, b, {})
|
genAssignment(p, a, b, {})
|
||||||
|
|
@ -1484,7 +1484,7 @@ proc genNewFinalize(p: BProc, e: PNode) =
|
||||||
gcUsage(p.config, e)
|
gcUsage(p.config, e)
|
||||||
|
|
||||||
proc genOfHelper(p: BProc; dest: PType; a: Rope; info: TLineInfo): Rope =
|
proc genOfHelper(p: BProc; dest: PType; a: Rope; info: TLineInfo): Rope =
|
||||||
if optNimV2 in p.config.globalOptions:
|
if optTinyRtti in p.config.globalOptions:
|
||||||
result = ropecg(p.module, "#isObj($1.m_type, $2)",
|
result = ropecg(p.module, "#isObj($1.m_type, $2)",
|
||||||
[a, genTypeInfo2Name(p.module, dest)])
|
[a, genTypeInfo2Name(p.module, dest)])
|
||||||
else:
|
else:
|
||||||
|
|
@ -1535,7 +1535,7 @@ proc genOf(p: BProc, n: PNode, d: var TLoc) =
|
||||||
genOf(p, n.sons[1], n.sons[2].typ, d)
|
genOf(p, n.sons[1], n.sons[2].typ, d)
|
||||||
|
|
||||||
proc genRepr(p: BProc, e: PNode, d: var TLoc) =
|
proc genRepr(p: BProc, e: PNode, d: var TLoc) =
|
||||||
if optNimV2 in p.config.globalOptions:
|
if optTinyRtti in p.config.globalOptions:
|
||||||
localError(p.config, e.info, "'repr' is not available for --newruntime")
|
localError(p.config, e.info, "'repr' is not available for --newruntime")
|
||||||
var a: TLoc
|
var a: TLoc
|
||||||
initLocExpr(p, e.sons[1], a)
|
initLocExpr(p, e.sons[1], a)
|
||||||
|
|
@ -2148,7 +2148,7 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
of mCStrToStr: genDollar(p, e, d, "#cstrToNimstr($1)")
|
of mCStrToStr: genDollar(p, e, d, "#cstrToNimstr($1)")
|
||||||
of mStrToStr, mUnown: expr(p, e.sons[1], d)
|
of mStrToStr, mUnown: expr(p, e.sons[1], d)
|
||||||
of mEnumToStr:
|
of mEnumToStr:
|
||||||
if optNimV2 in p.config.globalOptions:
|
if optTinyRtti in p.config.globalOptions:
|
||||||
genEnumToStr(p, e, d)
|
genEnumToStr(p, e, d)
|
||||||
else:
|
else:
|
||||||
genRepr(p, e, d)
|
genRepr(p, e, d)
|
||||||
|
|
@ -2423,7 +2423,7 @@ proc upConv(p: BProc, n: PNode, d: var TLoc) =
|
||||||
while t.kind == tyObject and t.sons[0] != nil:
|
while t.kind == tyObject and t.sons[0] != nil:
|
||||||
add(r, ".Sup")
|
add(r, ".Sup")
|
||||||
t = skipTypes(t.sons[0], skipPtrs)
|
t = skipTypes(t.sons[0], skipPtrs)
|
||||||
let checkFor = if optNimV2 in p.config.globalOptions:
|
let checkFor = if optTinyRtti in p.config.globalOptions:
|
||||||
genTypeInfo2Name(p.module, dest)
|
genTypeInfo2Name(p.module, dest)
|
||||||
else:
|
else:
|
||||||
genTypeInfo(p.module, dest, n.info)
|
genTypeInfo(p.module, dest, n.info)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ const
|
||||||
|
|
||||||
proc getTraverseProc(p: BProc, v: PSym): Rope =
|
proc getTraverseProc(p: BProc, v: PSym): Rope =
|
||||||
if p.config.selectedGC in {gcMarkAndSweep, gcDestructors, gcV2, gcRefc} and
|
if p.config.selectedGC in {gcMarkAndSweep, gcDestructors, gcV2, gcRefc} and
|
||||||
optNimV2 notin p.config.globalOptions and
|
optOwnedRefs notin p.config.globalOptions and
|
||||||
containsGarbageCollectedRef(v.loc.t):
|
containsGarbageCollectedRef(v.loc.t):
|
||||||
# we register a specialized marked proc here; this has the advantage
|
# we register a specialized marked proc here; this has the advantage
|
||||||
# that it works out of the box for thread local storage then :-)
|
# that it works out of the box for thread local storage then :-)
|
||||||
|
|
@ -692,7 +692,7 @@ proc genRaiseStmt(p: BProc, t: PNode) =
|
||||||
[e, makeCString(typ.sym.name.s),
|
[e, makeCString(typ.sym.name.s),
|
||||||
makeCString(if p.prc != nil: p.prc.name.s else: p.module.module.name.s),
|
makeCString(if p.prc != nil: p.prc.name.s else: p.module.module.name.s),
|
||||||
quotedFilename(p.config, t.info), toLinenumber(t.info)])
|
quotedFilename(p.config, t.info), toLinenumber(t.info)])
|
||||||
if optNimV2 in p.config.globalOptions:
|
if optOwnedRefs in p.config.globalOptions:
|
||||||
lineCg(p, cpsStmts, "$1 = NIM_NIL;$n", [e])
|
lineCg(p, cpsStmts, "$1 = NIM_NIL;$n", [e])
|
||||||
else:
|
else:
|
||||||
genLineDir(p, t)
|
genLineDir(p, t)
|
||||||
|
|
@ -1057,7 +1057,7 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) =
|
||||||
for j in 0 .. blen - 2:
|
for j in 0 .. blen - 2:
|
||||||
assert(t.sons[i].sons[j].kind == nkType)
|
assert(t.sons[i].sons[j].kind == nkType)
|
||||||
if orExpr != nil: add(orExpr, "||")
|
if orExpr != nil: add(orExpr, "||")
|
||||||
let checkFor = if optNimV2 in p.config.globalOptions:
|
let checkFor = if optTinyRtti in p.config.globalOptions:
|
||||||
genTypeInfo2Name(p.module, t[i][j].typ)
|
genTypeInfo2Name(p.module, t[i][j].typ)
|
||||||
else:
|
else:
|
||||||
genTypeInfo(p.module, t[i][j].typ, t[i][j].info)
|
genTypeInfo(p.module, t[i][j].typ, t[i][j].info)
|
||||||
|
|
@ -1220,7 +1220,7 @@ proc asgnFieldDiscriminant(p: BProc, e: PNode) =
|
||||||
getTemp(p, a.t, tmp)
|
getTemp(p, a.t, tmp)
|
||||||
expr(p, e.sons[1], tmp)
|
expr(p, e.sons[1], tmp)
|
||||||
let field = dotExpr.sons[1].sym
|
let field = dotExpr.sons[1].sym
|
||||||
if optNimV2 in p.config.globalOptions:
|
if optTinyRtti in p.config.globalOptions:
|
||||||
let t = dotExpr[0].typ.skipTypes(abstractInst)
|
let t = dotExpr[0].typ.skipTypes(abstractInst)
|
||||||
var oldVal, newVal: TLoc
|
var oldVal, newVal: TLoc
|
||||||
genCaseObjDiscMapping(p, e[0], t, field, oldVal)
|
genCaseObjDiscMapping(p, e[0], t, field, oldVal)
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ proc genTraverseProc(c: TTraversalClosure, accessor: Rope, typ: PType) =
|
||||||
elif containsGarbageCollectedRef(typ.lastSon):
|
elif containsGarbageCollectedRef(typ.lastSon):
|
||||||
# destructor based seqs are themselves not traced but their data is, if
|
# destructor based seqs are themselves not traced but their data is, if
|
||||||
# they contain a GC'ed type:
|
# they contain a GC'ed type:
|
||||||
genTraverseProcSeq(c, accessor, typ)
|
lineCg(p, cpsStmts, "#nimGCvisitSeq((void*)$1, $2);$n", [accessor, c.visitorFrmt])
|
||||||
|
#genTraverseProcSeq(c, accessor, typ)
|
||||||
of tyString:
|
of tyString:
|
||||||
if tfHasAsgn notin typ.flags:
|
if tfHasAsgn notin typ.flags:
|
||||||
lineCg(p, cpsStmts, visitorFrmt, [accessor, c.visitorFrmt])
|
lineCg(p, cpsStmts, visitorFrmt, [accessor, c.visitorFrmt])
|
||||||
|
|
|
||||||
|
|
@ -1365,7 +1365,7 @@ proc genTypeInfo(m: BModule, t: PType; info: TLineInfo): Rope =
|
||||||
of tySet: genSetInfo(m, t, result, info)
|
of tySet: genSetInfo(m, t, result, info)
|
||||||
of tyEnum: genEnumInfo(m, t, result, info)
|
of tyEnum: genEnumInfo(m, t, result, info)
|
||||||
of tyObject:
|
of tyObject:
|
||||||
if optNimV2 in m.config.globalOptions:
|
if optTinyRtti in m.config.globalOptions:
|
||||||
genObjectInfoV2(m, t, origType, result, info)
|
genObjectInfoV2(m, t, origType, result, info)
|
||||||
else:
|
else:
|
||||||
genObjectInfo(m, t, origType, result, info)
|
genObjectInfo(m, t, origType, result, info)
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,7 @@ proc genObjectInit(p: BProc, section: TCProcSection, t: PType, a: TLoc,
|
||||||
s = skipTypes(s.sons[0], skipPtrs)
|
s = skipTypes(s.sons[0], skipPtrs)
|
||||||
linefmt(p, section, "$1.m_type = $2;$n", [r, genTypeInfo(p.module, t, a.lode.info)])
|
linefmt(p, section, "$1.m_type = $2;$n", [r, genTypeInfo(p.module, t, a.lode.info)])
|
||||||
of frEmbedded:
|
of frEmbedded:
|
||||||
if optNimV2 in p.config.globalOptions:
|
if optTinyRtti in p.config.globalOptions:
|
||||||
localError(p.config, p.prc.info,
|
localError(p.config, p.prc.info,
|
||||||
"complex object initialization is not supported with --newruntime")
|
"complex object initialization is not supported with --newruntime")
|
||||||
# worst case for performance:
|
# worst case for performance:
|
||||||
|
|
|
||||||
|
|
@ -758,7 +758,9 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
if pass in {passCmd2, passPP}:
|
if pass in {passCmd2, passPP}:
|
||||||
doAssert(conf != nil)
|
doAssert(conf != nil)
|
||||||
incl(conf.features, destructor)
|
incl(conf.features, destructor)
|
||||||
incl(conf.globalOptions, optNimV2)
|
incl(conf.globalOptions, optTinyRtti)
|
||||||
|
incl(conf.globalOptions, optOwnedRefs)
|
||||||
|
incl(conf.globalOptions, optSeqDestructors)
|
||||||
defineSymbol(conf.symbols, "nimV2")
|
defineSymbol(conf.symbols, "nimV2")
|
||||||
conf.selectedGC = gcDestructors
|
conf.selectedGC = gcDestructors
|
||||||
defineSymbol(conf.symbols, "gcdestructors")
|
defineSymbol(conf.symbols, "gcdestructors")
|
||||||
|
|
|
||||||
|
|
@ -486,7 +486,7 @@ proc p(n: PNode; c: var Con): PNode =
|
||||||
result.add n[0]
|
result.add n[0]
|
||||||
result.add p(n[1], c)
|
result.add p(n[1], c)
|
||||||
of nkRaiseStmt:
|
of nkRaiseStmt:
|
||||||
if optNimV2 in c.graph.config.globalOptions and n[0].kind != nkEmpty:
|
if optOwnedRefs in c.graph.config.globalOptions and n[0].kind != nkEmpty:
|
||||||
if n[0].kind in nkCallKinds:
|
if n[0].kind in nkCallKinds:
|
||||||
let call = p(n[0], c)
|
let call = p(n[0], c)
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ proc liftIterSym*(g: ModuleGraph; n: PNode; owner: PSym): PNode =
|
||||||
result.add(v)
|
result.add(v)
|
||||||
# add 'new' statement:
|
# add 'new' statement:
|
||||||
result.add newCall(getSysSym(g, n.info, "internalNew"), env)
|
result.add newCall(getSysSym(g, n.info, "internalNew"), env)
|
||||||
if optNimV2 in g.config.globalOptions:
|
if optOwnedRefs in g.config.globalOptions:
|
||||||
createTypeBoundOps(g, nil, env.typ, n.info)
|
createTypeBoundOps(g, nil, env.typ, n.info)
|
||||||
result.add makeClosure(g, iter, env, n.info)
|
result.add makeClosure(g, iter, env, n.info)
|
||||||
|
|
||||||
|
|
@ -323,7 +323,7 @@ proc getEnvTypeForOwner(c: var DetectionPass; owner: PSym;
|
||||||
c.ownerToType[owner.id] = result
|
c.ownerToType[owner.id] = result
|
||||||
|
|
||||||
proc asOwnedRef(c: DetectionPass; t: PType): PType =
|
proc asOwnedRef(c: DetectionPass; t: PType): PType =
|
||||||
if optNimV2 in c.graph.config.globalOptions:
|
if optOwnedRefs in c.graph.config.globalOptions:
|
||||||
assert t.kind == tyRef
|
assert t.kind == tyRef
|
||||||
result = newType(tyOwned, t.owner)
|
result = newType(tyOwned, t.owner)
|
||||||
result.flags.incl tfHasOwned
|
result.flags.incl tfHasOwned
|
||||||
|
|
@ -542,7 +542,7 @@ proc setupEnvVar(owner: PSym; d: DetectionPass;
|
||||||
localError d.graph.config, owner.info, "internal error: could not determine closure type"
|
localError d.graph.config, owner.info, "internal error: could not determine closure type"
|
||||||
result = newEnvVar(d.graph.cache, owner, asOwnedRef(d, envVarType), info)
|
result = newEnvVar(d.graph.cache, owner, asOwnedRef(d, envVarType), info)
|
||||||
c.envVars[owner.id] = result
|
c.envVars[owner.id] = result
|
||||||
if optNimV2 in d.graph.config.globalOptions:
|
if optOwnedRefs in d.graph.config.globalOptions:
|
||||||
var v = newSym(skVar, getIdent(d.graph.cache, envName & "Alt"), owner, info)
|
var v = newSym(skVar, getIdent(d.graph.cache, envName & "Alt"), owner, info)
|
||||||
v.flags = {sfShadowed, sfGeneratedOp}
|
v.flags = {sfShadowed, sfGeneratedOp}
|
||||||
v.typ = envVarType
|
v.typ = envVarType
|
||||||
|
|
@ -572,14 +572,14 @@ proc rawClosureCreation(owner: PSym;
|
||||||
var v = newNodeI(nkVarSection, env.info)
|
var v = newNodeI(nkVarSection, env.info)
|
||||||
addVar(v, env)
|
addVar(v, env)
|
||||||
result.add(v)
|
result.add(v)
|
||||||
if optNimV2 in d.graph.config.globalOptions:
|
if optOwnedRefs in d.graph.config.globalOptions:
|
||||||
let unowned = c.unownedEnvVars[owner.id]
|
let unowned = c.unownedEnvVars[owner.id]
|
||||||
assert unowned != nil
|
assert unowned != nil
|
||||||
addVar(v, unowned)
|
addVar(v, unowned)
|
||||||
|
|
||||||
# add 'new' statement:
|
# add 'new' statement:
|
||||||
result.add(newCall(getSysSym(d.graph, env.info, "internalNew"), env))
|
result.add(newCall(getSysSym(d.graph, env.info, "internalNew"), env))
|
||||||
if optNimV2 in d.graph.config.globalOptions:
|
if optOwnedRefs in d.graph.config.globalOptions:
|
||||||
let unowned = c.unownedEnvVars[owner.id]
|
let unowned = c.unownedEnvVars[owner.id]
|
||||||
assert unowned != nil
|
assert unowned != nil
|
||||||
let env2 = copyTree(env)
|
let env2 = copyTree(env)
|
||||||
|
|
@ -608,12 +608,12 @@ proc rawClosureCreation(owner: PSym;
|
||||||
localError(d.graph.config, env.info, "internal error: cannot create up reference")
|
localError(d.graph.config, env.info, "internal error: cannot create up reference")
|
||||||
# we are not in the sem'check phase anymore! so pass 'nil' for the PContext
|
# we are not in the sem'check phase anymore! so pass 'nil' for the PContext
|
||||||
# and hope for the best:
|
# and hope for the best:
|
||||||
if optNimV2 in d.graph.config.globalOptions:
|
if optOwnedRefs in d.graph.config.globalOptions:
|
||||||
createTypeBoundOps(d.graph, nil, env.typ, owner.info)
|
createTypeBoundOps(d.graph, nil, env.typ, owner.info)
|
||||||
|
|
||||||
proc finishClosureCreation(owner: PSym; d: DetectionPass; c: LiftingPass;
|
proc finishClosureCreation(owner: PSym; d: DetectionPass; c: LiftingPass;
|
||||||
info: TLineInfo; res: PNode) =
|
info: TLineInfo; res: PNode) =
|
||||||
if optNimV2 in d.graph.config.globalOptions:
|
if optOwnedRefs in d.graph.config.globalOptions:
|
||||||
let unowned = c.unownedEnvVars[owner.id]
|
let unowned = c.unownedEnvVars[owner.id]
|
||||||
assert unowned != nil
|
assert unowned != nil
|
||||||
let nilLit = newNodeIT(nkNilLit, info, unowned.typ)
|
let nilLit = newNodeIT(nkNilLit, info, unowned.typ)
|
||||||
|
|
@ -637,7 +637,7 @@ proc closureCreationForIter(iter: PNode;
|
||||||
addVar(vs, vnode)
|
addVar(vs, vnode)
|
||||||
result.add(vs)
|
result.add(vs)
|
||||||
result.add(newCall(getSysSym(d.graph, iter.info, "internalNew"), vnode))
|
result.add(newCall(getSysSym(d.graph, iter.info, "internalNew"), vnode))
|
||||||
if optNimV2 in d.graph.config.globalOptions:
|
if optOwnedRefs in d.graph.config.globalOptions:
|
||||||
createTypeBoundOps(d.graph, nil, vnode.typ, iter.info)
|
createTypeBoundOps(d.graph, nil, vnode.typ, iter.info)
|
||||||
|
|
||||||
let upField = lookupInRecord(v.typ.skipTypes({tyOwned, tyRef}).n, getIdent(d.graph.cache, upName))
|
let upField = lookupInRecord(v.typ.skipTypes({tyOwned, tyRef}).n, getIdent(d.graph.cache, upName))
|
||||||
|
|
@ -653,7 +653,7 @@ proc closureCreationForIter(iter: PNode;
|
||||||
proc accessViaEnvVar(n: PNode; owner: PSym; d: DetectionPass;
|
proc accessViaEnvVar(n: PNode; owner: PSym; d: DetectionPass;
|
||||||
c: var LiftingPass): PNode =
|
c: var LiftingPass): PNode =
|
||||||
var access = setupEnvVar(owner, d, c, n.info)
|
var access = setupEnvVar(owner, d, c, n.info)
|
||||||
if optNimV2 in d.graph.config.globalOptions:
|
if optOwnedRefs in d.graph.config.globalOptions:
|
||||||
access = c.unownedEnvVars[owner.id]
|
access = c.unownedEnvVars[owner.id]
|
||||||
let obj = access.typ.skipTypes({tyOwned, tyRef})
|
let obj = access.typ.skipTypes({tyOwned, tyRef})
|
||||||
let field = getFieldFromObj(obj, n.sym)
|
let field = getFieldFromObj(obj, n.sym)
|
||||||
|
|
@ -923,7 +923,7 @@ proc liftForLoop*(g: ModuleGraph; body: PNode; owner: PSym): PNode =
|
||||||
result.add(v)
|
result.add(v)
|
||||||
# add 'new' statement:
|
# add 'new' statement:
|
||||||
result.add(newCall(getSysSym(g, env.info, "internalNew"), env.newSymNode))
|
result.add(newCall(getSysSym(g, env.info, "internalNew"), env.newSymNode))
|
||||||
if optNimV2 in g.config.globalOptions:
|
if optOwnedRefs in g.config.globalOptions:
|
||||||
createTypeBoundOps(g, nil, env.typ, body.info)
|
createTypeBoundOps(g, nil, env.typ, body.info)
|
||||||
|
|
||||||
elif op.kind == nkStmtListExpr:
|
elif op.kind == nkStmtListExpr:
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@ proc closureOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
call.sons[0] = newSymNode(createMagic(c.g, "deepCopy", mDeepCopy))
|
call.sons[0] = newSymNode(createMagic(c.g, "deepCopy", mDeepCopy))
|
||||||
call.sons[1] = y
|
call.sons[1] = y
|
||||||
body.add newAsgnStmt(x, call)
|
body.add newAsgnStmt(x, call)
|
||||||
elif optNimV2 in c.g.config.globalOptions and
|
elif optOwnedRefs in c.g.config.globalOptions and
|
||||||
optRefCheck in c.g.config.options:
|
optRefCheck in c.g.config.options:
|
||||||
let xx = genBuiltin(c.g, mAccessEnv, "accessEnv", x)
|
let xx = genBuiltin(c.g, mAccessEnv, "accessEnv", x)
|
||||||
xx.typ = getSysType(c.g, c.info, tyPointer)
|
xx.typ = getSysType(c.g, c.info, tyPointer)
|
||||||
|
|
@ -457,7 +457,7 @@ proc fillBody(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
tyPtr, tyOpt, tyUncheckedArray:
|
tyPtr, tyOpt, tyUncheckedArray:
|
||||||
defaultOp(c, t, body, x, y)
|
defaultOp(c, t, body, x, y)
|
||||||
of tyRef:
|
of tyRef:
|
||||||
if optNimV2 in c.g.config.globalOptions and
|
if optOwnedRefs in c.g.config.globalOptions and
|
||||||
optRefCheck in c.g.config.options:
|
optRefCheck in c.g.config.options:
|
||||||
weakrefOp(c, t, body, x, y)
|
weakrefOp(c, t, body, x, y)
|
||||||
else:
|
else:
|
||||||
|
|
@ -469,7 +469,7 @@ proc fillBody(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
defaultOp(c, t, body, x, y)
|
defaultOp(c, t, body, x, y)
|
||||||
of tyOwned:
|
of tyOwned:
|
||||||
let base = t.skipTypes(abstractInstOwned)
|
let base = t.skipTypes(abstractInstOwned)
|
||||||
if optNimV2 in c.g.config.globalOptions:
|
if optOwnedRefs in c.g.config.globalOptions:
|
||||||
case base.kind
|
case base.kind
|
||||||
of tyRef:
|
of tyRef:
|
||||||
ownedRefOp(c, base, body, x, y)
|
ownedRefOp(c, base, body, x, y)
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,11 @@ type # please make sure we have under 32 options
|
||||||
optNoNimblePath
|
optNoNimblePath
|
||||||
optHotCodeReloading
|
optHotCodeReloading
|
||||||
optDynlibOverrideAll
|
optDynlibOverrideAll
|
||||||
optNimV2
|
optSeqDestructors # active if the implementation uses the new
|
||||||
|
# string/seq implementation based on destructors
|
||||||
|
optTinyRtti # active if we use the new "tiny RTTI"
|
||||||
|
# implementation
|
||||||
|
optOwnedRefs # active if the Nim compiler knows about 'owned'.
|
||||||
optMultiMethods
|
optMultiMethods
|
||||||
optNimV019
|
optNimV019
|
||||||
optBenchmarkVM # Enables cpuTime() in the VM
|
optBenchmarkVM # Enables cpuTime() in the VM
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
||||||
let oldGlobalOptions = conf.globalOptions
|
let oldGlobalOptions = conf.globalOptions
|
||||||
let oldSelectedGC = conf.selectedGC
|
let oldSelectedGC = conf.selectedGC
|
||||||
undefSymbol(conf.symbols, "nimv2")
|
undefSymbol(conf.symbols, "nimv2")
|
||||||
conf.globalOptions.excl optNimV2
|
conf.globalOptions.excl {optTinyRtti, optOwnedRefs, optSeqDestructors}
|
||||||
conf.selectedGC = gcUnselected
|
conf.selectedGC = gcUnselected
|
||||||
|
|
||||||
var m = graph.makeModule(scriptName)
|
var m = graph.makeModule(scriptName)
|
||||||
|
|
@ -229,8 +229,8 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
||||||
|
|
||||||
# watch out, "newruntime" can be set within NimScript itself and then we need
|
# watch out, "newruntime" can be set within NimScript itself and then we need
|
||||||
# to remember this:
|
# to remember this:
|
||||||
if optNimV2 in oldGlobalOptions:
|
if optOwnedRefs in oldGlobalOptions:
|
||||||
conf.globalOptions.incl optNimV2
|
conf.globalOptions.incl {optTinyRtti, optOwnedRefs, optSeqDestructors}
|
||||||
defineSymbol(conf.symbols, "nimv2")
|
defineSymbol(conf.symbols, "nimv2")
|
||||||
if conf.selectedGC == gcUnselected:
|
if conf.selectedGC == gcUnselected:
|
||||||
conf.selectedGC = oldSelectedGC
|
conf.selectedGC = oldSelectedGC
|
||||||
|
|
|
||||||
|
|
@ -2563,7 +2563,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
# if isGenericRoutine(result.sym):
|
# if isGenericRoutine(result.sym):
|
||||||
# localError(c.config, n.info, errInstantiateXExplicitly, s.name.s)
|
# localError(c.config, n.info, errInstantiateXExplicitly, s.name.s)
|
||||||
# "procs literals" are 'owned'
|
# "procs literals" are 'owned'
|
||||||
if optNimV2 in c.config.globalOptions:
|
if optOwnedRefs in c.config.globalOptions:
|
||||||
result.typ = makeVarType(c, result.typ, tyOwned)
|
result.typ = makeVarType(c, result.typ, tyOwned)
|
||||||
else:
|
else:
|
||||||
result = semSym(c, n, s, flags)
|
result = semSym(c, n, s, flags)
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,7 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
t = skipTypes(t, {tyGenericInst, tyAlias, tySink, tyOwned})
|
t = skipTypes(t, {tyGenericInst, tyAlias, tySink, tyOwned})
|
||||||
if t.kind == tyRef:
|
if t.kind == tyRef:
|
||||||
t = skipTypes(t.sons[0], {tyGenericInst, tyAlias, tySink, tyOwned})
|
t = skipTypes(t.sons[0], {tyGenericInst, tyAlias, tySink, tyOwned})
|
||||||
if optNimV2 in c.config.globalOptions:
|
if optOwnedRefs in c.config.globalOptions:
|
||||||
result.typ = makeVarType(c, result.typ, tyOwned)
|
result.typ = makeVarType(c, result.typ, tyOwned)
|
||||||
# we have to watch out, there are also 'owned proc' types that can be used
|
# we have to watch out, there are also 'owned proc' types that can be used
|
||||||
# multiple times as long as they don't have closures.
|
# multiple times as long as they don't have closures.
|
||||||
|
|
|
||||||
|
|
@ -1519,7 +1519,7 @@ proc semLambda(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
closeScope(c) # close scope for parameters
|
closeScope(c) # close scope for parameters
|
||||||
popOwner(c)
|
popOwner(c)
|
||||||
result.typ = s.typ
|
result.typ = s.typ
|
||||||
if optNimV2 in c.config.globalOptions:
|
if optOwnedRefs in c.config.globalOptions:
|
||||||
result.typ = makeVarType(c, result.typ, tyOwned)
|
result.typ = makeVarType(c, result.typ, tyOwned)
|
||||||
|
|
||||||
proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode =
|
proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode =
|
||||||
|
|
@ -1556,7 +1556,7 @@ proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode =
|
||||||
popProcCon(c)
|
popProcCon(c)
|
||||||
popOwner(c)
|
popOwner(c)
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
if optNimV2 in c.config.globalOptions and result.typ != nil:
|
if optOwnedRefs in c.config.globalOptions and result.typ != nil:
|
||||||
result.typ = makeVarType(c, result.typ, tyOwned)
|
result.typ = makeVarType(c, result.typ, tyOwned)
|
||||||
# alternative variant (not quite working):
|
# alternative variant (not quite working):
|
||||||
# var prc = arg[0].sym
|
# var prc = arg[0].sym
|
||||||
|
|
@ -1948,7 +1948,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
||||||
if isAnon:
|
if isAnon:
|
||||||
n.kind = nkLambda
|
n.kind = nkLambda
|
||||||
result.typ = s.typ
|
result.typ = s.typ
|
||||||
if optNimV2 in c.config.globalOptions:
|
if optOwnedRefs in c.config.globalOptions:
|
||||||
result.typ = makeVarType(c, result.typ, tyOwned)
|
result.typ = makeVarType(c, result.typ, tyOwned)
|
||||||
if isTopLevel(c) and s.kind != skIterator and
|
if isTopLevel(c) and s.kind != skIterator and
|
||||||
s.typ.callConv == ccClosure:
|
s.typ.callConv == ccClosure:
|
||||||
|
|
|
||||||
|
|
@ -877,7 +877,7 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
||||||
if tfPartial in result.flags:
|
if tfPartial in result.flags:
|
||||||
if result.lastSon.kind == tyObject: incl(result.lastSon.flags, tfPartial)
|
if result.lastSon.kind == tyObject: incl(result.lastSon.flags, tfPartial)
|
||||||
#if not isNilable: result.flags.incl tfNotNil
|
#if not isNilable: result.flags.incl tfNotNil
|
||||||
if isOwned and optNimV2 in c.config.globalOptions:
|
if isOwned and optOwnedRefs in c.config.globalOptions:
|
||||||
let t = newTypeS(tyOwned, c)
|
let t = newTypeS(tyOwned, c)
|
||||||
t.flags.incl tfHasOwned
|
t.flags.incl tfHasOwned
|
||||||
t.rawAddSonNoPropagationOfTypeFlags result
|
t.rawAddSonNoPropagationOfTypeFlags result
|
||||||
|
|
@ -1644,7 +1644,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||||
result = semTypeof(c, n[1], prev)
|
result = semTypeof(c, n[1], prev)
|
||||||
elif op.s == "typeof" and n[0].kind == nkSym and n[0].sym.magic == mTypeOf:
|
elif op.s == "typeof" and n[0].kind == nkSym and n[0].sym.magic == mTypeOf:
|
||||||
result = semTypeof2(c, n, prev)
|
result = semTypeof2(c, n, prev)
|
||||||
elif op.s == "owned" and optNimV2 notin c.config.globalOptions and n.len == 2:
|
elif op.s == "owned" and optOwnedRefs notin c.config.globalOptions and n.len == 2:
|
||||||
result = semTypeExpr(c, n[1], prev)
|
result = semTypeExpr(c, n[1], prev)
|
||||||
else:
|
else:
|
||||||
if c.inGenericContext > 0 and n.kind == nkCall:
|
if c.inGenericContext > 0 and n.kind == nkCall:
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ proc addLocalVar(g: ModuleGraph; varSection, varInit: PNode; owner: PSym; typ: P
|
||||||
vpart.sons[2] = if varInit.isNil: v else: vpart[1]
|
vpart.sons[2] = if varInit.isNil: v else: vpart[1]
|
||||||
varSection.add vpart
|
varSection.add vpart
|
||||||
if varInit != nil:
|
if varInit != nil:
|
||||||
if useShallowCopy and typeNeedsNoDeepCopy(typ) or optNimV2 in g.config.globalOptions:
|
if useShallowCopy and typeNeedsNoDeepCopy(typ) or optTinyRtti in g.config.globalOptions:
|
||||||
varInit.add newFastAsgnStmt(newSymNode(result), v)
|
varInit.add newFastAsgnStmt(newSymNode(result), v)
|
||||||
else:
|
else:
|
||||||
let deepCopyCall = newNodeI(nkCall, varInit.info, 3)
|
let deepCopyCall = newNodeI(nkCall, varInit.info, 3)
|
||||||
|
|
|
||||||
|
|
@ -914,7 +914,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
|
||||||
oldDeferAnchor = c.deferAnchor
|
oldDeferAnchor = c.deferAnchor
|
||||||
c.deferAnchor = n
|
c.deferAnchor = n
|
||||||
if (n.typ != nil and tfHasAsgn in n.typ.flags) or
|
if (n.typ != nil and tfHasAsgn in n.typ.flags) or
|
||||||
optNimV2 in c.graph.config.globalOptions:
|
optSeqDestructors in c.graph.config.globalOptions:
|
||||||
c.needsDestroyPass = true
|
c.needsDestroyPass = true
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkSym:
|
of nkSym:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue