diff options
Diffstat (limited to 'compiler')
35 files changed, 107 insertions, 107 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 63cab5998..c5b367977 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -799,7 +799,7 @@ type loc*: TLoc TPair*{.final.} = object - key*, val*: PObject + key*, val*: RootRef TPairSeq* = seq[TPair] TTable*{.final.} = object # the same as table[PObject] of PObject @@ -808,7 +808,7 @@ type TIdPair*{.final.} = object key*: PIdObj - val*: PObject + val*: RootRef TIdPairSeq* = seq[TIdPair] TIdTable*{.final.} = object # the same as table[PIdent] of PObject @@ -835,7 +835,7 @@ type counter*: int data*: TNodePairSeq - TObjectSeq* = seq[PObject] + TObjectSeq* = seq[RootRef] TObjectSet*{.final.} = object counter*: int data*: TObjectSeq diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index eb7ffc63e..e95dbf7c8 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -14,7 +14,7 @@ import ast, hashes, intsets, strutils, options, msgs, ropes, idents, rodutils -proc hashNode*(p: PObject): THash +proc hashNode*(p: RootRef): THash proc treeToYaml*(n: PNode, indent: int = 0, maxRecDepth: int = - 1): PRope # Convert a tree into its YAML representation; this is used by the # YAML code generator and it is invaluable for debugging purposes. @@ -24,21 +24,21 @@ proc symToYaml*(n: PSym, indent: int = 0, maxRecDepth: int = - 1): PRope proc lineInfoToStr*(info: TLineInfo): PRope # ----------------------- node sets: --------------------------------------- -proc objectSetContains*(t: TObjectSet, obj: PObject): bool +proc objectSetContains*(t: TObjectSet, obj: RootRef): bool # returns true whether n is in t -proc objectSetIncl*(t: var TObjectSet, obj: PObject) +proc objectSetIncl*(t: var TObjectSet, obj: RootRef) # include an element n in the table t -proc objectSetContainsOrIncl*(t: var TObjectSet, obj: PObject): bool +proc objectSetContainsOrIncl*(t: var TObjectSet, obj: RootRef): bool # more are not needed ... # ----------------------- (key, val)-Hashtables ---------------------------- -proc tablePut*(t: var TTable, key, val: PObject) -proc tableGet*(t: TTable, key: PObject): PObject +proc tablePut*(t: var TTable, key, val: RootRef) +proc tableGet*(t: TTable, key: RootRef): RootRef type - TCmpProc* = proc (key, closure: PObject): bool {.nimcall.} # true if found + TCmpProc* = proc (key, closure: RootRef): bool {.nimcall.} # true if found -proc tableSearch*(t: TTable, key, closure: PObject, - comparator: TCmpProc): PObject +proc tableSearch*(t: TTable, key, closure: RootRef, + comparator: TCmpProc): RootRef # return val as soon as comparator returns true; if this never happens, # nil is returned @@ -79,9 +79,9 @@ proc debug*(n: PType) {.deprecated.} proc debug*(n: PNode) {.deprecated.} # --------------------------- ident tables ---------------------------------- -proc idTableGet*(t: TIdTable, key: PIdObj): PObject -proc idTableGet*(t: TIdTable, key: int): PObject -proc idTablePut*(t: var TIdTable, key: PIdObj, val: PObject) +proc idTableGet*(t: TIdTable, key: PIdObj): RootRef +proc idTableGet*(t: TIdTable, key: int): RootRef +proc idTablePut*(t: var TIdTable, key: PIdObj, val: RootRef) proc idTableHasObjectAsKey*(t: TIdTable, key: PIdObj): bool # checks if `t` contains the `key` (compared by the pointer value, not only # `key`'s id) @@ -196,7 +196,7 @@ proc getSymFromList(list: PNode, ident: PIdent, start: int = 0): PSym = else: internalError(list.info, "getSymFromList") result = nil -proc hashNode(p: PObject): THash = +proc hashNode(p: RootRef): THash = result = hash(cast[pointer](p)) proc mustRehash(length, counter: int): bool = @@ -283,7 +283,7 @@ proc symToYamlAux(n: PSym, marker: var TIntSet, indent: int, result = toRope("null") elif containsOrIncl(marker, n.id): result = ropef("\"$1 @$2\"", [toRope(n.name.s), toRope( - strutils.toHex(cast[TAddress](n), sizeof(n) * 2))]) + strutils.toHex(cast[ByteAddress](n), sizeof(n) * 2))]) else: var ast = treeToYamlAux(n.ast, marker, indent + 2, maxRecDepth - 1) result = ropeConstr(indent, [toRope("kind"), @@ -304,7 +304,7 @@ proc typeToYamlAux(n: PType, marker: var TIntSet, indent: int, result = toRope("null") elif containsOrIncl(marker, n.id): result = ropef("\"$1 @$2\"", [toRope($n.kind), toRope( - strutils.toHex(cast[TAddress](n), sizeof(n) * 2))]) + strutils.toHex(cast[ByteAddress](n), sizeof(n) * 2))]) else: if sonsLen(n) > 0: result = toRope("[") @@ -469,7 +469,7 @@ proc nextTry(h, maxHash: THash): THash = # generates each int in range(maxHash) exactly once (see any text on # random-number generation for proof). -proc objectSetContains(t: TObjectSet, obj: PObject): bool = +proc objectSetContains(t: TObjectSet, obj: RootRef): bool = # returns true whether n is in t var h: THash = hashNode(obj) and high(t.data) # start with real hash value while t.data[h] != nil: @@ -478,7 +478,7 @@ proc objectSetContains(t: TObjectSet, obj: PObject): bool = h = nextTry(h, high(t.data)) result = false -proc objectSetRawInsert(data: var TObjectSeq, obj: PObject) = +proc objectSetRawInsert(data: var TObjectSeq, obj: RootRef) = var h: THash = hashNode(obj) and high(data) while data[h] != nil: assert(data[h] != obj) @@ -493,12 +493,12 @@ proc objectSetEnlarge(t: var TObjectSet) = if t.data[i] != nil: objectSetRawInsert(n, t.data[i]) swap(t.data, n) -proc objectSetIncl(t: var TObjectSet, obj: PObject) = +proc objectSetIncl(t: var TObjectSet, obj: RootRef) = if mustRehash(len(t.data), t.counter): objectSetEnlarge(t) objectSetRawInsert(t.data, obj) inc(t.counter) -proc objectSetContainsOrIncl(t: var TObjectSet, obj: PObject): bool = +proc objectSetContainsOrIncl(t: var TObjectSet, obj: RootRef): bool = # returns true if obj is already in the string table: var h: THash = hashNode(obj) and high(t.data) while true: @@ -516,7 +516,7 @@ proc objectSetContainsOrIncl(t: var TObjectSet, obj: PObject): bool = inc(t.counter) result = false -proc tableRawGet(t: TTable, key: PObject): int = +proc tableRawGet(t: TTable, key: RootRef): int = var h: THash = hashNode(key) and high(t.data) # start with real hash value while t.data[h].key != nil: if t.data[h].key == key: @@ -524,8 +524,8 @@ proc tableRawGet(t: TTable, key: PObject): int = h = nextTry(h, high(t.data)) result = -1 -proc tableSearch(t: TTable, key, closure: PObject, - comparator: TCmpProc): PObject = +proc tableSearch(t: TTable, key, closure: RootRef, + comparator: TCmpProc): RootRef = var h: THash = hashNode(key) and high(t.data) # start with real hash value while t.data[h].key != nil: if t.data[h].key == key: @@ -535,12 +535,12 @@ proc tableSearch(t: TTable, key, closure: PObject, h = nextTry(h, high(t.data)) result = nil -proc tableGet(t: TTable, key: PObject): PObject = +proc tableGet(t: TTable, key: RootRef): RootRef = var index = tableRawGet(t, key) if index >= 0: result = t.data[index].val else: result = nil -proc tableRawInsert(data: var TPairSeq, key, val: PObject) = +proc tableRawInsert(data: var TPairSeq, key, val: RootRef) = var h: THash = hashNode(key) and high(data) while data[h].key != nil: assert(data[h].key != key) @@ -556,7 +556,7 @@ proc tableEnlarge(t: var TTable) = if t.data[i].key != nil: tableRawInsert(n, t.data[i].key, t.data[i].val) swap(t.data, n) -proc tablePut(t: var TTable, key, val: PObject) = +proc tablePut(t: var TTable, key, val: RootRef) = var index = tableRawGet(t, key) if index >= 0: t.data[index].val = val @@ -740,22 +740,22 @@ proc idTableHasObjectAsKey(t: TIdTable, key: PIdObj): bool = if index >= 0: result = t.data[index].key == key else: result = false -proc idTableGet(t: TIdTable, key: PIdObj): PObject = +proc idTableGet(t: TIdTable, key: PIdObj): RootRef = var index = idTableRawGet(t, key.id) if index >= 0: result = t.data[index].val else: result = nil -proc idTableGet(t: TIdTable, key: int): PObject = +proc idTableGet(t: TIdTable, key: int): RootRef = var index = idTableRawGet(t, key) if index >= 0: result = t.data[index].val else: result = nil -iterator pairs*(t: TIdTable): tuple[key: int, value: PObject] = +iterator pairs*(t: TIdTable): tuple[key: int, value: RootRef] = for i in 0..high(t.data): if t.data[i].key != nil: yield (t.data[i].key.id, t.data[i].val) -proc idTableRawInsert(data: var TIdPairSeq, key: PIdObj, val: PObject) = +proc idTableRawInsert(data: var TIdPairSeq, key: PIdObj, val: RootRef) = var h: THash h = key.id and high(data) while data[h].key != nil: @@ -765,7 +765,7 @@ proc idTableRawInsert(data: var TIdPairSeq, key: PIdObj, val: PObject) = data[h].key = key data[h].val = val -proc idTablePut(t: var TIdTable, key: PIdObj, val: PObject) = +proc idTablePut(t: var TIdTable, key: PIdObj, val: RootRef) = var index: int n: TIdPairSeq @@ -784,7 +784,7 @@ proc idTablePut(t: var TIdTable, key: PIdObj, val: PObject) = idTableRawInsert(t.data, key, val) inc(t.counter) -iterator idTablePairs*(t: TIdTable): tuple[key: PIdObj, val: PObject] = +iterator idTablePairs*(t: TIdTable): tuple[key: PIdObj, val: RootRef] = for i in 0 .. high(t.data): if not isNil(t.data[i].key): yield (t.data[i].key, t.data[i].val) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index fc6febc6f..0bd96e89f 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -428,10 +428,10 @@ proc getRecordDesc(m: BModule, typ: PType, name: PRope, var hasField = false var attribute: PRope = - if tfPacked in typ.flags: toRope(CC[ccompiler].packedPragma) + if tfPacked in typ.flags: toRope(CC[cCompiler].packedPragma) else: nil - result = ropecg(m, CC[ccompiler].structStmtFmt, + result = ropecg(m, CC[cCompiler].structStmtFmt, [structOrUnion(typ), name, attribute]) if typ.kind == tyObject: diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim index 65957584a..48fdacf46 100644 --- a/compiler/ccgutils.nim +++ b/compiler/ccgutils.nim @@ -149,7 +149,7 @@ proc getUniqueType*(key: PType): PType = idTablePut(gTypeTable[k], key, key) result = key -proc tableGetType*(tab: TIdTable, key: PType): PObject = +proc tableGetType*(tab: TIdTable, key: PType): RootRef = # returns nil if we need to declare this type result = idTableGet(tab, key) if (result == nil) and (tab.counter > 0): diff --git a/compiler/commands.nim b/compiler/commands.nim index c15cc674c..712e0e1c5 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -284,7 +284,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = if pass in {passCmd2, passPP} and not options.gNoBabelPath: expectArg(switch, arg, pass, info) let path = processPath(arg, notRelativeToProj=true) - babelpath(path, info) + babelPath(path, info) of "nobabelpath": expectNoArg(switch, arg, pass, info) options.gNoBabelPath = true diff --git a/compiler/crc.nim b/compiler/crc.nim index ae1df3ff1..22b1d1b69 100644 --- a/compiler/crc.nim +++ b/compiler/crc.nim @@ -102,7 +102,7 @@ proc crcFromFile(filename: string): TCrc32 = const bufSize = 8000 # don't use 8K for the memory allocator! var - bin: TFile + bin: File result = InitCrc32 if not open(bin, filename): return # not equal if file does not exist diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 4c9803401..7d9a11fbc 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -374,11 +374,11 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) = cleanPlainSymbol = renderPlainSymbolName(nameNode) complexSymbol = complexName(k, n, cleanPlainSymbol) plainSymbolRope = toRope(cleanPlainSymbol) - plainSymbolEncRope = toRope(URLEncode(cleanPlainSymbol)) + plainSymbolEncRope = toRope(URLencode(cleanPlainSymbol)) itemIDRope = toRope(d.id) symbolOrId = d.newUniquePlainSymbol(complexSymbol) symbolOrIdRope = symbolOrId.toRope - symbolOrIdEncRope = URLEncode(symbolOrId).toRope + symbolOrIdEncRope = URLencode(symbolOrId).toRope var seeSrcRope: PRope = nil let docItemSeeSrc = getConfigVar("doc.item.seesrc") diff --git a/compiler/docgen2.nim b/compiler/docgen2.nim index d76be8e3c..1bff89b55 100644 --- a/compiler/docgen2.nim +++ b/compiler/docgen2.nim @@ -26,7 +26,7 @@ proc close(p: PPassContext, n: PNode): PNode = writeOutput(g.doc, g.module.filename, HtmlExt, useWarning) try: generateIndex(g.doc) - except EIO: + except IOError: discard proc processNode(c: PPassContext, n: PNode): PNode = diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index f0e5dad11..8dc399f43 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -551,7 +551,7 @@ proc footprint(filename: string): TCrc32 = proc externalFileChanged(filename: string): bool = var crcFile = toGeneratedFile(filename.withPackageName, "crc") var currentCrc = int(footprint(filename)) - var f: TFile + var f: File if open(f, crcFile, fmRead): var line = newStringOfCap(40) if not f.readLine(line): line = "0" diff --git a/compiler/idents.nim b/compiler/idents.nim index ec903826a..c37d94362 100644 --- a/compiler/idents.nim +++ b/compiler/idents.nim @@ -15,7 +15,7 @@ import hashes, strutils type - TIdObj* = object of TObject + TIdObj* = object of RootObj id*: int # unique id; use this for comparisons and not the pointers PIdObj* = ref TIdObj diff --git a/compiler/idgen.nim b/compiler/idgen.nim index d932e3d9d..7f137b885 100644 --- a/compiler/idgen.nim +++ b/compiler/idgen.nim @@ -53,7 +53,7 @@ proc saveMaxIds*(project: string) = f.close() proc loadMaxIds*(project: string) = - var f: TFile + var f: File if open(f, project.toGid, fmRead): var line = newStringOfCap(20) if f.readLine(line): diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 6c650eee3..c29d20a0a 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -128,7 +128,7 @@ type obj: PType PEnv = ref TEnv - TEnv {.final.} = object of TObject + TEnv {.final.} = object of RootObj attachedNode, replacementNode: PNode createdVar: PNode # if != nil it is a used environment; for closure # iterators this can be 'envParam.env' diff --git a/compiler/lexer.nim b/compiler/lexer.nim index ea51a1399..bcc02da9e 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -429,9 +429,9 @@ proc getNumber(L: var TLexer): TToken = elif result.tokType == tkInt16Lit and (result.iNumber < int16.low or result.iNumber > int16.high): lexMessage(L, errNumberOutOfRange, result.literal) - except EInvalidValue: + except ValueError: lexMessage(L, errInvalidNumber, result.literal) - except EOverflow, EOutOfRange: + except OverflowError, EOutOfRange: lexMessage(L, errNumberOutOfRange, result.literal) L.bufpos = endpos @@ -519,7 +519,7 @@ proc handleCRLF(L: var TLexer, pos: int): int = lexMessagePos(L, hintLineTooLong, pos) if optEmbedOrigSrc in gGlobalOptions: - let lineStart = cast[TAddress](L.buf) + L.lineStart + let lineStart = cast[ByteAddress](L.buf) + L.lineStart let line = newString(cast[cstring](lineStart), col) addSourceLine(L.fileIdx, line) diff --git a/compiler/lists.nim b/compiler/lists.nim index efffe60fe..2b3a9f3fc 100644 --- a/compiler/lists.nim +++ b/compiler/lists.nim @@ -12,7 +12,7 @@ import os type PListEntry* = ref TListEntry - TListEntry* = object of TObject + TListEntry* = object of RootObj prev*, next*: PListEntry TStrEntry* = object of TListEntry diff --git a/compiler/llstream.nim b/compiler/llstream.nim index 5aefd468a..8dc3dcea3 100644 --- a/compiler/llstream.nim +++ b/compiler/llstream.nim @@ -21,9 +21,9 @@ type llsString, # stream encapsulates a string llsFile, # stream encapsulates a file llsStdIn # stream encapsulates stdin - TLLStream* = object of TObject + TLLStream* = object of RootObj kind*: TLLStreamKind # accessible for low-level access (lexbase uses this) - f*: TFile + f*: File s*: string rd*, wr*: int # for string streams lineOffset*: int # for fake stdin line numbers @@ -31,8 +31,8 @@ type PLLStream* = ref TLLStream proc llStreamOpen*(data: string): PLLStream -proc llStreamOpen*(f: var TFile): PLLStream -proc llStreamOpen*(filename: string, mode: TFileMode): PLLStream +proc llStreamOpen*(f: var File): PLLStream +proc llStreamOpen*(filename: string, mode: FileMode): PLLStream proc llStreamOpen*(): PLLStream proc llStreamOpenStdIn*(): PLLStream proc llStreamClose*(s: PLLStream) @@ -50,12 +50,12 @@ proc llStreamOpen(data: string): PLLStream = result.s = data result.kind = llsString -proc llStreamOpen(f: var TFile): PLLStream = +proc llStreamOpen(f: var File): PLLStream = new(result) result.f = f result.kind = llsFile -proc llStreamOpen(filename: string, mode: TFileMode): PLLStream = +proc llStreamOpen(filename: string, mode: FileMode): PLLStream = new(result) result.kind = llsFile if not open(result.f, filename, mode): result = nil diff --git a/compiler/lowerings.nim b/compiler/lowerings.nim index ddfcb4f01..c4155724f 100644 --- a/compiler/lowerings.nim +++ b/compiler/lowerings.nim @@ -260,7 +260,7 @@ proc createWrapperProc(f: PNode; threadParam, argsParam: PSym; threadLocalBarrier = addLocalVar(varSection2, nil, argsParam.owner, barrier.typ, barrier) body.add varSection2 - body.add callCodeGenProc("barrierEnter", threadLocalBarrier.newSymNode) + body.add callCodegenProc("barrierEnter", threadLocalBarrier.newSymNode) var threadLocalProm: PSym if spawnKind == srByVar: threadLocalProm = addLocalVar(varSection, nil, argsParam.owner, fv.typ, fv) @@ -275,7 +275,7 @@ proc createWrapperProc(f: PNode; threadParam, argsParam: PSym; body.add newAsgnStmt(indirectAccess(threadLocalProm.newSymNode, "owner", fv.info), threadParam.newSymNode) - body.add callCodeGenProc("nimArgsPassingDone", threadParam.newSymNode) + body.add callCodegenProc("nimArgsPassingDone", threadParam.newSymNode) if spawnKind == srByVar: body.add newAsgnStmt(genDeref(threadLocalProm.newSymNode), call) elif fv != nil: @@ -288,11 +288,11 @@ proc createWrapperProc(f: PNode; threadParam, argsParam: PSym; if barrier == nil: # by now 'fv' is shared and thus might have beeen overwritten! we need # to use the thread-local view instead: - body.add callCodeGenProc("nimFlowVarSignal", threadLocalProm.newSymNode) + body.add callCodegenProc("nimFlowVarSignal", threadLocalProm.newSymNode) else: body.add call if barrier != nil: - body.add callCodeGenProc("barrierLeave", threadLocalBarrier.newSymNode) + body.add callCodegenProc("barrierLeave", threadLocalBarrier.newSymNode) var params = newNodeI(nkFormalParams, f.info) params.add emptyNode @@ -542,7 +542,7 @@ proc wrapProcForSpawn*(owner: PSym; spawnExpr: PNode; retType: PType; # create flowVar: result.add newFastAsgnStmt(fvField, callProc(spawnExpr[2])) if barrier == nil: - result.add callCodeGenProc("nimFlowVarCreateCondVar", fvField) + result.add callCodegenProc("nimFlowVarCreateCondVar", fvField) elif spawnKind == srByVar: var field = newSym(skField, getIdent"fv", owner, n.info) @@ -555,7 +555,7 @@ proc wrapProcForSpawn*(owner: PSym; spawnExpr: PNode; retType: PType; let wrapper = createWrapperProc(fn, threadParam, argsParam, varSection, varInit, call, barrierAsExpr, fvAsExpr, spawnKind) - result.add callCodeGenProc("nimSpawn", wrapper.newSymNode, + result.add callCodegenProc("nimSpawn", wrapper.newSymNode, genAddrOf(scratchObj.newSymNode)) if spawnKind == srFlowVar: result.add fvField diff --git a/compiler/modules.nim b/compiler/modules.nim index b102224cd..65c438cc3 100644 --- a/compiler/modules.nim +++ b/compiler/modules.nim @@ -177,7 +177,7 @@ proc includeModule*(s: PSym, fileIdx: int32): PNode {.procvar.} = proc `==^`(a, b: string): bool = try: result = sameFile(a, b) - except EOS: + except OSError: result = false proc compileSystemModule* = diff --git a/compiler/msgs.nim b/compiler/msgs.nim index cd5b34194..00f80a438 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -468,8 +468,8 @@ type TErrorOutputs* = set[TErrorOutput] - ERecoverableError* = object of EInvalidValue - ESuggestDone* = object of E_Base + ERecoverableError* = object of ValueError + ESuggestDone* = object of Exception const InvalidFileIDX* = int32(-1) @@ -858,7 +858,7 @@ proc sourceLine*(i: TLineInfo): PRope = try: for line in lines(i.toFullPath): addSourceLine i.fileIndex, line.string - except EIO: + except IOError: discard internalAssert i.fileIndex < fileInfos.len # can happen if the error points to EOF: diff --git a/compiler/nimlexbase.nim b/compiler/nimlexbase.nim index 038573c35..cabcac390 100644 --- a/compiler/nimlexbase.nim +++ b/compiler/nimlexbase.nim @@ -37,7 +37,7 @@ const NewLines* = {CR, LF} type - TBaseLexer* = object of TObject + TBaseLexer* = object of RootObj bufpos*: int buf*: cstring bufLen*: int # length of buffer in characters diff --git a/compiler/nimrod.nim b/compiler/nimrod.nim index 618d98698..69cb8bb99 100644 --- a/compiler/nimrod.nim +++ b/compiler/nimrod.nim @@ -40,7 +40,7 @@ proc handleCmdLine() = if gProjectName != "": try: gProjectFull = canonicalizePath(gProjectName) - except EOS: + except OSError: gProjectFull = gProjectName var p = splitFile(gProjectFull) gProjectPath = p.dir diff --git a/compiler/options.nim b/compiler/options.nim index 02719cacc..8acf9e830 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -295,7 +295,7 @@ proc completeGeneratedFilePath*(f: string, createSubDir: bool = true): string = createDir(subdir) when noTimeMachine: excludeDirFromTimeMachine(subdir) - except EOS: + except OSError: writeln(stdout, "cannot create directory: " & subdir) quit(1) result = joinPath(subdir, tail) diff --git a/compiler/parser.nim b/compiler/parser.nim index 6ff0c2dfc..548084974 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -84,7 +84,7 @@ proc openParser*(p: var TParser, fileIdx: int32, inputStream: PLLStream, proc openParser*(p: var TParser, filename: string, inputStream: PLLStream, strongSpaces=false) = - openParser(p, filename.fileInfoIdx, inputstream, strongSpaces) + openParser(p, filename.fileInfoIdx, inputStream, strongSpaces) proc closeParser(p: var TParser) = ## Close a parser, freeing up its resources. diff --git a/compiler/passes.nim b/compiler/passes.nim index 66a1a4954..1af9739bd 100644 --- a/compiler/passes.nim +++ b/compiler/passes.nim @@ -16,7 +16,7 @@ import nimsets, syntaxes, times, rodread, idgen type - TPassContext* = object of TObject # the pass's context + TPassContext* = object of RootObj # the pass's context fromCache*: bool # true if created by "openCached" PPassContext* = ref TPassContext diff --git a/compiler/pretty.nim b/compiler/pretty.nim index 8d20d205b..5f990a658 100644 --- a/compiler/pretty.nim +++ b/compiler/pretty.nim @@ -38,7 +38,7 @@ proc overwriteFiles*() = f.write line f.write("\L") f.close - except EIO: + except IOError: rawMessage(errCannotOpenFile, newFile) proc `=~`(s: string, a: openArray[string]): bool = diff --git a/compiler/prettybase.nim b/compiler/prettybase.nim index 581114441..baf2484e4 100644 --- a/compiler/prettybase.nim +++ b/compiler/prettybase.nim @@ -41,7 +41,7 @@ proc differ*(line: string, a, b: int, x: string): bool = let y = line[a..b] result = cmpIgnoreStyle(y, x) == 0 and y != x -proc replaceDeprecated*(info: TlineInfo; oldSym, newSym: PSym) = +proc replaceDeprecated*(info: TLineInfo; oldSym, newSym: PSym) = loadFile(info) let line = gSourceFiles[info.fileIndex].lines[info.line-1] diff --git a/compiler/renderer.nim b/compiler/renderer.nim index c97b2f321..e01916920 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -1306,7 +1306,7 @@ proc renderTree(n: PNode, renderFlags: TRenderFlags = {}): string = proc renderModule(n: PNode, filename: string, renderFlags: TRenderFlags = {}) = var - f: TFile + f: File g: TSrcGen initSrcGen(g, renderFlags) for i in countup(0, sonsLen(n) - 1): diff --git a/compiler/rodread.nim b/compiler/rodread.nim index 036e6cc3c..47020253f 100644 --- a/compiler/rodread.nim +++ b/compiler/rodread.nim @@ -121,7 +121,7 @@ type r*: string # writers use this offset*: int # readers use this - TRodReader* = object of TObject + TRodReader* = object of RootObj pos: int # position; used for parsing s: cstring # mmap'ed file contents options: TOptions @@ -503,7 +503,7 @@ proc processCompilerProcs(r: PRodReader, module: PSym) = idTablePut(r.syms, s, s) strTableAdd(rodCompilerprocs, s) -proc processIndex(r: PRodReader; idx: var TIndex; outf: TFile = nil) = +proc processIndex(r: PRodReader; idx: var TIndex; outf: File = nil) = var key, val, tmp: int inc(r.pos, 2) # skip "(\10" inc(r.line) @@ -659,7 +659,7 @@ proc newRodReader(modfilename: string, crc: TCrc32, new(result) try: result.memfile = memfiles.open(modfilename) - except EOS: + except OSError: return nil result.files = @[] result.modDeps = @[] @@ -916,7 +916,7 @@ initIdTable(gTypeTable) initStrTable(rodCompilerprocs) # viewer: -proc writeNode(f: TFile; n: PNode) = +proc writeNode(f: File; n: PNode) = f.write("(") if n != nil: f.write($n.kind) @@ -947,7 +947,7 @@ proc writeNode(f: TFile; n: PNode) = writeNode(f, n.sons[i]) f.write(")") -proc writeSym(f: TFile; s: PSym) = +proc writeSym(f: File; s: PSym) = if s == nil: f.write("{}\n") return @@ -985,7 +985,7 @@ proc writeSym(f: TFile; s: PSym) = f.writeNode(s.ast) f.write("}\n") -proc writeType(f: TFile; t: PType) = +proc writeType(f: File; t: PType) = if t == nil: f.write("[]\n") return diff --git a/compiler/rodwrite.nim b/compiler/rodwrite.nim index 4231da2d0..4948c8fc2 100644 --- a/compiler/rodwrite.nim +++ b/compiler/rodwrite.nim @@ -422,7 +422,7 @@ proc addStmt(w: PRodWriter, n: PNode) = proc writeRod(w: PRodWriter) = processStacks(w, true) - var f: TFile + var f: File if not open(f, completeGeneratedFilePath(changeFileExt( w.filename.withPackageName, RodExt)), fmWrite): diff --git a/compiler/ropes.nim b/compiler/ropes.nim index fcf5dd202..6eb3673b4 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -64,7 +64,7 @@ type # copy the format strings # though it is not necessary) PRope* = ref TRope - TRope*{.acyclic.} = object of TObject # the empty rope is represented + TRope*{.acyclic.} = object of RootObj # the empty rope is represented # by nil to safe space left*, right*: PRope length*: int @@ -216,7 +216,7 @@ proc app(a: var PRope, b: PRope) = a = con(a, b) proc app(a: var PRope, b: string) = a = con(a, b) proc prepend(a: var PRope, b: PRope) = a = con(b, a) -proc writeRope*(f: TFile, c: PRope) = +proc writeRope*(f: File, c: PRope) = var stack = @[c] while len(stack) > 0: var it = pop(stack) @@ -228,7 +228,7 @@ proc writeRope*(f: TFile, c: PRope) = write(f, it.data) proc writeRope*(head: PRope, filename: string, useWarning = false) = - var f: TFile + var f: File if open(f, filename, fmWrite): if head != nil: writeRope(f, head) close(f) @@ -299,7 +299,7 @@ proc appf(c: var PRope, frmt: TFormatStr, args: varargs[PRope]) = const bufSize = 1024 # 1 KB is reasonable -proc auxRopeEqualsFile(r: PRope, bin: var TFile, buf: pointer): bool = +proc auxRopeEqualsFile(r: PRope, bin: var File, buf: pointer): bool = if r.data != nil: if r.length > bufSize: errorHandler(rTokenTooLong, r.data) @@ -312,7 +312,7 @@ proc auxRopeEqualsFile(r: PRope, bin: var TFile, buf: pointer): bool = if result: result = auxRopeEqualsFile(r.right, bin, buf) proc ropeEqualsFile(r: PRope, f: string): bool = - var bin: TFile + var bin: File result = open(bin, f) if not result: return # not equal if file does not exist diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 30e02dcc9..8e53fd670 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -683,9 +683,9 @@ proc getConstExpr(m: PSym, n: PNode): PNode = result = evalIs(n, a) else: result = magicCall(m, n) - except EOverflow: + except OverflowError: localError(n.info, errOverOrUnderflow) - except EDivByZero: + except DivByZeroError: localError(n.info, errConstantDivisionByZero) of nkAddr: var a = getConstExpr(m, n.sons[0]) diff --git a/compiler/semmacrosanity.nim b/compiler/semmacrosanity.nim index 1bece95c2..8106aa179 100644 --- a/compiler/semmacrosanity.nim +++ b/compiler/semmacrosanity.nim @@ -55,7 +55,7 @@ proc annotateType*(n: PNode, t: PType) = else: globalError(n.info, "() must have an object or tuple type") of nkBracket: - if x.kind in {tyArrayConstr, tyArray, tySequence, tyOpenarray}: + if x.kind in {tyArrayConstr, tyArray, tySequence, tyOpenArray}: n.typ = t for m in n: annotateType(m, x.elemType) else: diff --git a/compiler/semparallel.nim b/compiler/semparallel.nim index 7c489c3b6..5571d1bed 100644 --- a/compiler/semparallel.nim +++ b/compiler/semparallel.nim @@ -320,7 +320,7 @@ proc analyse(c: var AnalysisCtx; n: PNode) = # since we already ensure sfAddrTaken is not in s.flags, we only need to # prevent direct assignments to the monotonic variable: let slot = c.getSlot(n[0].sym) - slot.blackListed = true + slot.blacklisted = true invalidateFacts(c.guards, n[0]) analyseSons(c, n) addAsgnFact(c.guards, n[0], n[1]) @@ -464,6 +464,6 @@ proc liftParallel*(owner: PSym; n: PNode): PNode = result = newNodeI(nkStmtList, n.info) generateAliasChecks(a, result) result.add varSection - result.add callCodeGenProc("openBarrier", barrier) + result.add callCodegenProc("openBarrier", barrier) result.add transformSpawn(owner, body, barrier) - result.add callCodeGenProc("closeBarrier", barrier) + result.add callCodegenProc("closeBarrier", barrier) diff --git a/compiler/syntaxes.nim b/compiler/syntaxes.nim index d5062544f..8de6dcd91 100644 --- a/compiler/syntaxes.nim +++ b/compiler/syntaxes.nim @@ -44,7 +44,7 @@ proc parseTopLevelStmt*(p: var TParsers): PNode proc parseFile(fileIdx: int32): PNode = var p: TParsers - f: TFile + f: File let filename = fileIdx.toFullPath if not open(f, filename): rawMessage(errCannotOpenFile, filename) diff --git a/compiler/types.nim b/compiler/types.nim index ec2271deb..ba796b6c3 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -24,13 +24,13 @@ proc getProcHeader*(sym: PSym): string proc base*(t: PType): PType # ------------------- type iterator: ---------------------------------------- type - TTypeIter* = proc (t: PType, closure: PObject): bool {.nimcall.} # true if iteration should stop - TTypeMutator* = proc (t: PType, closure: PObject): PType {.nimcall.} # copy t and mutate it + TTypeIter* = proc (t: PType, closure: RootRef): bool {.nimcall.} # true if iteration should stop + TTypeMutator* = proc (t: PType, closure: RootRef): PType {.nimcall.} # copy t and mutate it TTypePredicate* = proc (t: PType): bool {.nimcall.} -proc iterOverType*(t: PType, iter: TTypeIter, closure: PObject): bool +proc iterOverType*(t: PType, iter: TTypeIter, closure: RootRef): bool # Returns result of `iter`. -proc mutateType*(t: PType, iter: TTypeMutator, closure: PObject): PType +proc mutateType*(t: PType, iter: TTypeMutator, closure: RootRef): PType # Returns result of `iter`. type @@ -161,9 +161,9 @@ proc enumHasHoles(t: PType): bool = result = b.kind == tyEnum and tfEnumHasHoles in b.flags proc iterOverTypeAux(marker: var TIntSet, t: PType, iter: TTypeIter, - closure: PObject): bool + closure: RootRef): bool proc iterOverNode(marker: var TIntSet, n: PNode, iter: TTypeIter, - closure: PObject): bool = + closure: RootRef): bool = if n != nil: case n.kind of nkNone..nkNilLit: @@ -175,7 +175,7 @@ proc iterOverNode(marker: var TIntSet, n: PNode, iter: TTypeIter, if result: return proc iterOverTypeAux(marker: var TIntSet, t: PType, iter: TTypeIter, - closure: PObject): bool = + closure: RootRef): bool = result = false if t == nil: return result = iter(t, closure) @@ -190,7 +190,7 @@ proc iterOverTypeAux(marker: var TIntSet, t: PType, iter: TTypeIter, if result: return if t.n != nil: result = iterOverNode(marker, t.n, iter, closure) -proc iterOverType(t: PType, iter: TTypeIter, closure: PObject): bool = +proc iterOverType(t: PType, iter: TTypeIter, closure: RootRef): bool = var marker = initIntSet() result = iterOverTypeAux(marker, t, iter, closure) @@ -354,9 +354,9 @@ proc canFormAcycle(typ: PType): bool = result = canFormAcycleAux(marker, typ, typ.id) proc mutateTypeAux(marker: var TIntSet, t: PType, iter: TTypeMutator, - closure: PObject): PType + closure: RootRef): PType proc mutateNode(marker: var TIntSet, n: PNode, iter: TTypeMutator, - closure: PObject): PNode = + closure: RootRef): PNode = result = nil if n != nil: result = copyNode(n) @@ -370,7 +370,7 @@ proc mutateNode(marker: var TIntSet, n: PNode, iter: TTypeMutator, addSon(result, mutateNode(marker, n.sons[i], iter, closure)) proc mutateTypeAux(marker: var TIntSet, t: PType, iter: TTypeMutator, - closure: PObject): PType = + closure: RootRef): PType = result = nil if t == nil: return result = iter(t, closure) @@ -380,7 +380,7 @@ proc mutateTypeAux(marker: var TIntSet, t: PType, iter: TTypeMutator, if t.n != nil: result.n = mutateNode(marker, t.n, iter, closure) assert(result != nil) -proc mutateType(t: PType, iter: TTypeMutator, closure: PObject): PType = +proc mutateType(t: PType, iter: TTypeMutator, closure: RootRef): PType = var marker = initIntSet() result = mutateTypeAux(marker, t, iter, closure) @@ -1283,7 +1283,7 @@ proc getSize(typ: PType): BiggestInt = result = computeSize(typ) if result < 0: internalError("getSize: " & $typ.kind) -proc containsGenericTypeIter(t: PType, closure: PObject): bool = +proc containsGenericTypeIter(t: PType, closure: RootRef): bool = if t.kind == tyStatic: return t.n == nil diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 9a213d813..c0916fbd8 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -33,6 +33,6 @@ proc opSlurp*(file: string, info: TLineInfo, module: PSym): string = # the module dependencies are accurate: appendToModule(module, newNode(nkIncludeStmt, info, @[ newStrNode(nkStrLit, filename)])) - except EIO: + except IOError: localError(info, errCannotOpenFile, file) result = "" |