make case-object transitions explicit, make unknownLineInfo a const, replace a few magic numbers with consts (#13170)

This commit is contained in:
Jasper Jenkins 2020-01-17 01:34:32 -08:00 • committed by Andreas Rumpf
commit 796aafe7e0
35 changed files with 182 additions and 203 deletions

View file

@ -1020,6 +1020,10 @@ const
skProcKinds* = {skProc, skFunc, skTemplate, skMacro, skIterator, skProcKinds* = {skProc, skFunc, skTemplate, skMacro, skIterator,
skMethod, skConverter} skMethod, skConverter}
defaultSize = -1
defaultAlignment = -1
defaultOffset = -1
var ggDebug* {.deprecated.}: bool ## convenience switch for trying out things var ggDebug* {.deprecated.}: bool ## convenience switch for trying out things
#var #var
# gMainPackageId*: int # gMainPackageId*: int
@ -1066,12 +1070,7 @@ when defined(useNodeIds):
var gNodeId: int var gNodeId: int
proc newNode*(kind: TNodeKind): PNode = proc newNode*(kind: TNodeKind): PNode =
new(result) result = PNode(kind: kind, info: unknownLineInfo)
result.kind = kind
#result.info = UnknownLineInfo() inlined:
result.info.fileIndex = InvalidFileIdx
result.info.col = int16(-1)
result.info.line = uint16(0)
when defined(useNodeIds): when defined(useNodeIds):
result.id = gNodeId result.id = gNodeId
if result.id == nodeIdToDebug: if result.id == nodeIdToDebug:
@ -1091,15 +1090,8 @@ template previouslyInferred*(t: PType): PType =
proc newSym*(symKind: TSymKind, name: PIdent, owner: PSym, proc newSym*(symKind: TSymKind, name: PIdent, owner: PSym,
info: TLineInfo; options: TOptions = {}): PSym = info: TLineInfo; options: TOptions = {}): PSym =
# generates a symbol and initializes the hash field too # generates a symbol and initializes the hash field too
new(result) result = PSym(name: name, kind: symKind, flags: {}, info: info, id: getID(),
result.name = name options: options, owner: owner, offset: defaultOffset)
result.kind = symKind
result.flags = {}
result.info = info
result.options = options
result.owner = owner
result.offset = -1
result.id = getID()
when debugIds: when debugIds:
registerId(result) registerId(result)
@ -1193,9 +1185,7 @@ proc newSymNode*(sym: PSym, info: TLineInfo): PNode =
result.info = info result.info = info
proc newNodeI*(kind: TNodeKind, info: TLineInfo): PNode = proc newNodeI*(kind: TNodeKind, info: TLineInfo): PNode =
new(result) result = PNode(kind: kind, info: info)
result.kind = kind
result.info = info
when defined(useNodeIds): when defined(useNodeIds):
result.id = gNodeId result.id = gNodeId
if result.id == nodeIdToDebug: if result.id == nodeIdToDebug:
@ -1204,9 +1194,7 @@ proc newNodeI*(kind: TNodeKind, info: TLineInfo): PNode =
inc gNodeId inc gNodeId
proc newNodeI*(kind: TNodeKind, info: TLineInfo, children: int): PNode = proc newNodeI*(kind: TNodeKind, info: TLineInfo, children: int): PNode =
new(result) result = PNode(kind: kind, info: info)
result.kind = kind
result.info = info
if children > 0: if children > 0:
newSeq(result.sons, children) newSeq(result.sons, children)
when defined(useNodeIds): when defined(useNodeIds):
@ -1217,12 +1205,9 @@ proc newNodeI*(kind: TNodeKind, info: TLineInfo, children: int): PNode =
inc gNodeId inc gNodeId
proc newNode*(kind: TNodeKind, info: TLineInfo, sons: TNodeSeq = @[], proc newNode*(kind: TNodeKind, info: TLineInfo, sons: TNodeSeq = @[],
typ: PType = nil): PNode = typ: PType = nil): PNode =
new(result)
result.kind = kind
result.info = info
result.typ = typ
# XXX use shallowCopy here for ownership transfer: # XXX use shallowCopy here for ownership transfer:
result = PNode(kind: kind, info: info, typ: typ)
result.sons = sons result.sons = sons
when defined(useNodeIds): when defined(useNodeIds):
result.id = gNodeId result.id = gNodeId
@ -1321,14 +1306,10 @@ proc `$`*(s: PSym): string =
result = "<nil>" result = "<nil>"
proc newType*(kind: TTypeKind, owner: PSym): PType = proc newType*(kind: TTypeKind, owner: PSym): PType =
new(result) let id = getID()
result.kind = kind result = PType(kind: kind, owner: owner, size: defaultSize,
result.owner = owner align: defaultAlignment, id: id, uniqueId: id,
result.size = -1 lockLevel: UnspecifiedLockLevel)
result.align = -1 # default alignment
result.id = getID()
result.uniqueId = result.id
result.lockLevel = UnspecifiedLockLevel
when debugIds: when debugIds:
registerId(result) registerId(result)
when false: when false:
@ -1543,6 +1524,51 @@ proc copyNode*(src: PNode): PNode =
of nkStrLit..nkTripleStrLit: result.strVal = src.strVal of nkStrLit..nkTripleStrLit: result.strVal = src.strVal
else: discard else: discard
template transitionNodeKindCommon(k: TNodeKind) =
let obj {.inject.} = n[]
n[] = TNode(kind: k, typ: obj.typ, info: obj.info, flags: obj.flags,
comment: obj.comment)
when defined(useNodeIds):
n.id = obj.id
proc transitionSonsKind*(n: PNode, kind: range[nkComesFrom..nkTupleConstr]) =
transitionNodeKindCommon(kind)
n.sons = obj.sons
proc transitionIntKind*(n: PNode, kind: range[nkCharLit..nkUInt64Lit]) =
transitionNodeKindCommon(kind)
n.intVal = obj.intVal
proc transitionNoneToSym*(n: PNode) =
transitionNodeKindCommon(nkSym)
template transitionSymKindCommon*(k: TSymKind) =
let obj {.inject.} = s[]
s[] = TSym(kind: k, id: obj.id, magic: obj.magic, typ: obj.typ, name: obj.name,
info: obj.info, owner: obj.owner, flags: obj.flags, ast: obj.ast,
options: obj.options, position: obj.position, offset: obj.offset,
loc: obj.loc, annex: obj.annex, constraint: obj.constraint)
when hasFFI:
s.cname = obj.cname
when defined(nimsuggest):
s.allUsages = obj.allUsages
proc transitionGenericParamToType*(s: PSym) =
transitionSymKindCommon(skType)
s.typeInstCache = obj.typeInstCache
proc transitionRoutineSymKind*(s: PSym, kind: range[skProc..skTemplate]) =
transitionSymKindCommon(kind)
s.procInstCache = obj.procInstCache
s.gcUnsafetyReason = obj.gcUnsafetyReason
s.transformedBody = obj.transformedBody
proc transitionToLet*(s: PSym) =
transitionSymKindCommon(skLet)
s.guard = obj.guard
s.bitsize = obj.bitsize
s.alignment = obj.alignment
proc shallowCopy*(src: PNode): PNode = proc shallowCopy*(src: PNode): PNode =
# does not copy its sons, but provides space for them: # does not copy its sons, but provides space for them:
if src == nil: return nil if src == nil: return nil

View file

@ -282,7 +282,7 @@ proc encodeType(w: PRodWriter, t: PType, result: var string) =
result.add('+') result.add('+')
encodeVInt(t.id, result) encodeVInt(t.id, result)
if t.n != nil: if t.n != nil:
encodeNode(w, unknownLineInfo(), t.n, result) encodeNode(w, unknownLineInfo, t.n, result)
if t.flags != {}: if t.flags != {}:
result.add('$') result.add('$')
encodeVInt(cast[int32](t.flags), result) encodeVInt(cast[int32](t.flags), result)
@ -364,7 +364,7 @@ proc encodeSym(w: PRodWriter, s: PSym, result: var string) =
if s.annex != nil: encodeLib(w, s.annex, s.info, result) if s.annex != nil: encodeLib(w, s.annex, s.info, result)
if s.constraint != nil: if s.constraint != nil:
result.add('#') result.add('#')
encodeNode(w, unknownLineInfo(), s.constraint, result) encodeNode(w, unknownLineInfo, s.constraint, result)
# lazy loading will soon reload the ast lazily, so the ast needs to be # lazy loading will soon reload the ast lazily, so the ast needs to be
# the last entry of a symbol: # the last entry of a symbol:
if s.ast != nil: if s.ast != nil:

View file

@ -1457,7 +1457,7 @@ proc genArrToSeq(p: BProc, n: PNode, d: var TLoc) =
genAssignment(p, elem, arr, {needToCopy}) genAssignment(p, elem, arr, {needToCopy})
else: else:
var i: TLoc var i: TLoc
getTemp(p, getSysType(p.module.g.graph, unknownLineInfo(), tyInt), i) getTemp(p, getSysType(p.module.g.graph, unknownLineInfo, tyInt), i)
linefmt(p, cpsStmts, "for ($1 = 0; $1 < $2; $1++) {$n", [i.r, L]) linefmt(p, cpsStmts, "for ($1 = 0; $1 < $2; $1++) {$n", [i.r, L])
initLoc(elem, locExpr, lodeTyp elemType(skipTypes(n.typ, abstractInst)), OnHeap) initLoc(elem, locExpr, lodeTyp elemType(skipTypes(n.typ, abstractInst)), OnHeap)
elem.r = ropecg(p.module, "$1$3[$2]", [rdLoc(d), rdLoc(i), dataField(p)]) elem.r = ropecg(p.module, "$1$3[$2]", [rdLoc(d), rdLoc(i), dataField(p)])
@ -1847,10 +1847,10 @@ proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
initLocExpr(p, e[1], a) initLocExpr(p, e[1], a)
putIntoDest(p, d, e, ropecg(p.module, "#cardSet($1, $2)", [rdCharLoc(a), size])) putIntoDest(p, d, e, ropecg(p.module, "#cardSet($1, $2)", [rdCharLoc(a), size]))
of mLtSet, mLeSet: of mLtSet, mLeSet:
getTemp(p, getSysType(p.module.g.graph, unknownLineInfo(), tyInt), i) # our counter getTemp(p, getSysType(p.module.g.graph, unknownLineInfo, tyInt), i) # our counter
initLocExpr(p, e[1], a) initLocExpr(p, e[1], a)
initLocExpr(p, e[2], b) initLocExpr(p, e[2], b)
if d.k == locNone: getTemp(p, getSysType(p.module.g.graph, unknownLineInfo(), tyBool), d) if d.k == locNone: getTemp(p, getSysType(p.module.g.graph, unknownLineInfo, tyBool), d)
if op == mLtSet: if op == mLtSet:
linefmt(p, cpsStmts, lookupOpr[mLtSet], linefmt(p, cpsStmts, lookupOpr[mLtSet],
[rdLoc(i), size, rdLoc(d), rdLoc(a), rdLoc(b)]) [rdLoc(i), size, rdLoc(d), rdLoc(a), rdLoc(b)])
@ -1866,7 +1866,7 @@ proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
putIntoDest(p, d, e, ropecg(p.module, "(#nimCmpMem($1, $2, $3)==0)", [a.rdCharLoc, b.rdCharLoc, size])) putIntoDest(p, d, e, ropecg(p.module, "(#nimCmpMem($1, $2, $3)==0)", [a.rdCharLoc, b.rdCharLoc, size]))
of mMulSet, mPlusSet, mMinusSet, mSymDiffSet: of mMulSet, mPlusSet, mMinusSet, mSymDiffSet:
# we inline the simple for loop for better code generation: # we inline the simple for loop for better code generation:
getTemp(p, getSysType(p.module.g.graph, unknownLineInfo(), tyInt), i) # our counter getTemp(p, getSysType(p.module.g.graph, unknownLineInfo, tyInt), i) # our counter
initLocExpr(p, e[1], a) initLocExpr(p, e[1], a)
initLocExpr(p, e[2], b) initLocExpr(p, e[2], b)
if d.k == locNone: getTemp(p, setType, d) if d.k == locNone: getTemp(p, setType, d)
@ -2319,7 +2319,7 @@ proc genSetConstr(p: BProc, e: PNode, d: var TLoc) =
[rdLoc(d), getTypeDesc(p.module, e.typ)]) [rdLoc(d), getTypeDesc(p.module, e.typ)])
for it in e.sons: for it in e.sons:
if it.kind == nkRange: if it.kind == nkRange:
getTemp(p, getSysType(p.module.g.graph, unknownLineInfo(), tyInt), idx) # our counter getTemp(p, getSysType(p.module.g.graph, unknownLineInfo, tyInt), idx) # our counter
initLocExpr(p, it[0], a) initLocExpr(p, it[0], a)
initLocExpr(p, it[1], b) initLocExpr(p, it[1], b)
lineF(p, cpsStmts, "for ($1 = $3; $1 <= $4; $1++) $n" & lineF(p, cpsStmts, "for ($1 = $3; $1 <= $4; $1++) $n" &
@ -2335,7 +2335,7 @@ proc genSetConstr(p: BProc, e: PNode, d: var TLoc) =
lineF(p, cpsStmts, "$1 = 0;$n", [rdLoc(d)]) lineF(p, cpsStmts, "$1 = 0;$n", [rdLoc(d)])
for it in e.sons: for it in e.sons:
if it.kind == nkRange: if it.kind == nkRange:
getTemp(p, getSysType(p.module.g.graph, unknownLineInfo(), tyInt), idx) # our counter getTemp(p, getSysType(p.module.g.graph, unknownLineInfo, tyInt), idx) # our counter
initLocExpr(p, it[0], a) initLocExpr(p, it[0], a)
initLocExpr(p, it[1], b) initLocExpr(p, it[1], b)
lineF(p, cpsStmts, "for ($1 = $3; $1 <= $4; $1++) $n" & lineF(p, cpsStmts, "for ($1 = $3; $1 <= $4; $1++) $n" &

View file

@ -558,7 +558,7 @@ proc genComputedGoto(p: BProc; n: PNode) =
let it = n[j] let it = n[j]
if it.kind in {nkLetSection, nkVarSection}: if it.kind in {nkLetSection, nkVarSection}:
let asgn = copyNode(it) let asgn = copyNode(it)
asgn.kind = nkAsgn asgn.transitionSonsKind(nkAsgn)
asgn.sons.setLen 2 asgn.sons.setLen 2
for sym, value in it.fieldValuePairs: for sym, value in it.fieldValuePairs:
if value.kind != nkEmpty: if value.kind != nkEmpty:

View file

@ -75,7 +75,7 @@ proc genTraverseProc(c: TTraversalClosure, accessor: Rope, typ: PType) =
of tyArray: of tyArray:
let arraySize = lengthOrd(c.p.config, typ[0]) let arraySize = lengthOrd(c.p.config, typ[0])
var i: TLoc var i: TLoc
getTemp(p, getSysType(c.p.module.g.graph, unknownLineInfo(), tyInt), i) getTemp(p, getSysType(c.p.module.g.graph, unknownLineInfo, tyInt), i)
let oldCode = p.s(cpsStmts) let oldCode = p.s(cpsStmts)
linefmt(p, cpsStmts, "for ($1 = 0; $1 < $2; $1++) {$n", linefmt(p, cpsStmts, "for ($1 = 0; $1 < $2; $1++) {$n",
[i.r, arraySize]) [i.r, arraySize])
@ -119,7 +119,7 @@ proc genTraverseProcSeq(c: TTraversalClosure, accessor: Rope, typ: PType) =
var p = c.p var p = c.p
assert typ.kind == tySequence assert typ.kind == tySequence
var i: TLoc var i: TLoc
getTemp(p, getSysType(c.p.module.g.graph, unknownLineInfo(), tyInt), i) getTemp(p, getSysType(c.p.module.g.graph, unknownLineInfo, tyInt), i)
let oldCode = p.s(cpsStmts) let oldCode = p.s(cpsStmts)
var a: TLoc var a: TLoc
a.r = accessor a.r = accessor

View file

@ -696,7 +696,7 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope =
var etB = et.skipTypes(abstractInst) var etB = et.skipTypes(abstractInst)
if mapType(m.config, t) == ctPtrToArray: if mapType(m.config, t) == ctPtrToArray:
if etB.kind == tySet: if etB.kind == tySet:
et = getSysType(m.g.graph, unknownLineInfo(), tyUInt8) et = getSysType(m.g.graph, unknownLineInfo, tyUInt8)
else: else:
et = elemType(etB) et = elemType(etB)
etB = et.skipTypes(abstractInst) etB = et.skipTypes(abstractInst)

View file

@ -480,7 +480,7 @@ proc getIntTemp(p: BProc, result: var TLoc) =
linefmt(p, cpsLocals, "NI $1;$n", [result.r]) linefmt(p, cpsLocals, "NI $1;$n", [result.r])
result.k = locTemp result.k = locTemp
result.storage = OnStack result.storage = OnStack
result.lode = lodeTyp getSysType(p.module.g.graph, unknownLineInfo(), tyInt) result.lode = lodeTyp getSysType(p.module.g.graph, unknownLineInfo, tyInt)
result.flags = {} result.flags = {}
proc localVarDecl(p: BProc; n: PNode): Rope = proc localVarDecl(p: BProc; n: PNode): Rope =

View file

@ -230,9 +230,9 @@ proc genDispatcher(g: ModuleGraph; methods: seq[PSym], relevantCols: IntSet): PS
var paramLen = base.typ.len var paramLen = base.typ.len
var nilchecks = newNodeI(nkStmtList, base.info) var nilchecks = newNodeI(nkStmtList, base.info)
var disp = newNodeI(nkIfStmt, base.info) var disp = newNodeI(nkIfStmt, base.info)
var ands = getSysMagic(g, unknownLineInfo(), "and", mAnd) var ands = getSysMagic(g, unknownLineInfo, "and", mAnd)
var iss = getSysMagic(g, unknownLineInfo(), "of", mOf) var iss = getSysMagic(g, unknownLineInfo, "of", mOf)
let boolType = getSysType(g, unknownLineInfo(), tyBool) let boolType = getSysType(g, unknownLineInfo, tyBool)
for col in 1..<paramLen: for col in 1..<paramLen:
if contains(relevantCols, col): if contains(relevantCols, col):
let param = base.typ.n[col].sym let param = base.typ.n[col].sym

View file

@ -778,7 +778,7 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
result = newNodeI(nkStmtListExpr, n.info) result = newNodeI(nkStmtListExpr, n.info)
result.typ = n.typ result.typ = n.typ
let (st, ex) = exprToStmtList(n[1]) let (st, ex) = exprToStmtList(n[1])
n.kind = nkBlockStmt n.transitionSonsKind(nkBlockStmt)
n.typ = nil n.typ = nil
n[1] = st n[1] = st
result.add(n) result.add(n)

View file

@ -837,12 +837,12 @@ proc liftIterToProc*(g: ModuleGraph; fn: PSym; body: PNode; ptrType: PType): PNo
# pretend 'fn' is a closure iterator for the analysis: # pretend 'fn' is a closure iterator for the analysis:
let oldKind = fn.kind let oldKind = fn.kind
let oldCC = fn.typ.callConv let oldCC = fn.typ.callConv
fn.kind = skIterator fn.transitionRoutineSymKind(skIterator)
fn.typ.callConv = ccClosure fn.typ.callConv = ccClosure
d.ownerToType[fn.id] = ptrType d.ownerToType[fn.id] = ptrType
detectCapturedVars(body, fn, d) detectCapturedVars(body, fn, d)
result = liftCapturedVars(body, fn, d, c) result = liftCapturedVars(body, fn, d, c)
fn.kind = oldKind fn.transitionRoutineSymKind(oldKind)
fn.typ.callConv = oldCC fn.typ.callConv = oldCC
proc liftLambdas*(g: ModuleGraph; fn: PSym, body: PNode; tooEarly: var bool): PNode = proc liftLambdas*(g: ModuleGraph; fn: PSym, body: PNode; tooEarly: var bool): PNode =
@ -959,7 +959,7 @@ proc liftForLoop*(g: ModuleGraph; body: PNode; owner: PSym): PNode =
var vpart = newNodeI(if body.len == 3: nkIdentDefs else: nkVarTuple, body.info) var vpart = newNodeI(if body.len == 3: nkIdentDefs else: nkVarTuple, body.info)
for i in 0..<body.len-2: for i in 0..<body.len-2:
if body[i].kind == nkSym: if body[i].kind == nkSym:
body[i].sym.kind = skLet body[i].sym.transitionToLet()
vpart.add body[i] vpart.add body[i]
vpart.add newNodeI(nkEmpty, body.info) # no explicit type vpart.add newNodeI(nkEmpty, body.info) # no explicit type

View file

@ -236,11 +236,7 @@ proc raiseRecoverableError*(msg: string) {.noinline.} =
const const
InvalidFileIdx* = FileIndex(-1) InvalidFileIdx* = FileIndex(-1)
unknownLineInfo* = TLineInfo(line: 0, col: -1, fileIndex: InvalidFileIdx)
proc unknownLineInfo*(): TLineInfo =
result.line = uint16(0)
result.col = int16(-1)
result.fileIndex = InvalidFileIdx
type type
Severity* {.pure.} = enum ## VS Code only supports these three Severity* {.pure.} = enum ## VS Code only supports these three
@ -267,7 +263,7 @@ type
proc initMsgConfig*(): MsgConfig = proc initMsgConfig*(): MsgConfig =
result.msgContext = @[] result.msgContext = @[]
result.lastError = unknownLineInfo() result.lastError = unknownLineInfo
result.filenameToIndexTbl = initTable[string, FileIndex]() result.filenameToIndexTbl = initTable[string, FileIndex]()
result.fileInfos = @[] result.fileInfos = @[]
result.errorOutputs = {eStdOut, eStdErr} result.errorOutputs = {eStdOut, eStdErr}

View file

@ -323,7 +323,7 @@ proc genDeref*(n: PNode; k = nkHiddenDeref): PNode =
result.add n result.add n
proc callCodegenProc*(g: ModuleGraph; name: string; proc callCodegenProc*(g: ModuleGraph; name: string;
info: TLineInfo = unknownLineInfo(); info: TLineInfo = unknownLineInfo;
arg1, arg2, arg3, optionalArgs: PNode = nil): PNode = arg1, arg2, arg3, optionalArgs: PNode = nil): PNode =
result = newNodeI(nkCall, info) result = newNodeI(nkCall, info)
let sym = magicsys.getCompilerProc(g, name) let sym = magicsys.getCompilerProc(g, name)

View file

@ -163,7 +163,7 @@ proc stopCompile*(g: ModuleGraph): bool {.inline.} =
result = g.doStopCompile != nil and g.doStopCompile() result = g.doStopCompile != nil and g.doStopCompile()
proc createMagic*(g: ModuleGraph; name: string, m: TMagic): PSym = proc createMagic*(g: ModuleGraph; name: string, m: TMagic): PSym =
result = newSym(skProc, getIdent(g.cache, name), nil, unknownLineInfo(), {}) result = newSym(skProc, getIdent(g.cache, name), nil, unknownLineInfo, {})
result.magic = m result.magic = m
proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph = proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph =

View file

@ -55,16 +55,14 @@ proc partialInitModule(result: PSym; graph: ModuleGraph; fileIdx: FileIndex; fil
strTableAdd(packSym.tab, result) strTableAdd(packSym.tab, result)
proc newModule(graph: ModuleGraph; fileIdx: FileIndex): PSym = proc newModule(graph: ModuleGraph; fileIdx: FileIndex): PSym =
let filename = AbsoluteFile toFullPath(graph.config, fileIdx)
# We cannot call ``newSym`` here, because we have to circumvent the ID # We cannot call ``newSym`` here, because we have to circumvent the ID
# mechanism, which we do in order to assign each module a persistent ID. # mechanism, which we do in order to assign each module a persistent ID.
new(result) result = PSym(kind: skModule, id: -1, # for better error checking
result.id = -1 # for better error checking name: getIdent(graph.cache, splitFile(filename).name),
result.kind = skModule info: newLineInfo(fileIdx, 1, 1))
let filename = AbsoluteFile toFullPath(graph.config, fileIdx)
result.name = getIdent(graph.cache, splitFile(filename).name)
if not isNimIdentifier(result.name.s): if not isNimIdentifier(result.name.s):
rawMessage(graph.config, errGenerated, "invalid module name: " & result.name.s) rawMessage(graph.config, errGenerated, "invalid module name: " & result.name.s)
result.info = newLineInfo(fileIdx, 1, 1)
partialInitModule(result, graph, fileIdx, filename) partialInitModule(result, graph, fileIdx, filename)
proc compileModule*(graph: ModuleGraph; fileIdx: FileIndex; flags: TSymFlags): PSym = proc compileModule*(graph: ModuleGraph; fileIdx: FileIndex; flags: TSymFlags): PSym =

View file

@ -157,7 +157,7 @@ proc popInfoContext*(conf: ConfigRef) =
proc getInfoContext*(conf: ConfigRef; index: int): TLineInfo = proc getInfoContext*(conf: ConfigRef; index: int): TLineInfo =
let i = if index < 0: conf.m.msgContext.len + index else: index let i = if index < 0: conf.m.msgContext.len + index else: index
if i >=% conf.m.msgContext.len: result = unknownLineInfo() if i >=% conf.m.msgContext.len: result = unknownLineInfo
else: result = conf.m.msgContext[i].info else: result = conf.m.msgContext[i].info
const const
@ -405,14 +405,14 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
case msg case msg
of errMin..errMax: of errMin..errMax:
sev = Severity.Error sev = Severity.Error
writeContext(conf, unknownLineInfo()) writeContext(conf, unknownLineInfo)
title = ErrorTitle title = ErrorTitle
color = ErrorColor color = ErrorColor
of warnMin..warnMax: of warnMin..warnMax:
sev = Severity.Warning sev = Severity.Warning
if optWarns notin conf.options: return if optWarns notin conf.options: return
if msg notin conf.notes: return if msg notin conf.notes: return
writeContext(conf, unknownLineInfo()) writeContext(conf, unknownLineInfo)
title = WarningTitle title = WarningTitle
color = WarningColor color = WarningColor
kind = WarningsToStr[ord(msg) - ord(warnMin)] kind = WarningsToStr[ord(msg) - ord(warnMin)]
@ -428,7 +428,7 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
let s = msgKindToString(msg) % args let s = msgKindToString(msg) % args
if conf.structuredErrorHook != nil: if conf.structuredErrorHook != nil:
conf.structuredErrorHook(conf, unknownLineInfo(), conf.structuredErrorHook(conf, unknownLineInfo,
s & (if kind.len > 0: KindFormat % kind else: ""), sev) s & (if kind.len > 0: KindFormat % kind else: ""), sev)
if not ignoreMsgBecauseOfIdeTools(conf, msg): if not ignoreMsgBecauseOfIdeTools(conf, msg):
@ -561,7 +561,7 @@ proc internalError*(conf: ConfigRef; info: TLineInfo, errMsg: string) =
proc internalError*(conf: ConfigRef; errMsg: string) = proc internalError*(conf: ConfigRef; errMsg: string) =
if conf.cmd == cmdIdeTools and conf.structuredErrorHook.isNil: return if conf.cmd == cmdIdeTools and conf.structuredErrorHook.isNil: return
writeContext(conf, unknownLineInfo()) writeContext(conf, unknownLineInfo)
rawMessage(conf, errInternal, errMsg) rawMessage(conf, errInternal, errMsg)
template assertNotNil*(conf: ConfigRef; e): untyped = template assertNotNil*(conf: ConfigRef; e): untyped =

View file

@ -15,7 +15,6 @@ define:nimcore
@end @end
define:useStdoutAsStdmsg define:useStdoutAsStdmsg
define:nimOldCaseObjects
@if nimHasStyleChecks: @if nimHasStyleChecks:
styleCheck:error styleCheck:error
@ -23,7 +22,3 @@ define:nimOldCaseObjects
#define:useNodeIds #define:useNodeIds
#gc:markAndSweep #gc:markAndSweep
@if nimHasWarningCaseTransition:
warning[CaseTransition]:off
@end

View file

@ -147,16 +147,16 @@ when isMainModule:
let conf = newConfigRef() let conf = newConfigRef()
var rr = newStringTable() var rr = newStringTable()
addPackage conf, rr, "irc-#a111", unknownLineInfo() addPackage conf, rr, "irc-#a111", unknownLineInfo
addPackage conf, rr, "irc-#head", unknownLineInfo() addPackage conf, rr, "irc-#head", unknownLineInfo
addPackage conf, rr, "irc-0.1.0", unknownLineInfo() addPackage conf, rr, "irc-0.1.0", unknownLineInfo
#addPackage conf, rr, "irc", unknownLineInfo() #addPackage conf, rr, "irc", unknownLineInfo
#addPackage conf, rr, "another", unknownLineInfo() #addPackage conf, rr, "another", unknownLineInfo
addPackage conf, rr, "another-0.1", unknownLineInfo() addPackage conf, rr, "another-0.1", unknownLineInfo
addPackage conf, rr, "ab-0.1.3", unknownLineInfo() addPackage conf, rr, "ab-0.1.3", unknownLineInfo
addPackage conf, rr, "ab-0.1", unknownLineInfo() addPackage conf, rr, "ab-0.1", unknownLineInfo
addPackage conf, rr, "justone-1.0", unknownLineInfo() addPackage conf, rr, "justone-1.0", unknownLineInfo
doAssert toSeq(rr.chosen) == doAssert toSeq(rr.chosen) ==
@["irc-#head", "another-0.1", "ab-0.1.3", "justone-1.0"] @["irc-#head", "another-0.1", "ab-0.1.3", "justone-1.0"]

View file

@ -427,7 +427,7 @@ proc exprColonEqExprListAux(p: var TParser, endTok: TTokType, result: PNode) =
getTok(p) getTok(p)
# (1,) produces a tuple expression # (1,) produces a tuple expression
if endTok == tkParRi and p.tok.tokType == tkParRi and result.kind == nkPar: if endTok == tkParRi and p.tok.tokType == tkParRi and result.kind == nkPar:
result.kind = nkTupleConstr result.transitionSonsKind(nkTupleConstr)
skipComment(p, a) skipComment(p, a)
optPar(p) optPar(p)
eat(p, endTok) eat(p, endTok)
@ -472,12 +472,12 @@ proc setOrTableConstr(p: var TParser): PNode =
optInd(p, result) optInd(p, result)
if p.tok.tokType == tkColon: if p.tok.tokType == tkColon:
getTok(p) # skip ':' getTok(p) # skip ':'
result.kind = nkTableConstr result.transitionSonsKind(nkTableConstr)
else: else:
# progress guaranteed # progress guaranteed
while p.tok.tokType notin {tkCurlyRi, tkEof}: while p.tok.tokType notin {tkCurlyRi, tkEof}:
var a = exprColonEqExpr(p) var a = exprColonEqExpr(p)
if a.kind == nkExprColonExpr: result.kind = nkTableConstr if a.kind == nkExprColonExpr: result.transitionSonsKind(nkTableConstr)
result.add(a) result.add(a)
if p.tok.tokType != tkComma: break if p.tok.tokType != tkComma: break
getTok(p) getTok(p)
@ -534,7 +534,7 @@ proc semiStmtList(p: var TParser, result: PNode) =
optInd(p, result) optInd(p, result)
result.add(complexOrSimpleStmt(p)) result.add(complexOrSimpleStmt(p))
dec p.inSemiStmtList dec p.inSemiStmtList
result.kind = nkStmtListExpr result.transitionSonsKind(nkStmtListExpr)
proc parsePar(p: var TParser): PNode = proc parsePar(p: var TParser): PNode =
#| parKeyw = 'discard' | 'include' | 'if' | 'while' | 'case' | 'try' #| parKeyw = 'discard' | 'include' | 'if' | 'while' | 'case' | 'try'
@ -595,7 +595,7 @@ proc parsePar(p: var TParser): PNode =
skipComment(p, a) skipComment(p, a)
# (1,) produces a tuple expression: # (1,) produces a tuple expression:
if p.tok.tokType == tkParRi: if p.tok.tokType == tkParRi:
result.kind = nkTupleConstr result.transitionSonsKind(nkTupleConstr)
# progress guaranteed # progress guaranteed
while p.tok.tokType != tkParRi and p.tok.tokType != tkEof: while p.tok.tokType != tkParRi and p.tok.tokType != tkEof:
var a = exprColonEqExpr(p) var a = exprColonEqExpr(p)
@ -778,7 +778,7 @@ proc primarySuffix(p: var TParser, r: PNode,
break break
result = namedParams(p, result, nkCall, tkParRi) result = namedParams(p, result, nkCall, tkParRi)
if result.len > 1 and result[1].kind == nkExprColonExpr: if result.len > 1 and result[1].kind == nkExprColonExpr:
result.kind = nkObjConstr result.transitionSonsKind(nkObjConstr)
of tkDot: of tkDot:
# progress guaranteed # progress guaranteed
result = dotExpr(p, result) result = dotExpr(p, result)
@ -1275,8 +1275,8 @@ proc primary(p: var TParser, mode: TPrimaryMode): PNode =
of tkFunc: result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef}, nkFuncDef) of tkFunc: result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef}, nkFuncDef)
of tkIterator: of tkIterator:
result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef}, nkLambda) result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef}, nkLambda)
if result.kind == nkLambda: result.kind = nkIteratorDef if result.kind == nkLambda: result.transitionSonsKind(nkIteratorDef)
else: result.kind = nkIteratorTy else: result.transitionSonsKind(nkIteratorTy)
of tkEnum: of tkEnum:
if mode == pmTypeDef: if mode == pmTypeDef:
prettySection: prettySection:
@ -1479,7 +1479,7 @@ proc parseImport(p: var TParser, kind: TNodeKind): PNode =
result.add(a) result.add(a)
if p.tok.tokType in {tkComma, tkExcept}: if p.tok.tokType in {tkComma, tkExcept}:
if p.tok.tokType == tkExcept: if p.tok.tokType == tkExcept:
result.kind = succ(kind) result.transitionSonsKind(succ(kind))
getTok(p) getTok(p)
optInd(p, result) optInd(p, result)
while true: while true:

View file

@ -736,7 +736,7 @@ proc semCustomPragma(c: PContext, n: PNode): PNode =
result = result[0] result = result[0]
elif n.kind == nkExprColonExpr and r.len == 2: elif n.kind == nkExprColonExpr and r.len == 2:
# pragma(arg) -> pragma: arg # pragma(arg) -> pragma: arg
result.kind = n.kind result.transitionSonsKind(n.kind)
proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
validPragmas: TSpecialWords, validPragmas: TSpecialWords,

View file

@ -173,7 +173,7 @@ proc encodeLoc(g: ModuleGraph; loc: TLoc, result: var string) =
encodeVInt(cast[int32](loc.flags), result) encodeVInt(cast[int32](loc.flags), result)
if loc.lode != nil: if loc.lode != nil:
result.add('^') result.add('^')
encodeNode(g, unknownLineInfo(), loc.lode, result) encodeNode(g, unknownLineInfo, loc.lode, result)
if loc.r != nil: if loc.r != nil:
result.add('!') result.add('!')
encodeStr($loc.r, result) encodeStr($loc.r, result)
@ -200,7 +200,7 @@ proc encodeType(g: ModuleGraph, t: PType, result: var string) =
result.add('+') result.add('+')
encodeVInt(t.id, result) encodeVInt(t.id, result)
if t.n != nil: if t.n != nil:
encodeNode(g, unknownLineInfo(), t.n, result) encodeNode(g, unknownLineInfo, t.n, result)
if t.flags != {}: if t.flags != {}:
result.add('$') result.add('$')
encodeVInt(cast[int32](t.flags), result) encodeVInt(cast[int32](t.flags), result)
@ -318,7 +318,7 @@ proc encodeSym(g: ModuleGraph, s: PSym, result: var string) =
if s.annex != nil: encodeLib(g, s.annex, s.info, result) if s.annex != nil: encodeLib(g, s.annex, s.info, result)
if s.constraint != nil: if s.constraint != nil:
result.add('#') result.add('#')
encodeNode(g, unknownLineInfo(), s.constraint, result) encodeNode(g, unknownLineInfo, s.constraint, result)
case s.kind case s.kind
of skType, skGenericParam: of skType, skGenericParam:
for t in s.typeInstCache: for t in s.typeInstCache:
@ -605,7 +605,7 @@ proc loadType(g; id: int; info: TLineInfo): PType =
result.id = result.uniqueId result.id = result.uniqueId
# here this also avoids endless recursion for recursive type # here this also avoids endless recursion for recursive type
g.incr.r.types.add(result.uniqueId, result) g.incr.r.types.add(result.uniqueId, result)
if b.s[b.pos] == '(': result.n = decodeNode(g, b, unknownLineInfo()) if b.s[b.pos] == '(': result.n = decodeNode(g, b, unknownLineInfo)
if b.s[b.pos] == '$': if b.s[b.pos] == '$':
inc(b.pos) inc(b.pos)
result.flags = cast[TTypeFlags](int32(decodeVInt(b.s, b.pos))) result.flags = cast[TTypeFlags](int32(decodeVInt(b.s, b.pos)))
@ -752,7 +752,7 @@ proc loadSymFromBlob(g; b; info: TLineInfo): PSym =
result.annex = decodeLib(g, b, info) result.annex = decodeLib(g, b, info)
if b.s[b.pos] == '#': if b.s[b.pos] == '#':
inc(b.pos) inc(b.pos)
result.constraint = decodeNode(g, b, unknownLineInfo()) result.constraint = decodeNode(g, b, unknownLineInfo)
case result.kind case result.kind
of skType, skGenericParam: of skType, skGenericParam:
while b.s[b.pos] == '\14': while b.s[b.pos] == '\14':

View file

@ -416,7 +416,7 @@ proc semAfterMacroCall(c: PContext, call, macroResult: PNode,
# More restrictive version. # More restrictive version.
result = semExprWithType(c, result, flags) result = semExprWithType(c, result, flags)
of tyTypeDesc: of tyTypeDesc:
if result.kind == nkStmtList: result.kind = nkStmtListType if result.kind == nkStmtList: result.transitionSonsKind(nkStmtListType)
var typ = semTypeNode(c, result, nil) var typ = semTypeNode(c, result, nil)
if typ == nil: if typ == nil:
localError(c.config, result.info, "expression has no type: " & localError(c.config, result.info, "expression has no type: " &

View file

@ -884,7 +884,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
if n0.kind == nkDotCall: if n0.kind == nkDotCall:
# it is a static call! # it is a static call!
result = n0 result = n0
result.kind = nkCall result.transitionSonsKind(nkCall)
result.flags.incl nfExplicitCall result.flags.incl nfExplicitCall
for i in 1..<n.len: result.add n[i] for i in 1..<n.len: result.add n[i]
return semExpr(c, result, flags) return semExpr(c, result, flags)
@ -1509,7 +1509,7 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode =
else: else:
# We are processing macroOrTmpl[] not in call. Transform it to the # We are processing macroOrTmpl[] not in call. Transform it to the
# macro or template call with generic arguments here. # macro or template call with generic arguments here.
n.kind = nkCall n.transitionSonsKind(nkCall)
case s.kind case s.kind
of skMacro: result = semMacroExpr(c, n, n, s, flags) of skMacro: result = semMacroExpr(c, n, n, s, flags)
of skTemplate: result = semTemplateExpr(c, n, s, flags) of skTemplate: result = semTemplateExpr(c, n, s, flags)
@ -1646,7 +1646,7 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
# possible: # possible:
a = dotTransformation(c, n[0]) a = dotTransformation(c, n[0])
if a.kind == nkDotCall: if a.kind == nkDotCall:
a.kind = nkCall a.transitionSonsKind(nkCall)
a = semExprWithType(c, a, {efLValue}) a = semExprWithType(c, a, {efLValue})
of nkBracketExpr: of nkBracketExpr:
# a[i] = x # a[i] = x
@ -2429,7 +2429,7 @@ proc semTupleFieldsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode = proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
result = n # we don't modify n, but compute the type: result = n # we don't modify n, but compute the type:
result.kind = nkTupleConstr result.transitionSonsKind(nkTupleConstr)
var typ = newTypeS(tyTuple, c) # leave typ.n nil! var typ = newTypeS(tyTuple, c) # leave typ.n nil!
for i in 0..<n.len: for i in 0..<n.len:
n[i] = semExprWithType(c, n[i], flags*{efAllowDestructor}) n[i] = semExprWithType(c, n[i], flags*{efAllowDestructor})
@ -2455,8 +2455,8 @@ proc semBlock(c: PContext, n: PNode; flags: TExprFlags): PNode =
onDef(n[0].info, labl) onDef(n[0].info, labl)
n[1] = semExpr(c, n[1], flags) n[1] = semExpr(c, n[1], flags)
n.typ = n[1].typ n.typ = n[1].typ
if isEmptyType(n.typ): n.kind = nkBlockStmt if isEmptyType(n.typ): n.transitionSonsKind(nkBlockStmt)
else: n.kind = nkBlockExpr else: n.transitionSonsKind(nkBlockExpr)
closeScope(c) closeScope(c)
dec(c.p.nestedBlockCounter) dec(c.p.nestedBlockCounter)
@ -2608,7 +2608,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
of nkDotExpr: of nkDotExpr:
result = semFieldAccess(c, n, flags) result = semFieldAccess(c, n, flags)
if result.kind == nkDotCall: if result.kind == nkDotCall:
result.kind = nkCall result.transitionSonsKind(nkCall)
result = semExpr(c, result, flags) result = semExpr(c, result, flags)
of nkBind: of nkBind:
message(c.config, n.info, warnDeprecated, "bind is deprecated") message(c.config, n.info, warnDeprecated, "bind is deprecated")

View file

@ -451,7 +451,7 @@ proc foldConv(n, a: PNode; g: ModuleGraph; check = false): PNode =
if check: rangeCheck(n, val, g) if check: rangeCheck(n, val, g)
result = newIntNodeT(val, n, g) result = newIntNodeT(val, n, g)
if dstTyp.kind in {tyUInt..tyUInt64}: if dstTyp.kind in {tyUInt..tyUInt64}:
result.kind = nkUIntLit result.transitionIntKind(nkUIntLit)
else: else:
result = a result = a
result.typ = n.typ result.typ = n.typ

View file

@ -163,7 +163,7 @@ proc fuzzyLookup(c: PContext, n: PNode, flags: TSemGenericFlags,
let syms = semGenericStmtSymbol(c, n, s, ctx, flags, fromDotExpr=true) let syms = semGenericStmtSymbol(c, n, s, ctx, flags, fromDotExpr=true)
if syms.kind == nkSym: if syms.kind == nkSym:
let choice = symChoice(c, n, s, scForceOpen) let choice = symChoice(c, n, s, scForceOpen)
choice.kind = nkClosedSymChoice choice.transitionSonsKind(nkClosedSymChoice)
result = newDot(result, choice) result = newDot(result, choice)
else: else:
result = newDot(result, syms) result = newDot(result, syms)

View file

@ -129,7 +129,7 @@ proc fixNilType(c: PContext; n: PNode) =
if n.kind != nkNilLit and n.typ != nil: if n.kind != nkNilLit and n.typ != nil:
localError(c.config, n.info, errDiscardValueX % n.typ.typeToString) localError(c.config, n.info, errDiscardValueX % n.typ.typeToString)
elif n.kind in {nkStmtList, nkStmtListExpr}: elif n.kind in {nkStmtList, nkStmtListExpr}:
n.kind = nkStmtList n.transitionSonsKind(nkStmtList)
for it in n: fixNilType(c, it) for it in n: fixNilType(c, it)
n.typ = nil n.typ = nil
@ -172,7 +172,7 @@ proc semIf(c: PContext, n: PNode; flags: TExprFlags): PNode =
if isEmptyType(typ) or typ.kind in {tyNil, tyUntyped} or if isEmptyType(typ) or typ.kind in {tyNil, tyUntyped} or
(not hasElse and efInTypeof notin flags): (not hasElse and efInTypeof notin flags):
for it in n: discardCheck(c, it.lastSon, flags) for it in n: discardCheck(c, it.lastSon, flags)
result.kind = nkIfStmt result.transitionSonsKind(nkIfStmt)
# propagate any enforced VoidContext: # propagate any enforced VoidContext:
if typ == c.enforceVoidContext: result.typ = c.enforceVoidContext if typ == c.enforceVoidContext: result.typ = c.enforceVoidContext
else: else:
@ -180,7 +180,7 @@ proc semIf(c: PContext, n: PNode; flags: TExprFlags): PNode =
let j = it.len-1 let j = it.len-1
if not endsInNoReturn(it[j]): if not endsInNoReturn(it[j]):
it[j] = fitNode(c, typ, it[j], it[j].info) it[j] = fitNode(c, typ, it[j], it[j].info)
result.kind = nkIfExpr result.transitionSonsKind(nkIfExpr)
result.typ = typ result.typ = typ
proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode =
@ -867,7 +867,7 @@ proc semFor(c: PContext, n: PNode; flags: TExprFlags): PNode =
call[0].sym.magic in {mFields, mFieldPairs, mOmpParFor}: call[0].sym.magic in {mFields, mFieldPairs, mOmpParFor}:
if call[0].sym.magic == mOmpParFor: if call[0].sym.magic == mOmpParFor:
result = semForVars(c, n, flags) result = semForVars(c, n, flags)
result.kind = nkParForStmt result.transitionSonsKind(nkParForStmt)
else: else:
result = semForFields(c, n, call[0].sym.magic) result = semForFields(c, n, call[0].sym.magic)
elif isCallExpr and isClosureIterator(call[0].typ.skipTypes(abstractInst)): elif isCallExpr and isClosureIterator(call[0].typ.skipTypes(abstractInst)):
@ -1970,7 +1970,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
if n[patternPos].kind != nkEmpty: if n[patternPos].kind != nkEmpty:
c.patterns.add(s) c.patterns.add(s)
if isAnon: if isAnon:
n.kind = nkLambda n.transitionSonsKind(nkLambda)
result.typ = s.typ result.typ = s.typ
if optOwnedRefs in c.config.globalOptions: if optOwnedRefs in c.config.globalOptions:
result.typ = makeVarType(c, result.typ, tyOwned) result.typ = makeVarType(c, result.typ, tyOwned)
@ -1989,7 +1989,7 @@ proc semIterator(c: PContext, n: PNode): PNode =
if n[namePos].kind == nkSym: if n[namePos].kind == nkSym:
# gensym'ed iterators might need to become closure iterators: # gensym'ed iterators might need to become closure iterators:
n[namePos].sym.owner = getCurrOwner(c) n[namePos].sym.owner = getCurrOwner(c)
n[namePos].sym.kind = skIterator n[namePos].sym.transitionRoutineSymKind(skIterator)
result = semProcAux(c, n, skIterator, iteratorPragmas) result = semProcAux(c, n, skIterator, iteratorPragmas)
# bug #7093: if after a macro transformation we don't have an # bug #7093: if after a macro transformation we don't have an
# nkIteratorDef aynmore, return. The iterator then might have been # nkIteratorDef aynmore, return. The iterator then might have been
@ -2166,7 +2166,7 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode =
const const
LastBlockStmts = {nkRaiseStmt, nkReturnStmt, nkBreakStmt, nkContinueStmt} LastBlockStmts = {nkRaiseStmt, nkReturnStmt, nkBreakStmt, nkContinueStmt}
result = n result = n
result.kind = nkStmtList result.transitionSonsKind(nkStmtList)
var voidContext = false var voidContext = false
var last = n.len-1 var last = n.len-1
# by not allowing for nkCommentStmt etc. we ensure nkStmtListExpr actually # by not allowing for nkCommentStmt etc. we ensure nkStmtListExpr actually
@ -2203,12 +2203,12 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode =
n.typ = c.enforceVoidContext n.typ = c.enforceVoidContext
if i == last and (n.len == 1 or ({efWantValue, efInTypeof} * flags != {})): if i == last and (n.len == 1 or ({efWantValue, efInTypeof} * flags != {})):
n.typ = n[i].typ n.typ = n[i].typ
if not isEmptyType(n.typ): n.kind = nkStmtListExpr if not isEmptyType(n.typ): n.transitionSonsKind(nkStmtListExpr)
elif i != last or voidContext: elif i != last or voidContext:
discardCheck(c, n[i], flags) discardCheck(c, n[i], flags)
else: else:
n.typ = n[i].typ n.typ = n[i].typ
if not isEmptyType(n.typ): n.kind = nkStmtListExpr if not isEmptyType(n.typ): n.transitionSonsKind(nkStmtListExpr)
if n[i].kind in LastBlockStmts or if n[i].kind in LastBlockStmts or
n[i].kind in nkCallKinds and n[i][0].kind == nkSym and n[i].kind in nkCallKinds and n[i][0].kind == nkSym and
sfNoReturn in n[i][0].sym.flags: sfNoReturn in n[i][0].sym.flags:

View file

@ -381,7 +381,7 @@ proc semTypeIdent(c: PContext, n: PNode): PSym =
if result.typ.kind == tyGenericParam and result.typ.len == 0 and if result.typ.kind == tyGenericParam and result.typ.len == 0 and
tfWildcard in result.typ.flags: tfWildcard in result.typ.flags:
# collapse the wild-card param to a type # collapse the wild-card param to a type
result.kind = skType result.transitionGenericParamToType()
result.typ.flags.excl tfWildcard result.typ.flags.excl tfWildcard
return return
else: else:
@ -405,7 +405,7 @@ proc semTypeIdent(c: PContext, n: PNode): PSym =
reset(n[]) reset(n[])
when defined(useNodeIds): when defined(useNodeIds):
n.id = oldId n.id = oldId
n.kind = nkSym n.transitionNoneToSym()
n.sym = result n.sym = result
n.info = oldInfo n.info = oldInfo
n.typ = result.typ n.typ = result.typ
@ -1127,7 +1127,7 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
onUse(paramType.sym.info, paramType.sym) onUse(paramType.sym.info, paramType.sym)
if tfWildcard in paramType.flags: if tfWildcard in paramType.flags:
paramType.flags.excl tfWildcard paramType.flags.excl tfWildcard
paramType.sym.kind = skType paramType.sym.transitionGenericParamToType()
else: discard else: discard
@ -1326,7 +1326,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
result.flags.incl tfUnresolved result.flags.incl tfUnresolved
if tfWildcard in n.sym.typ.flags: if tfWildcard in n.sym.typ.flags:
n.sym.kind = skType n.sym.transitionGenericParamToType()
n.sym.typ.flags.excl tfWildcard n.sym.typ.flags.excl tfWildcard
proc semStmtListType(c: PContext, n: PNode, prev: PType): PType = proc semStmtListType(c: PContext, n: PNode, prev: PType): PType =
@ -1696,7 +1696,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
result = semTypeExpr(c, n, prev) result = semTypeExpr(c, n, prev)
of nkWhenStmt: of nkWhenStmt:
var whenResult = semWhen(c, n, false) var whenResult = semWhen(c, n, false)
if whenResult.kind == nkStmtList: whenResult.kind = nkStmtListType if whenResult.kind == nkStmtList: whenResult.transitionSonsKind(nkStmtListType)
result = semTypeNode(c, whenResult, prev) result = semTypeNode(c, whenResult, prev)
of nkBracketExpr: of nkBracketExpr:
checkMinSonsLen(n, 2, c.config) checkMinSonsLen(n, 2, c.config)

View file

@ -1714,7 +1714,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
if result == isGeneric: if result == isGeneric:
var concrete = a var concrete = a
if tfWildcard in a.flags: if tfWildcard in a.flags:
a.sym.kind = skType a.sym.transitionGenericParamToType()
a.flags.excl tfWildcard a.flags.excl tfWildcard
else: else:
concrete = concreteType(c, a, f) concrete = concreteType(c, a, f)
@ -1943,7 +1943,7 @@ proc localConvMatch(c: PContext, m: var TCandidate, f, a: PType,
# resulting type must be consistent with the other arguments: # resulting type must be consistent with the other arguments:
var r = typeRel(m, f[0], result.typ) var r = typeRel(m, f[0], result.typ)
if r < isGeneric: return nil if r < isGeneric: return nil
if result.kind == nkCall: result.kind = nkHiddenCallConv if result.kind == nkCall: result.transitionSonsKind(nkHiddenCallConv)
inc(m.convMatches) inc(m.convMatches)
if r == isGeneric: if r == isGeneric:
result.typ = getInstantiatedType(c, arg, m, base(f)) result.typ = getInstantiatedType(c, arg, m, base(f))
@ -2602,7 +2602,7 @@ when not declared(tests):
template tests(s: untyped) = discard template tests(s: untyped) = discard
tests: tests:
var dummyOwner = newSym(skModule, getIdent("test_module"), nil, UnknownLineInfo()) var dummyOwner = newSym(skModule, getIdent("test_module"), nil, unknownLineInfo)
proc `|` (t1, t2: PType): PType = proc `|` (t1, t2: PType): PType =
result = newType(tyOr, dummyOwner) result = newType(tyOr, dummyOwner)
@ -2625,7 +2625,7 @@ tests:
proc array(x: int, t: PType): PType = proc array(x: int, t: PType): PType =
result = newType(tyArray, dummyOwner) result = newType(tyArray, dummyOwner)
var n = newNodeI(nkRange, UnknownLineInfo()) var n = newNodeI(nkRange, unknownLineInfo)
n.add newIntNode(nkIntLit, 0) n.add newIntNode(nkIntLit, 0)
n.add newIntNode(nkIntLit, x) n.add newIntNode(nkIntLit, x)
let range = newType(tyRange, dummyOwner) let range = newType(tyRange, dummyOwner)
@ -2643,14 +2643,14 @@ tests:
number = int | float number = int | float
var TFoo = newType(tyObject, dummyOwner) var TFoo = newType(tyObject, dummyOwner)
TFoo.sym = newSym(skType, getIdent"TFoo", dummyOwner, UnknownLineInfo()) TFoo.sym = newSym(skType, getIdent"TFoo", dummyOwner, unknownLineInfo)
var T1 = newType(tyGenericParam, dummyOwner) var T1 = newType(tyGenericParam, dummyOwner)
T1.sym = newSym(skType, getIdent"T1", dummyOwner, UnknownLineInfo()) T1.sym = newSym(skType, getIdent"T1", dummyOwner, unknownLineInfo)
T1.sym.position = 0 T1.sym.position = 0
var T2 = newType(tyGenericParam, dummyOwner) var T2 = newType(tyGenericParam, dummyOwner)
T2.sym = newSym(skType, getIdent"T2", dummyOwner, UnknownLineInfo()) T2.sym = newSym(skType, getIdent"T2", dummyOwner, unknownLineInfo)
T2.sym.position = 1 T2.sym.position = 1
setup: setup:

View file

@ -366,11 +366,11 @@ proc computeSizeAlign(conf: ConfigRef; typ: PType) =
OffsetAccum(maxAlign: 1) OffsetAccum(maxAlign: 1)
if tfUnion in typ.flags: if tfUnion in typ.flags:
if tfPacked in typ.flags: if tfPacked in typ.flags:
let info = if typ.sym != nil: typ.sym.info else: unknownLineInfo() let info = if typ.sym != nil: typ.sym.info else: unknownLineInfo
localError(conf, info, "union type may not be packed.") localError(conf, info, "union type may not be packed.")
accum = OffsetAccum(offset: szUnknownSize, maxAlign: szUnknownSize) accum = OffsetAccum(offset: szUnknownSize, maxAlign: szUnknownSize)
elif accum.offset != 0: elif accum.offset != 0:
let info = if typ.sym != nil: typ.sym.info else: unknownLineInfo() let info = if typ.sym != nil: typ.sym.info else: unknownLineInfo
localError(conf, info, "union type may not have an object header") localError(conf, info, "union type may not have an object header")
accum = OffsetAccum(offset: szUnknownSize, maxAlign: szUnknownSize) accum = OffsetAccum(offset: szUnknownSize, maxAlign: szUnknownSize)
else: else:

View file

@ -108,12 +108,12 @@ proc bailOut(c: PCtx; tos: PStackFrame) =
when not defined(nimComputedGoto): when not defined(nimComputedGoto):
{.pragma: computedGoto.} {.pragma: computedGoto.}
proc myreset(n: var TFullReg) = reset(n) proc ensureKind(n: var TFullReg, kind: TRegisterKind) =
if n.kind != kind:
n = TFullReg(kind: kind)
template ensureKind(k: untyped) {.dirty.} = template ensureKind(k: untyped) {.dirty.} =
if regs[ra].kind != k: ensureKind(regs[ra], k)
myreset(regs[ra])
regs[ra].kind = k
template decodeB(k: untyped) {.dirty.} = template decodeB(k: untyped) {.dirty.} =
let rb = instr.regB let rb = instr.regB
@ -146,10 +146,7 @@ proc derefPtrToReg(address: BiggestInt, typ: PType, r: var TFullReg, isAssign: b
if isAssign: if isAssign:
cast[ptr T](address)[] = T(r.field) cast[ptr T](address)[] = T(r.field)
else: else:
# ensureKind(rkind) r.ensureKind(rkind)
if r.kind != rkind:
myreset(r)
r.kind = rkind
let val = cast[ptr T](address)[] let val = cast[ptr T](address)[]
when T is SomeInteger: when T is SomeInteger:
r.field = BiggestInt(val) r.field = BiggestInt(val)
@ -180,8 +177,7 @@ proc createStrKeepNode(x: var TFullReg; keepNode=true) =
elif x.node.kind == nkNilLit and keepNode: elif x.node.kind == nkNilLit and keepNode:
when defined(useNodeIds): when defined(useNodeIds):
let id = x.node.id let id = x.node.id
system.reset(x.node[]) x.node[] = TNode(kind: nkStrLit)
x.node.kind = nkStrLit
when defined(useNodeIds): when defined(useNodeIds):
x.node.id = id x.node.id = id
elif x.node.kind notin {nkStrLit..nkTripleStrLit} or elif x.node.kind notin {nkStrLit..nkTripleStrLit} or
@ -201,9 +197,7 @@ template createSet(x) =
x.node = newNode(nkCurly) x.node = newNode(nkCurly)
proc moveConst(x: var TFullReg, y: TFullReg) = proc moveConst(x: var TFullReg, y: TFullReg) =
if x.kind != y.kind: x.ensureKind(y.kind)
myreset(x)
x.kind = y.kind
case x.kind case x.kind
of rkNone: discard of rkNone: discard
of rkInt: x.intVal = y.intVal of rkInt: x.intVal = y.intVal
@ -239,9 +233,7 @@ proc copyValue(src: PNode): PNode =
result[i] = copyValue(src[i]) result[i] = copyValue(src[i])
proc asgnComplex(x: var TFullReg, y: TFullReg) = proc asgnComplex(x: var TFullReg, y: TFullReg) =
if x.kind != y.kind: x.ensureKind(y.kind)
myreset(x)
x.kind = y.kind
case x.kind case x.kind
of rkNone: discard of rkNone: discard
of rkInt: x.intVal = y.intVal of rkInt: x.intVal = y.intVal
@ -251,9 +243,7 @@ proc asgnComplex(x: var TFullReg, y: TFullReg) =
of rkNodeAddr: x.nodeAddr = y.nodeAddr of rkNodeAddr: x.nodeAddr = y.nodeAddr
proc fastAsgnComplex(x: var TFullReg, y: TFullReg) = proc fastAsgnComplex(x: var TFullReg, y: TFullReg) =
if x.kind != y.kind: x.ensureKind(y.kind)
myreset(x)
x.kind = y.kind
case x.kind case x.kind
of rkNone: discard of rkNone: discard
of rkInt: x.intVal = y.intVal of rkInt: x.intVal = y.intVal
@ -267,8 +257,7 @@ proc writeField(n: var PNode, x: TFullReg) =
of rkNone: discard of rkNone: discard
of rkInt: of rkInt:
if n.kind == nkNilLit: if n.kind == nkNilLit:
n[].reset n[] = TNode(kind: nkIntLit) # ideally, `nkPtrLit`
n.kind = nkIntLit # ideally, `nkPtrLit`
n.intVal = x.intVal n.intVal = x.intVal
of rkFloat: n.floatVal = x.floatVal of rkFloat: n.floatVal = x.floatVal
of rkNode: n = copyValue(x.node) of rkNode: n = copyValue(x.node)
@ -276,26 +265,21 @@ proc writeField(n: var PNode, x: TFullReg) =
of rkNodeAddr: n = x.nodeAddr[] of rkNodeAddr: n = x.nodeAddr[]
proc putIntoReg(dest: var TFullReg; n: PNode) = proc putIntoReg(dest: var TFullReg; n: PNode) =
template funInt() =
dest.kind = rkInt
dest.intVal = n.intVal
case n.kind case n.kind
of nkStrLit..nkTripleStrLit: of nkStrLit..nkTripleStrLit:
dest.kind = rkNode dest = TFullReg(kind: rkNode, node: newStrNode(nkStrLit, n.strVal))
createStr(dest)
dest.node.strVal = n.strVal
of nkIntLit: # use `nkPtrLit` once this is added of nkIntLit: # use `nkPtrLit` once this is added
if dest.kind == rkNode: dest.node = n if dest.kind == rkNode: dest.node = n
elif n.typ != nil and n.typ.kind in PtrLikeKinds: elif n.typ != nil and n.typ.kind in PtrLikeKinds:
dest = TFullReg(kind: rkNode, node: n) dest = TFullReg(kind: rkNode, node: n)
else: funInt() else:
of {nkCharLit..nkUInt64Lit} - {nkIntLit}: funInt() dest = TFullReg(kind: rkInt, intVal: n.intVal)
of {nkCharLit..nkUInt64Lit} - {nkIntLit}:
dest = TFullReg(kind: rkInt, intVal: n.intVal)
of nkFloatLit..nkFloat128Lit: of nkFloatLit..nkFloat128Lit:
dest.kind = rkFloat dest = TFullReg(kind: rkFloat, floatVal: n.floatVal)
dest.floatVal = n.floatVal
else: else:
dest.kind = rkNode dest = TFullReg(kind: rkNode, node: n)
dest.node = n
proc regToNode(x: TFullReg): PNode = proc regToNode(x: TFullReg): PNode =
case x.kind case x.kind
@ -413,9 +397,7 @@ proc cleanUpOnReturn(c: PCtx; f: PStackFrame): int =
proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType): bool = proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType): bool =
if desttyp.kind == tyString: if desttyp.kind == tyString:
if dest.kind != rkNode: dest.ensureKind(rkNode)
myreset(dest)
dest.kind = rkNode
dest.node = newNode(nkStrLit) dest.node = newNode(nkStrLit)
let styp = srctyp.skipTypes(abstractRange) let styp = srctyp.skipTypes(abstractRange)
case styp.kind case styp.kind
@ -460,8 +442,7 @@ proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType):
else: else:
case skipTypes(desttyp, abstractVarRange).kind case skipTypes(desttyp, abstractVarRange).kind
of tyInt..tyInt64: of tyInt..tyInt64:
if dest.kind != rkInt: dest.ensureKind(rkInt)
myreset(dest); dest.kind = rkInt
case skipTypes(srctyp, abstractRange).kind case skipTypes(srctyp, abstractRange).kind
of tyFloat..tyFloat64: of tyFloat..tyFloat64:
dest.intVal = int(src.floatVal) dest.intVal = int(src.floatVal)
@ -470,8 +451,7 @@ proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType):
if toInt128(dest.intVal) < firstOrd(c.config, desttyp) or toInt128(dest.intVal) > lastOrd(c.config, desttyp): if toInt128(dest.intVal) < firstOrd(c.config, desttyp) or toInt128(dest.intVal) > lastOrd(c.config, desttyp):
return true return true
of tyUInt..tyUInt64: of tyUInt..tyUInt64:
if dest.kind != rkInt: dest.ensureKind(rkInt)
myreset(dest); dest.kind = rkInt
case skipTypes(srctyp, abstractRange).kind case skipTypes(srctyp, abstractRange).kind
of tyFloat..tyFloat64: of tyFloat..tyFloat64:
dest.intVal = int(src.floatVal) dest.intVal = int(src.floatVal)
@ -484,8 +464,7 @@ proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType):
value = (value shl destDist) shr destDist value = (value shl destDist) shr destDist
dest.intVal = cast[BiggestInt](value) dest.intVal = cast[BiggestInt](value)
of tyFloat..tyFloat64: of tyFloat..tyFloat64:
if dest.kind != rkFloat: dest.ensureKind(rkFloat)
myreset(dest); dest.kind = rkFloat
case skipTypes(srctyp, abstractRange).kind case skipTypes(srctyp, abstractRange).kind
of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyBool, tyChar: of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyBool, tyChar:
dest.floatVal = toBiggestFloat(src.intVal) dest.floatVal = toBiggestFloat(src.intVal)
@ -1206,8 +1185,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
var rcAddr = addr(regs[rc]) var rcAddr = addr(regs[rc])
if rcAddr.kind == rkRegisterAddr: rcAddr = rcAddr.regAddr if rcAddr.kind == rkRegisterAddr: rcAddr = rcAddr.regAddr
elif regs[rc].kind != rkFloat: elif regs[rc].kind != rkFloat:
myreset(regs[rc]) regs[rc] = TFullReg(kind: rkFloat)
regs[rc].kind = rkFloat
regs[ra].intVal = parseBiggestFloat(regs[rb].node.strVal, regs[ra].intVal = parseBiggestFloat(regs[rb].node.strVal,
rcAddr.floatVal, regs[rd].intVal.int) rcAddr.floatVal, regs[rd].intVal.int)
of opcRangeChck: of opcRangeChck:
@ -1267,8 +1245,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
for i in 1..rc-1: for i in 1..rc-1:
newFrame.slots[i] = regs[rb+i] newFrame.slots[i] = regs[rb+i]
if isClosure: if isClosure:
newFrame.slots[rc].kind = rkNode newFrame.slots[rc] = TFullReg(kind: rkNode, node: regs[rb].node[1])
newFrame.slots[rc].node = regs[rb].node[1]
tos = newFrame tos = newFrame
move(regs, newFrame.slots) move(regs, newFrame.slots)
# -1 for the following 'inc pc' # -1 for the following 'inc pc'
@ -1432,7 +1409,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
let rb = instr.regBx - wordExcess let rb = instr.regBx - wordExcess
let cnst = c.constants[rb] let cnst = c.constants[rb]
if fitsRegister(cnst.typ): if fitsRegister(cnst.typ):
myreset(regs[ra]) reset(regs[ra])
putIntoReg(regs[ra], cnst) putIntoReg(regs[ra], cnst)
else: else:
ensureKind(rkNode) ensureKind(rkNode)
@ -2259,13 +2236,12 @@ proc setupMacroParam(x: PNode, typ: PType): TFullReg =
of tyStatic: of tyStatic:
putIntoReg(result, prepareVMValue(x)) putIntoReg(result, prepareVMValue(x))
else: else:
result.kind = rkNode
var n = x var n = x
if n.kind in {nkHiddenSubConv, nkHiddenStdConv}: n = n[1] if n.kind in {nkHiddenSubConv, nkHiddenStdConv}: n = n[1]
n = n.canonValue n = n.canonValue
n.flags.incl nfIsRef n.flags.incl nfIsRef
n.typ = x.typ n.typ = x.typ
result.node = n result = TFullReg(kind: rkNode, node: n)
iterator genericParamsInMacroCall*(macroSym: PSym, call: PNode): (PSym, PNode) = iterator genericParamsInMacroCall*(macroSym: PSym, call: PNode): (PSym, PNode) =
let gp = macroSym.ast[genericParamsPos] let gp = macroSym.ast[genericParamsPos]
@ -2317,8 +2293,7 @@ proc evalMacroCall*(module: PSym; g: ModuleGraph;
#InternalAssert tos.slots.len >= L #InternalAssert tos.slots.len >= L
# return value: # return value:
tos.slots[0].kind = rkNode tos.slots[0] = TFullReg(kind: rkNode, node: newNodeI(nkEmpty, n.info))
tos.slots[0].node = newNodeI(nkEmpty, n.info)
# setup parameters: # setup parameters:
for i in 1..<sym.typ.len: for i in 1..<sym.typ.len:

View file

@ -260,7 +260,7 @@ proc newCtx*(module: PSym; cache: IdentCache; g: ModuleGraph): PCtx =
PCtx(code: @[], debug: @[], PCtx(code: @[], debug: @[],
globals: newNode(nkStmtListExpr), constants: newNode(nkStmtList), types: @[], globals: newNode(nkStmtListExpr), constants: newNode(nkStmtList), types: @[],
prc: PProc(blocks: @[]), module: module, loopIterations: MaxLoopIterations, prc: PProc(blocks: @[]), module: module, loopIterations: MaxLoopIterations,
comesFromHeuristic: unknownLineInfo(), callbacks: @[], errorFlag: "", comesFromHeuristic: unknownLineInfo, callbacks: @[], errorFlag: "",
cache: cache, config: g.config, graph: g) cache: cache, config: g.config, graph: g)
proc refresh*(c: PCtx, module: PSym) = proc refresh*(c: PCtx, module: PSym) =

View file

@ -12,9 +12,7 @@ import pathutils
template setX(k, field) {.dirty.} = template setX(k, field) {.dirty.} =
var s: seq[TFullReg] var s: seq[TFullReg]
move(s, cast[seq[TFullReg]](a.slots)) move(s, cast[seq[TFullReg]](a.slots))
if s[a.ra].kind != k: s[a.ra].ensureKind(k)
myreset(s[a.ra])
s[a.ra].kind = k
s[a.ra].field = v s[a.ra].field = v
proc setResult*(a: VmArgs; v: BiggestInt) = setX(rkInt, intVal) proc setResult*(a: VmArgs; v: BiggestInt) = setX(rkInt, intVal)
@ -26,18 +24,14 @@ proc setResult*(a: VmArgs; v: bool) =
proc setResult*(a: VmArgs; v: string) = proc setResult*(a: VmArgs; v: string) =
var s: seq[TFullReg] var s: seq[TFullReg]
move(s, cast[seq[TFullReg]](a.slots)) move(s, cast[seq[TFullReg]](a.slots))
if s[a.ra].kind != rkNode: s[a.ra].ensureKind(rkNode)
myreset(s[a.ra])
s[a.ra].kind = rkNode
s[a.ra].node = newNode(nkStrLit) s[a.ra].node = newNode(nkStrLit)
s[a.ra].node.strVal = v s[a.ra].node.strVal = v
proc setResult*(a: VmArgs; n: PNode) = proc setResult*(a: VmArgs; n: PNode) =
var s: seq[TFullReg] var s: seq[TFullReg]
move(s, cast[seq[TFullReg]](a.slots)) move(s, cast[seq[TFullReg]](a.slots))
if s[a.ra].kind != rkNode: s[a.ra].ensureKind(rkNode)
myreset(s[a.ra])
s[a.ra].kind = rkNode
s[a.ra].node = n s[a.ra].node = n
proc setResult*(a: VmArgs; v: AbsoluteDir) = setResult(a, v.string) proc setResult*(a: VmArgs; v: AbsoluteDir) = setResult(a, v.string)
@ -45,9 +39,7 @@ proc setResult*(a: VmArgs; v: AbsoluteDir) = setResult(a, v.string)
proc setResult*(a: VmArgs; v: seq[string]) = proc setResult*(a: VmArgs; v: seq[string]) =
var s: seq[TFullReg] var s: seq[TFullReg]
move(s, cast[seq[TFullReg]](a.slots)) move(s, cast[seq[TFullReg]](a.slots))
if s[a.ra].kind != rkNode: s[a.ra].ensureKind(rkNode)
myreset(s[a.ra])
s[a.ra].kind = rkNode
var n = newNode(nkBracket) var n = newNode(nkBracket)
for x in v: n.add newStrNode(nkStrLit, x) for x in v: n.add newStrNode(nkStrLit, x)
s[a.ra].node = n s[a.ra].node = n

View file

@ -224,7 +224,7 @@ proc loadAny(p: var JsonParser, t: PType,
if pos >= result.len: if pos >= result.len:
setLen(result.sons, pos + 1) setLen(result.sons, pos + 1)
let fieldNode = newNode(nkExprColonExpr) let fieldNode = newNode(nkExprColonExpr)
fieldNode.add newSymNode(newSym(skField, ident, nil, unknownLineInfo())) fieldNode.add newSymNode(newSym(skField, ident, nil, unknownLineInfo))
fieldNode.add loadAny(p, field.typ, tab, cache, conf) fieldNode.add loadAny(p, field.typ, tab, cache, conf)
result[pos] = fieldNode result[pos] = fieldNode
if p.kind == jsonObjectEnd: next(p) if p.kind == jsonObjectEnd: next(p)

View file

@ -1,2 +1 @@
--define: nimpretty --define: nimpretty
--define: nimOldCaseObjects

View file

@ -22,4 +22,3 @@ define:nimcore
#define:noDocgen #define:noDocgen
--path:"$nim" --path:"$nim"
--threads:on --threads:on
--define:nimOldCaseObjects

View file

@ -1 +0,0 @@
define:nimOldCaseObjects