diff options
author | Araq <rumpf_a@web.de> | 2019-07-10 12:42:23 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2019-07-10 12:42:41 +0200 |
commit | c94647aecad6ed7fd12152800437a6cda11e06e6 (patch) | |
tree | f876ae0ac6379dfd99fd5d5ed7d8903be96b433b /compiler | |
parent | 96523cdd3e8ada367b804efbd47f4763a1269fa8 (diff) | |
download | Nim-c94647aecad6ed7fd12152800437a6cda11e06e6.tar.gz |
styleCheck: make the compiler and large parts of the stdlib compatible with --styleCheck:error
Diffstat (limited to 'compiler')
42 files changed, 185 insertions, 192 deletions
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index b13e00320..0950a301d 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -156,7 +156,7 @@ proc genArg(p: BProc, n: PNode, param: PSym; call: PNode): Rope = # means '*T'. See posix.nim for lots of examples that do that in the wild. let callee = call.sons[0] if callee.kind == nkSym and - {sfImportC, sfInfixCall, sfCompilerProc} * callee.sym.flags == {sfImportC} and + {sfImportc, sfInfixCall, sfCompilerProc} * callee.sym.flags == {sfImportc} and {lfHeader, lfNoDecl} * callee.sym.loc.flags != {}: result = addrLoc(p.config, a) else: diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 140f7e1d4..a155c1d98 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -76,7 +76,7 @@ proc genLiteral(p: BProc, n: PNode, ty: PType): Rope = # with the new semantics for 'nil' strings, we can map "" to nil and # save tons of allocations: if n.strVal.len == 0 and optNilSeqs notin p.options and - p.config.selectedGc != gcDestructors: + p.config.selectedGC != gcDestructors: result = genNilStringLiteral(p.module, n.info) else: result = genStringLiteral(p.module, n) @@ -1065,7 +1065,7 @@ proc gcUsage(conf: ConfigRef; n: PNode) = if conf.selectedGC == gcNone: message(conf, n.info, warnGcMem, n.renderTree) proc strLoc(p: BProc; d: TLoc): Rope = - if p.config.selectedGc == gcDestructors: + if p.config.selectedGC == gcDestructors: result = byRefLoc(p, d) else: result = rdLoc(d) @@ -1657,7 +1657,7 @@ proc makeAddr(n: PNode): PNode = result.typ = makePtrType(n.typ) proc genSetLengthSeq(p: BProc, e: PNode, d: var TLoc) = - if p.config.selectedGc == gcDestructors: + if p.config.selectedGC == gcDestructors: e.sons[1] = makeAddr(e[1]) genCall(p, e, d) return @@ -1686,7 +1686,7 @@ proc genSetLengthSeq(p: BProc, e: PNode, d: var TLoc) = gcUsage(p.config, e) proc genSetLengthStr(p: BProc, e: PNode, d: var TLoc) = - if p.config.selectedGc == gcDestructors: + if p.config.selectedGC == gcDestructors: binaryStmtAddr(p, e, d, "setLengthStrV2") else: var a, b, call: TLoc @@ -1900,7 +1900,7 @@ proc genSomeCast(p: BProc, e: PNode, d: var TLoc) = if srcTyp.kind in {tyPtr, tyPointer} and etyp.kind in IntegralTypes: putIntoDest(p, d, e, "(($1) (ptrdiff_t) ($2))" % [getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.storage) - elif p.config.selectedGc == gcDestructors and etyp.kind in {tySequence, tyString}: + elif p.config.selectedGC == gcDestructors and etyp.kind in {tySequence, tyString}: putIntoDest(p, d, e, "(*($1*) (&$2))" % [getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.storage) else: @@ -2134,7 +2134,7 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) = genAssignment(p, dest, call, {}) of mAppendStrStr: genStrAppend(p, e, d) of mAppendSeqElem: - if p.config.selectedGc == gcDestructors: + if p.config.selectedGC == gcDestructors: e.sons[1] = makeAddr(e[1]) genCall(p, e, d) else: @@ -2773,7 +2773,7 @@ proc getNullValueAuxT(p: BProc; orig, t: PType; obj, cons: PNode, inc count getNullValueAux(p, t, obj, cons, result, count) # do not emit '{}' as that is not valid C: - if oldcount == count: result = oldres + if oldcount == count: result = oldRes elif not p.module.compileToCpp: result.add "}" proc genConstObjConstr(p: BProc; n: PNode): Rope = @@ -2847,7 +2847,7 @@ proc genConstExpr(p: BProc, n: PNode): Rope = of nkBracket, nkPar, nkTupleConstr, nkClosure: var t = skipTypes(n.typ, abstractInstOwned) if t.kind == tySequence: - if p.config.selectedGc == gcDestructors: + if p.config.selectedGC == gcDestructors: result = genConstSeqV2(p, n, n.typ) else: result = genConstSeq(p, n, n.typ) @@ -2871,7 +2871,7 @@ proc genConstExpr(p: BProc, n: PNode): Rope = of nkObjConstr: result = genConstObjConstr(p, n) of nkStrLit..nkTripleStrLit: - if p.config.selectedGc == gcDestructors: + if p.config.selectedGC == gcDestructors: result = genStringLiteralV2Const(p.module, n) else: var d: TLoc diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index 7c5286d90..6190cb3f6 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -15,7 +15,7 @@ const stringCaseThreshold = 8 # above X strings a hash-switch for strings is generated -proc getTraverseProc(p: BProc, v: Psym): Rope = +proc getTraverseProc(p: BProc, v: PSym): Rope = if p.config.selectedGC in {gcMarkAndSweep, gcDestructors, gcV2, gcRefc} and optNimV2 notin p.config.globalOptions and containsGarbageCollectedRef(v.loc.t): diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 727cf9c8e..4055789b7 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -978,7 +978,7 @@ proc getNimNode(m: BModule): Rope = result = "$1[$2]" % [m.typeNodesName, rope(m.typeNodes)] inc(m.typeNodes) -proc TINameForHcr(m: BModule, name: Rope): Rope = +proc tiNameForHcr(m: BModule, name: Rope): Rope = return if m.hcrOn: "(*".rope & name & ")" else: name proc genTypeInfoAuxBase(m: BModule; typ, origType: PType; @@ -990,7 +990,7 @@ proc genTypeInfoAuxBase(m: BModule; typ, origType: PType; else: nimtypeKind = ord(typ.kind) - let nameHcr = TINameForHcr(m, name) + let nameHcr = tiNameForHcr(m, name) var size: Rope if tfIncompleteStruct in typ.flags: size = rope"void*" @@ -1012,7 +1012,7 @@ proc genTypeInfoAuxBase(m: BModule; typ, origType: PType; if typename == "ref object" and origType.skipTypes(skipPtrs).sym != nil: typename = "anon ref object from " & m.config$origType.skipTypes(skipPtrs).sym.info addf(m.s[cfsTypeInit3], "$1.name = $2;$n", - [nameHcr, makeCstring typename]) + [nameHcr, makeCString typename]) discard cgsym(m, "nimTypeRoot") addf(m.s[cfsTypeInit3], "$1.nextType = nimTypeRoot; nimTypeRoot=&$1;$n", [nameHcr]) @@ -1142,7 +1142,7 @@ proc genObjectInfo(m: BModule, typ, origType: PType, name: Rope; info: TLineInfo var tmp = getNimNode(m) if not isImportedType(typ): genObjectFields(m, typ, origType, typ.n, tmp, info) - addf(m.s[cfsTypeInit3], "$1.node = &$2;$n", [TINameForHcr(m, name), tmp]) + addf(m.s[cfsTypeInit3], "$1.node = &$2;$n", [tiNameForHcr(m, name), tmp]) var t = typ.sons[0] while t != nil: t = t.skipTypes(skipPtrs) @@ -1170,7 +1170,7 @@ proc genTupleInfo(m: BModule, typ, origType: PType, name: Rope; info: TLineInfo) else: addf(m.s[cfsTypeInit3], "$1.len = $2; $1.kind = 2;$n", [expr, rope(length)]) - addf(m.s[cfsTypeInit3], "$1.node = &$2;$n", [TINameForHcr(m, name), expr]) + addf(m.s[cfsTypeInit3], "$1.node = &$2;$n", [tiNameForHcr(m, name), expr]) proc genEnumInfo(m: BModule, typ: PType, name: Rope; info: TLineInfo) = # Type information for enumerations is quite heavy, so we do some @@ -1209,17 +1209,17 @@ proc genEnumInfo(m: BModule, typ: PType, name: Rope; info: TLineInfo) = add(m.s[cfsTypeInit3], specialCases) addf(m.s[cfsTypeInit3], "$1.len = $2; $1.kind = 2; $1.sons = &$3[0];$n$4.node = &$1;$n", - [getNimNode(m), rope(length), nodePtrs, TINameForHcr(m, name)]) + [getNimNode(m), rope(length), nodePtrs, tiNameForHcr(m, name)]) if hasHoles: # 1 << 2 is {ntfEnumHole} - addf(m.s[cfsTypeInit3], "$1.flags = 1<<2;$n", [TINameForHcr(m, name)]) + addf(m.s[cfsTypeInit3], "$1.flags = 1<<2;$n", [tiNameForHcr(m, name)]) proc genSetInfo(m: BModule, typ: PType, name: Rope; info: TLineInfo) = assert(typ.sons[0] != nil) genTypeInfoAux(m, typ, typ, name, info) var tmp = getNimNode(m) addf(m.s[cfsTypeInit3], "$1.len = $2; $1.kind = 0;$n" & "$3.node = &$1;$n", - [tmp, rope(firstOrd(m.config, typ)), TINameForHcr(m, name)]) + [tmp, rope(firstOrd(m.config, typ)), tiNameForHcr(m, name)]) proc genArrayInfo(m: BModule, typ: PType, name: Rope; info: TLineInfo) = genTypeInfoAuxBase(m, typ, typ, name, genTypeInfo(m, typ.sons[1], info), info) @@ -1350,12 +1350,12 @@ proc genTypeInfo(m: BModule, t: PType; info: TLineInfo): Rope = if m.config.selectedGC != gcDestructors: if m.config.selectedGC >= gcMarkAndSweep: let markerProc = genTraverseProc(m, origType, sig) - addf(m.s[cfsTypeInit3], "$1.marker = $2;$n", [TINameForHcr(m, result), markerProc]) + addf(m.s[cfsTypeInit3], "$1.marker = $2;$n", [tiNameForHcr(m, result), markerProc]) of tyRef: genTypeInfoAux(m, t, t, result, info) if m.config.selectedGC >= gcMarkAndSweep: let markerProc = genTraverseProc(m, origType, sig) - addf(m.s[cfsTypeInit3], "$1.marker = $2;$n", [TINameForHcr(m, result), markerProc]) + addf(m.s[cfsTypeInit3], "$1.marker = $2;$n", [tiNameForHcr(m, result), markerProc]) of tyPtr, tyRange, tyUncheckedArray: genTypeInfoAux(m, t, t, result, info) of tyArray: genArrayInfo(m, t, result, info) of tySet: genSetInfo(m, t, result, info) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 96698f92d..851c8c2a4 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -268,7 +268,7 @@ proc genLineDir(p: BProc, t: PNode) = [line, makeCString(toFilename(p.config, t.info))]) elif ({optLineTrace, optStackTrace} * p.options == {optLineTrace, optStackTrace}) and - (p.prc == nil or sfPure notin p.prc.flags) and t.info.fileIndex != InvalidFileIDX: + (p.prc == nil or sfPure notin p.prc.flags) and t.info.fileIndex != InvalidFileIdx: if freshLineInfo(p, t.info): linefmt(p, cpsStmts, "nimln_($1, $2);$n", [line, quotedFilename(p.config, t.info)]) @@ -296,13 +296,13 @@ proc lenField(p: BProc): Rope = result = rope(if p.module.compileToCpp: "len" else: "Sup.len") proc lenExpr(p: BProc; a: TLoc): Rope = - if p.config.selectedGc == gcDestructors: + if p.config.selectedGC == gcDestructors: result = rdLoc(a) & ".len" else: result = "($1 ? $1->$2 : 0)" % [rdLoc(a), lenField(p)] proc dataField(p: BProc): Rope = - if p.config.selectedGc == gcDestructors: + if p.config.selectedGC == gcDestructors: result = rope".p->data" else: result = rope"->data" @@ -380,10 +380,10 @@ proc isComplexValueType(t: PType): bool {.inline.} = (t.kind == tyProc and t.callConv == ccClosure) proc resetLoc(p: BProc, loc: var TLoc) = - let containsGcRef = p.config.selectedGc != gcDestructors and containsGarbageCollectedRef(loc.t) + let containsGcRef = p.config.selectedGC != gcDestructors and containsGarbageCollectedRef(loc.t) let typ = skipTypes(loc.t, abstractVarRange) if isImportedCppType(typ): return - if p.config.selectedGc == gcDestructors and typ.kind in {tyString, tySequence}: + if p.config.selectedGC == gcDestructors and typ.kind in {tyString, tySequence}: assert rdLoc(loc) != nil linefmt(p, cpsStmts, "$1.len = 0; $1.p = NIM_NIL;$n", [rdLoc(loc)]) elif not isComplexValueType(typ): @@ -414,7 +414,7 @@ proc resetLoc(p: BProc, loc: var TLoc) = proc constructLoc(p: BProc, loc: TLoc, isTemp = false) = let typ = loc.t - if p.config.selectedGc == gcDestructors and skipTypes(typ, abstractInst).kind in {tyString, tySequence}: + if p.config.selectedGC == gcDestructors and skipTypes(typ, abstractInst).kind in {tyString, tySequence}: linefmt(p, cpsStmts, "$1.len = 0; $1.p = NIM_NIL;$n", [rdLoc(loc)]) elif not isComplexValueType(typ): linefmt(p, cpsStmts, "$1 = ($2)0;$n", [rdLoc(loc), @@ -1774,7 +1774,7 @@ proc rawNewModule(g: BModuleList; module: PSym, filename: AbsoluteFile): BModule if sfSystemModule in module.flags: incl result.flags, preventStackTrace excl(result.preInitProc.options, optStackTrace) - let ndiName = if optCDebug in g.config.globalOptions: changeFileExt(completeCFilePath(g.config, filename), "ndi") + let ndiName = if optCDebug in g.config.globalOptions: changeFileExt(completeCfilePath(g.config, filename), "ndi") else: AbsoluteFile"" open(result.ndi, ndiName, g.config) @@ -1805,7 +1805,7 @@ proc myOpen(graph: ModuleGraph; module: PSym): PPassContext = let f = if graph.config.headerFile.len > 0: AbsoluteFile graph.config.headerFile else: graph.config.projectFull g.generatedHeader = rawNewModule(g, module, - changeFileExt(completeCFilePath(graph.config, f), hExt)) + changeFileExt(completeCfilePath(graph.config, f), hExt)) incl g.generatedHeader.flags, isHeaderFile proc writeHeader(m: BModule) = @@ -1838,9 +1838,9 @@ proc writeHeader(m: BModule) = proc getCFile(m: BModule): AbsoluteFile = let ext = if m.compileToCpp: ".nim.cpp" - elif m.config.cmd == cmdCompileToOC or sfCompileToObjC in m.module.flags: ".nim.m" + elif m.config.cmd == cmdCompileToOC or sfCompileToObjc in m.module.flags: ".nim.m" else: ".nim.c" - result = changeFileExt(completeCFilePath(m.config, withPackageName(m.config, m.cfilename)), ext) + result = changeFileExt(completeCfilePath(m.config, withPackageName(m.config, m.cfilename)), ext) when false: proc myOpenCached(graph: ModuleGraph; module: PSym, rd: PRodReader): PPassContext = @@ -1920,7 +1920,7 @@ proc writeModule(m: BModule, pending: bool) = generateThreadVarsSize(m) var cf = Cfile(nimname: m.module.name.s, cname: cfile, - obj: completeCFilePath(m.config, toObjFile(m.config, cfile)), flags: {}) + obj: completeCfilePath(m.config, toObjFile(m.config, cfile)), flags: {}) var code = genModule(m, cf) if code != nil: when hasTinyCBackend: @@ -1932,7 +1932,7 @@ proc writeModule(m: BModule, pending: bool) = addFileToCompile(m.config, cf) elif pending and mergeRequired(m) and sfMainModule notin m.module.flags: let cf = Cfile(nimname: m.module.name.s, cname: cfile, - obj: completeCFilePath(m.config, toObjFile(m.config, cfile)), flags: {}) + obj: completeCfilePath(m.config, toObjFile(m.config, cfile)), flags: {}) mergeFiles(cfile, m) genInitCode(m) finishTypeDescriptions(m) @@ -1946,7 +1946,7 @@ proc writeModule(m: BModule, pending: bool) = # ``system.c`` but then compilation fails due to an error. This means # that ``system.o`` is missing, so we need to call the C compiler for it: var cf = Cfile(nimname: m.module.name.s, cname: cfile, - obj: completeCFilePath(m.config, toObjFile(m.config, cfile)), flags: {}) + obj: completeCfilePath(m.config, toObjFile(m.config, cfile)), flags: {}) if not fileExists(cf.obj): cf.flags = {CfileFlag.Cached} addFileToCompile(m.config, cf) close(m.ndi) @@ -1954,7 +1954,7 @@ proc writeModule(m: BModule, pending: bool) = proc updateCachedModule(m: BModule) = let cfile = getCFile(m) var cf = Cfile(nimname: m.module.name.s, cname: cfile, - obj: completeCFilePath(m.config, toObjFile(m.config, cfile)), flags: {}) + obj: completeCfilePath(m.config, toObjFile(m.config, cfile)), flags: {}) if mergeRequired(m) and sfMainModule notin m.module.flags: mergeFiles(cfile, m) diff --git a/compiler/cgendata.nim b/compiler/cgendata.nim index d9c3b7b86..48dda0716 100644 --- a/compiler/cgendata.nim +++ b/compiler/cgendata.nim @@ -100,7 +100,7 @@ type TypeCache* = Table[SigHash, Rope] TypeCacheWithOwner* = Table[SigHash, tuple[str: Rope, owner: PSym]] - Codegenflag* = enum + CodegenFlag* = enum preventStackTrace, # true if stack traces need to be prevented usesThreadVars, # true if the module uses a thread var frameDeclared, # hack for ROD support so that we don't declare @@ -137,7 +137,7 @@ type TCGen = object of PPassContext # represents a C source file s*: TCFileSections # sections of the C file - flags*: set[Codegenflag] + flags*: set[CodegenFlag] module*: PSym filename*: AbsoluteFile cfilename*: AbsoluteFile # filename of the module (including path, diff --git a/compiler/commands.nim b/compiler/commands.nim index 6c2c6345f..4e445a957 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -277,7 +277,7 @@ proc testCompileOption*(conf: ConfigRef; switch: string, info: TLineInfo): bool of "rangechecks": result = contains(conf.options, optRangeCheck) of "boundchecks": result = contains(conf.options, optBoundsCheck) of "overflowchecks": result = contains(conf.options, optOverflowCheck) - of "movechecks": result = contains(conf.options, optMoveCheck) + of "stylechecks": result = contains(conf.options, optStyleCheck) of "linedir": result = contains(conf.options, optLineDir) of "assertions", "a": result = contains(conf.options, optAssert) of "run", "r": result = contains(conf.globalOptions, optRun) @@ -531,7 +531,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "rangechecks": processOnOffSwitch(conf, {optRangeCheck}, arg, pass, info) of "boundchecks": processOnOffSwitch(conf, {optBoundsCheck}, arg, pass, info) of "overflowchecks": processOnOffSwitch(conf, {optOverflowCheck}, arg, pass, info) - of "movechecks": processOnOffSwitch(conf, {optMoveCheck}, arg, pass, info) + of "stylechecks": processOnOffSwitch(conf, {optStyleCheck}, arg, pass, info) of "linedir": processOnOffSwitch(conf, {optLineDir}, arg, pass, info) of "assertions", "a": processOnOffSwitch(conf, {optAssert}, arg, pass, info) of "deadcodeelim": discard # deprecated, dead code elim always on @@ -807,7 +807,7 @@ proc processArgument*(pass: TCmdLinePass; p: OptParser; argsCount: var int; config: ConfigRef): bool = if argsCount == 0: # nim filename.nims is the same as "nim e filename.nims": - if p.key.endswith(".nims"): + if p.key.endsWith(".nims"): config.command = "e" incl(config.globalOptions, optWasNimscript) config.projectName = unixToNativePath(p.key) diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index 1bd56cd4d..ed95c8183 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -96,3 +96,4 @@ proc initDefines*(symbols: StringTableRef) = defineSymbol("nimHasHint" & s) defineSymbol("nimFixedOwned") + defineSymbol("nimHasStyleChecks") diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 0c3bfba30..e6dcb352f 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -416,7 +416,7 @@ proc setCC*(conf: ConfigRef; ccname: string; info: TLineInfo) = localError(conf, info, "unknown C compiler: '$1'. Available options are: $2" % [ccname, ccList]) conf.compileOptions = getConfigVar(conf, conf.cCompiler, ".options.always") conf.linkOptions = "" - conf.ccompilerpath = getConfigVar(conf, conf.cCompiler, ".path") + conf.cCompilerPath = getConfigVar(conf, conf.cCompiler, ".path") for i in low(CC) .. high(CC): undefSymbol(conf.symbols, CC[i].name) defineSymbol(conf.symbols, CC[conf.cCompiler].name) @@ -443,10 +443,10 @@ proc initVars*(conf: ConfigRef) = defineSymbol(conf.symbols, CC[conf.cCompiler].name) addCompileOption(conf, getConfigVar(conf, conf.cCompiler, ".options.always")) #addLinkOption(getConfigVar(cCompiler, ".options.linker")) - if len(conf.ccompilerpath) == 0: - conf.ccompilerpath = getConfigVar(conf, conf.cCompiler, ".path") + if len(conf.cCompilerPath) == 0: + conf.cCompilerPath = getConfigVar(conf, conf.cCompiler, ".path") -proc completeCFilePath*(conf: ConfigRef; cfile: AbsoluteFile, +proc completeCfilePath*(conf: ConfigRef; cfile: AbsoluteFile, createSubDir: bool = true): AbsoluteFile = result = completeGeneratedFilePath(conf, cfile, createSubDir) @@ -591,7 +591,7 @@ proc getCompileCFileCmd*(conf: ConfigRef; cfile: Cfile, isMainFile = false): str for includeDir in items(conf.cIncludes): includeCmd.add(join([CC[c].includeCmd, includeDir.quoteShell])) - compilePattern = joinPath(conf.ccompilerpath, exe) + compilePattern = joinPath(conf.cCompilerPath, exe) else: includeCmd = "" compilePattern = getCompilerExe(conf, c, cfile.cname) @@ -606,7 +606,7 @@ proc getCompileCFileCmd*(conf: ConfigRef; cfile: Cfile, isMainFile = false): str if not cfile.flags.contains(CfileFlag.External) or noAbsolutePaths(conf): toObjFile(conf, cf).string else: - completeCFilePath(conf, toObjFile(conf, cf)).string + completeCfilePath(conf, toObjFile(conf, cf)).string elif noAbsolutePaths(conf): extractFilename(cfile.obj.string) else: @@ -666,11 +666,11 @@ proc addExternalFileToCompile*(conf: ConfigRef; c: var Cfile) = proc addExternalFileToCompile*(conf: ConfigRef; filename: AbsoluteFile) = var c = Cfile(nimname: splitFile(filename).name, cname: filename, - obj: toObjFile(conf, completeCFilePath(conf, filename, false)), + obj: toObjFile(conf, completeCfilePath(conf, filename, false)), flags: {CfileFlag.External}) addExternalFileToCompile(conf, c) -proc compileCFiles(conf: ConfigRef; list: CFileList, script: var Rope, cmds: var TStringSeq, +proc compileCFiles(conf: ConfigRef; list: CfileList, script: var Rope, cmds: var TStringSeq, prettyCmds: var TStringSeq) = var currIdx = 0 for it in list: @@ -704,7 +704,7 @@ proc getLinkCmd(conf: ConfigRef; output: AbsoluteFile, # bug #6452: We must not use ``quoteShell`` here for ``linkerExe`` if needsExeExt(conf): linkerExe = addFileExt(linkerExe, "exe") if noAbsolutePaths(conf): result = linkerExe - else: result = joinPath(conf.cCompilerpath, linkerExe) + else: result = joinPath(conf.cCompilerPath, linkerExe) let buildgui = if optGenGuiApp in conf.globalOptions and conf.target.targetOS == osWindows: CC[conf.cCompiler].buildGui else: @@ -856,7 +856,7 @@ proc linkViaResponseFile(conf: ConfigRef; cmd: string) = finally: removeFile(linkerArgs) -proc getObjFilePath(conf: ConfigRef, f: CFile): string = +proc getObjFilePath(conf: ConfigRef, f: Cfile): string = if noAbsolutePaths(conf): f.obj.extractFilename else: f.obj.string @@ -1041,7 +1041,7 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) = echo getCurrentException().getStackTrace() quit "error evaluating JSON file: " & jsonFile.string -proc genMappingFiles(conf: ConfigRef; list: CFileList): Rope = +proc genMappingFiles(conf: ConfigRef; list: CfileList): Rope = for it in list: addf(result, "--file:r\"$1\"$N", [rope(it.cname.string)]) diff --git a/compiler/gorgeimpl.nim b/compiler/gorgeimpl.nim index 534ef9fdc..d61dcdac3 100644 --- a/compiler/gorgeimpl.nim +++ b/compiler/gorgeimpl.nim @@ -35,7 +35,7 @@ proc opGorge*(cmd, input, cache: string, info: TLineInfo; conf: ConfigRef): (str var readSuccessful = false try: var p = startProcess(cmd, workingDir, - options={poEvalCommand, poStderrToStdout}) + options={poEvalCommand, poStdErrToStdOut}) if input.len != 0: p.inputStream.write(input) p.inputStream.close() @@ -49,7 +49,7 @@ proc opGorge*(cmd, input, cache: string, info: TLineInfo; conf: ConfigRef): (str else: try: var p = startProcess(cmd, workingDir, - options={poEvalCommand, poStderrToStdout}) + options={poEvalCommand, poStdErrToStdOut}) if input.len != 0: p.inputStream.write(input) p.inputStream.close() diff --git a/compiler/importer.nim b/compiler/importer.nim index a11c6c6ab..ec065a1ec 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -139,7 +139,7 @@ proc importModuleAs(c: PContext; n: PNode, realModule: PSym): PSym = proc myImportModule(c: PContext, n: PNode; importStmtResult: PNode): PSym = let f = checkModuleName(c.config, n) - if f != InvalidFileIDX: + if f != InvalidFileIdx: let L = c.graph.importStack.len let recursion = c.graph.importStack.find(f) c.graph.importStack.add f diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 7893db61d..7c4e7f62b 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -540,7 +540,7 @@ proc pArg(arg: PNode; c: var Con; isSink: bool): PNode = result.add p(arg[0], c) for i in 1..<arg.len: var branch: PNode - if arg[i].kind == nkOfbranch: + if arg[i].kind == nkOfBranch: branch = arg[i] # of branch conditions are constants branch[^1] = pArgIfTyped(arg[i][^1]) elif arg[i].kind in {nkElifBranch, nkElifExpr}: @@ -620,7 +620,7 @@ proc moveOrCopy(dest, ri: PNode; c: var Con): PNode = result.add p(ri[0], c) for i in 1..<ri.len: var branch: PNode - if ri[i].kind == nkOfbranch: + if ri[i].kind == nkOfBranch: branch = ri[i] # of branch conditions are constants branch[^1] = moveOrCopyIfTyped(ri[i][^1]) elif ri[i].kind in {nkElifBranch, nkElifExpr}: diff --git a/compiler/int128.nim b/compiler/int128.nim index d67ec4add..5df1201c0 100644 --- a/compiler/int128.nim +++ b/compiler/int128.nim @@ -262,7 +262,7 @@ proc `*`*(a: Int128, b: int32): Int128 = proc `*=`*(a: var Int128, b: int32): Int128 = result = result * b -proc makeint128(high,low: uint64): Int128 = +proc makeInt128(high,low: uint64): Int128 = result.udata[0] = cast[uint32](low) result.udata[1] = cast[uint32](low shr 32) result.udata[2] = cast[uint32](high) @@ -296,7 +296,7 @@ proc `*`*(lhs,rhs: Int128): Int128 = result = makeInt128(high64(lhs) * low64(rhs) + low64(lhs) * high64(rhs) + a32 * b32, a00 * b00) result = result + toInt128(a32 * b00) shl 32 - result = result + toint128(a00 * b32) shl 32 + result = result + toInt128(a00 * b32) shl 32 if isNegative != isNegative(result): echo result diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index b60f2c5e9..444ce0191 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -573,20 +573,20 @@ proc arithAux(p: PProc, n: PNode, r: var TCompRes, op: TMagic) = of mMinF64: applyFormat("nimMin($1, $2)", "nimMin($1, $2)") of mMaxF64: applyFormat("nimMax($1, $2)", "nimMax($1, $2)") of mAddU: applyFormat("", "") - of msubU: applyFormat("", "") - of mmulU: applyFormat("", "") - of mdivU: applyFormat("", "") - of mmodU: applyFormat("($1 % $2)", "($1 % $2)") + of mSubU: applyFormat("", "") + of mMulU: applyFormat("", "") + of mDivU: applyFormat("", "") + of mModU: applyFormat("($1 % $2)", "($1 % $2)") of mEqI: applyFormat("($1 == $2)", "($1 == $2)") of mLeI: applyFormat("($1 <= $2)", "($1 <= $2)") of mLtI: applyFormat("($1 < $2)", "($1 < $2)") of mEqF64: applyFormat("($1 == $2)", "($1 == $2)") of mLeF64: applyFormat("($1 <= $2)", "($1 <= $2)") of mLtF64: applyFormat("($1 < $2)", "($1 < $2)") - of mleU: applyFormat("($1 <= $2)", "($1 <= $2)") - of mltU: applyFormat("($1 < $2)", "($1 < $2)") - of mleU64: applyFormat("($1 <= $2)", "($1 <= $2)") - of mltU64: applyFormat("($1 < $2)", "($1 < $2)") + of mLeU: applyFormat("($1 <= $2)", "($1 <= $2)") + of mLtU: applyFormat("($1 < $2)", "($1 < $2)") + of mLeU64: applyFormat("($1 <= $2)", "($1 <= $2)") + of mLtU64: applyFormat("($1 < $2)", "($1 < $2)") of mEqEnum: applyFormat("($1 == $2)", "($1 == $2)") of mLeEnum: applyFormat("($1 <= $2)", "($1 <= $2)") of mLtEnum: applyFormat("($1 < $2)", "($1 < $2)") @@ -1591,9 +1591,9 @@ proc arrayTypeForElemType(typ: PType): string = of tyInt, tyInt32: "Int32Array" of tyInt16: "Int16Array" of tyInt8: "Int8Array" - of tyUint, tyUint32: "Uint32Array" - of tyUint16: "Uint16Array" - of tyUint8: "Uint8Array" + of tyUInt, tyUInt32: "Uint32Array" + of tyUInt16: "Uint16Array" + of tyUInt8: "Uint8Array" of tyFloat32: "Float32Array" of tyFloat64, tyFloat: "Float64Array" else: "" @@ -2246,7 +2246,7 @@ proc genProc(oldProc: PProc, prc: PSym): Rope = if prc.typ.sons[0] != nil and sfPure notin prc.flags: resultSym = prc.ast.sons[resultPos].sym let mname = mangleName(p.module, resultSym) - if not isindirect(resultSym) and + if not isIndirect(resultSym) and resultSym.typ.kind in {tyVar, tyPtr, tyLent, tyRef, tyOwned} and mapType(p, resultSym.typ) == etyBaseIndex: resultAsgn = p.indentLine(("var $# = null;$n") % [mname]) @@ -2391,7 +2391,7 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) = of nkFloatLit..nkFloat64Lit: let f = n.floatVal case classify(f) - of fcNaN: + of fcNan: r.res = rope"NaN" of fcNegZero: r.res = rope"-0.0" diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 29d6f122e..726a64d21 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -344,7 +344,7 @@ proc createUpField(c: var DetectionPass; dest, dep: PSym; info: TLineInfo) = # with cycles properly, so it's better to produce a weak ref (=ptr) here. # This seems to be generally correct but since it's a bit risky it's only # enabled for gcDestructors. - let fieldType = if c.graph.config.selectedGc == gcDestructors: + let fieldType = if c.graph.config.selectedGC == gcDestructors: c.getEnvTypeForOwnerUp(dep, info) #getHiddenParam(dep).typ else: c.getEnvTypeForOwner(dep, info) @@ -535,7 +535,7 @@ proc setupEnvVar(owner: PSym; d: DetectionPass; c: var LiftingPass; info: TLineInfo): PNode = if owner.isIterator: return getHiddenParam(d.graph, owner).newSymNode - result = c.envvars.getOrDefault(owner.id) + result = c.envVars.getOrDefault(owner.id) if result.isNil: let envVarType = d.ownerToType.getOrDefault(owner.id) if envVarType.isNil: @@ -710,7 +710,7 @@ proc liftCapturedVars(n: PNode; owner: PSym; d: DetectionPass; c.inContainer = 0 var body = transformBody(d.graph, s) body = liftCapturedVars(body, s, d, c) - if c.envvars.getOrDefault(s.id).isNil: + if c.envVars.getOrDefault(s.id).isNil: s.transformedBody = body else: s.transformedBody = newTree(nkStmtList, rawClosureCreation(s, d, c, n.info), body) @@ -851,7 +851,7 @@ proc liftLambdas*(g: ModuleGraph; fn: PSym, body: PNode; tooEarly: var bool; var c = initLiftingPass(fn) result = liftCapturedVars(body, fn, d, c) # echo renderTree(result, {renderIds}) - if c.envvars.getOrDefault(fn.id) != nil: + if c.envVars.getOrDefault(fn.id) != nil: result = newTree(nkStmtList, rawClosureCreation(fn, d, c, body.info), result) finishClosureCreation(fn, d, c, body.info, result) else: diff --git a/compiler/lexer.nim b/compiler/lexer.nim index 19f1b828d..ea4aea8cf 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -219,7 +219,7 @@ proc fillToken(L: var TToken) = proc openLexer*(lex: var TLexer, fileIdx: FileIndex, inputstream: PLLStream; cache: IdentCache; config: ConfigRef) = openBaseLexer(lex, inputstream) - lex.fileIdx = fileidx + lex.fileIdx = fileIdx lex.indentAhead = -1 lex.currLineIndent = 0 inc(lex.lineNumber, inputstream.lineOffset) @@ -565,7 +565,7 @@ proc getNumber(L: var TLexer, result: var TToken) = case result.tokType of floatTypes: result.fNumber = parseFloat(result.literal) - of tkUint64Lit: + of tkUInt64Lit: var iNumber: uint64 var len: int try: diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim index b6707f11b..7adccd13d 100644 --- a/compiler/lineinfos.nim +++ b/compiler/lineinfos.nim @@ -193,7 +193,7 @@ type # used for better error messages and # embedding the original source in the # generated code - dirtyfile*: AbsoluteFile # the file that is actually read into memory + dirtyFile*: AbsoluteFile # the file that is actually read into memory # and parsed; usually "" but is used # for 'nimsuggest' hash*: string # the checksum of the file @@ -229,12 +229,12 @@ proc raiseRecoverableError*(msg: string) {.noinline.} = raise newException(ERecoverableError, msg) const - InvalidFileIDX* = FileIndex(-1) + InvalidFileIdx* = FileIndex(-1) proc unknownLineInfo*(): TLineInfo = result.line = uint16(0) result.col = int16(-1) - result.fileIndex = InvalidFileIDX + result.fileIndex = InvalidFileIdx type Severity* {.pure.} = enum ## VS Code only supports these three diff --git a/compiler/linter.nim b/compiler/linter.nim index 40b3841f7..2d2baeff5 100644 --- a/compiler/linter.nim +++ b/compiler/linter.nim @@ -83,19 +83,13 @@ proc checkStyle(conf: ConfigRef; cache: IdentCache; info: TLineInfo, s: string, if s != beau: lintReport(conf, info, beau, s) -proc styleCheckDefImpl(conf: ConfigRef; cache: IdentCache; info: TLineInfo; s: PSym; k: TSymKind) = - # operators stay as they are: - if k in {skResult, skTemp} or s.name.s[0] notin Letters: return - if k in {skType, skGenericParam} and sfAnon in s.flags: return - if {sfImportc, sfExportc} * s.flags == {}: - checkStyle(conf, cache, info, s.name.s, k, s) - proc nep1CheckDefImpl(conf: ConfigRef; info: TLineInfo; s: PSym; k: TSymKind) = # operators stay as they are: if k in {skResult, skTemp} or s.name.s[0] notin Letters: return if k in {skType, skGenericParam} and sfAnon in s.flags: return if s.typ != nil and s.typ.kind == tyTypeDesc: return if {sfImportc, sfExportc} * s.flags != {}: return + if optStyleCheck notin s.options: return let beau = beautifyName(s.name.s, k) if s.name.s != beau: lintReport(conf, info, beau, s.name.s) diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim index 16fd70d18..74158381c 100644 --- a/compiler/modulegraphs.nim +++ b/compiler/modulegraphs.nim @@ -29,7 +29,7 @@ import ast, intsets, tables, options, lineinfos, hashes, idents, incremental, btrees, md5 type - SigHash* = distinct Md5Digest + SigHash* = distinct MD5Digest ModuleGraph* = ref object modules*: seq[PSym] ## indexed by int32 fileIdx diff --git a/compiler/modulepaths.nim b/compiler/modulepaths.nim index 129f719e2..6130c3032 100644 --- a/compiler/modulepaths.nim +++ b/compiler/modulepaths.nim @@ -162,6 +162,6 @@ proc checkModuleName*(conf: ConfigRef; n: PNode; doLocalError=true): FileIndex = if doLocalError: let m = if modulename.len > 0: modulename else: $n localError(conf, n.info, "cannot open file: " & m) - result = InvalidFileIDX + result = InvalidFileIdx else: result = fileInfoIdx(conf, fullPath) diff --git a/compiler/modules.nim b/compiler/modules.nim index e45c5786d..3dbc1b2c1 100644 --- a/compiler/modules.nim +++ b/compiler/modules.nim @@ -133,12 +133,12 @@ proc wantMainModule*(conf: ConfigRef) = "command expects a filename") conf.projectMainIdx = fileInfoIdx(conf, addFileExt(conf.projectFull, NimExt)) -proc compileProject*(graph: ModuleGraph; projectFileIdx = InvalidFileIDX) = +proc compileProject*(graph: ModuleGraph; projectFileIdx = InvalidFileIdx) = connectCallbacks(graph) let conf = graph.config wantMainModule(conf) let systemFileIdx = fileInfoIdx(conf, conf.libpath / RelativeFile"system.nim") - let projectFile = if projectFileIdx == InvalidFileIDX: conf.projectMainIdx else: projectFileIdx + let projectFile = if projectFileIdx == InvalidFileIdx: conf.projectMainIdx else: projectFileIdx graph.importStack.add projectFile if projectFile == systemFileIdx: discard graph.compileModule(projectFile, {sfMainModule, sfSystemModule}) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 11c0b486b..71b1c1405 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -108,7 +108,7 @@ proc newLineInfo*(conf: ConfigRef; filename: AbsoluteFile, line, col: int): TLin result = newLineInfo(fileInfoIdx(conf, filename), line, col) -proc concat(strings: openarray[string]): string = +proc concat(strings: openArray[string]): string = var totalLen = 0 for s in strings: totalLen += s.len result = newStringOfCap totalLen @@ -542,7 +542,7 @@ proc localError*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg = "") = proc localError*(conf: ConfigRef; info: TLineInfo, arg: string) = liMessage(conf, info, errGenerated, arg, doNothing) -proc localError*(conf: ConfigRef; info: TLineInfo, format: string, params: openarray[string]) = +proc localError*(conf: ConfigRef; info: TLineInfo, format: string, params: openArray[string]) = localError(conf, info, format % params) proc message*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg = "") = diff --git a/compiler/nim.nim b/compiler/nim.nim index 982d0c7e5..1f8a55897 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -47,7 +47,7 @@ proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) = parseopt.next(p) case p.kind of cmdEnd: break - of cmdLongoption, cmdShortOption: + of cmdLongOption, cmdShortOption: if p.key == " ": p.key = "-" if processArgument(pass, p, argsCount, config): break diff --git a/compiler/options.nim b/compiler/options.nim index 2e8adea34..1ff48840a 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -26,7 +26,7 @@ type # please make sure we have under 32 options TOption* = enum # **keep binary compatible** optNone, optObjCheck, optFieldCheck, optRangeCheck, optBoundsCheck, optOverflowCheck, optNilCheck, - optNaNCheck, optInfCheck, optMoveCheck, + optNaNCheck, optInfCheck, optStyleCheck, optAssert, optLineDir, optWarns, optHints, optOptimizeSpeed, optOptimizeSize, optStackTrace, # stack tracing support optLineTrace, # line tracing support (includes stack tracing) @@ -149,7 +149,7 @@ type Cfile* = object nimname*: string cname*, obj*: AbsoluteFile - flags*: set[CFileFlag] + flags*: set[CfileFlag] CfileList* = seq[Cfile] Suggest* = ref object @@ -246,7 +246,7 @@ type compileOptionsCmd*: seq[string] linkOptions*: string # (*) compileOptions*: string # (*) - ccompilerpath*: string + cCompilerPath*: string toCompile*: CfileList # (*) suggestionResultHook*: proc (result: Suggest) {.closure.} suggestVersion*: int @@ -270,12 +270,12 @@ const oldExperimentalFeatures* = {implicitDeref, dotOperators, callOperator, par const ChecksOptions* = {optObjCheck, optFieldCheck, optRangeCheck, optNilCheck, optOverflowCheck, optBoundsCheck, optAssert, optNaNCheck, optInfCheck, - optMoveCheck} + optStyleCheck} DefaultOptions* = {optObjCheck, optFieldCheck, optRangeCheck, optBoundsCheck, optOverflowCheck, optAssert, optWarns, optHints, optStackTrace, optLineTrace, - optTrMacros, optNilCheck, optMoveCheck} + optTrMacros, optNilCheck, optStyleCheck} DefaultGlobalOptions* = {optThreadAnalysis, optExcessiveStackTrace, optListFullPaths} @@ -498,7 +498,7 @@ proc setDefaultLibpath*(conf: ConfigRef) = # Find out if $nim/../../lib/system.nim exists. let parentNimLibPath = realNimPath.parentDir.parentDir / "lib" if not fileExists(conf.libpath.string / "system.nim") and - fileExists(parentNimlibPath / "system.nim"): + fileExists(parentNimLibPath / "system.nim"): conf.libpath = AbsoluteDir parentNimLibPath proc canonicalizePath*(conf: ConfigRef; path: AbsoluteFile): AbsoluteFile = @@ -590,7 +590,7 @@ proc rawFindFile2(conf: ConfigRef; f: RelativeFile): AbsoluteFile = result = it / f if fileExists(result): # bring to front - for j in countDown(i,1): + for j in countdown(i,1): swap(conf.lazyPaths[j], conf.lazyPaths[j-1]) return canonicalizePath(conf, result) diff --git a/compiler/parser.nim b/compiler/parser.nim index 10aa92e6a..12036f20b 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -346,7 +346,7 @@ proc parseSymbol(p: var TParser, mode = smNormal): PNode = parMessage(p, errIdentifierExpected, p.tok) break of tkOpr, tkDot, tkDotDot, tkEquals, tkParLe..tkParDotRi: - let lineinfo = parLineinfo(p) + let lineinfo = parLineInfo(p) var accm = "" while p.tok.tokType in {tkOpr, tkDot, tkDotDot, tkEquals, tkParLe..tkParDotRi}: @@ -981,7 +981,7 @@ proc parseIdentColonEquals(p: var TParser, flags: TDeclaredIdentFlags): PNode = while true: case p.tok.tokType of tkSymbol, tkAccent: - if withPragma in flags: a = identWithPragma(p, allowDot=withdot in flags) + if withPragma in flags: a = identWithPragma(p, allowDot=withDot in flags) else: a = parseSymbol(p) if a.kind == nkEmpty: return else: break @@ -1090,7 +1090,7 @@ proc parseParamList(p: var TParser, retColon = true): PNode = getTok(p) optInd(p, result) result.sons[0] = parseTypeDesc(p) - elif not retColon and not hasParle: + elif not retColon and not hasParLe: # Mark as "not there" in order to mark for deprecation in the semantic pass: result = p.emptyNode when defined(nimpretty): diff --git a/compiler/passaux.nim b/compiler/passaux.nim index 09f656d58..17c4c506a 100644 --- a/compiler/passaux.nim +++ b/compiler/passaux.nim @@ -30,6 +30,6 @@ proc verboseProcess(context: PPassContext, n: PNode): PNode = # system.nim deactivates all hints, for verbosity:3 we want the processing # messages nonetheless, so we activate them again unconditionally: incl(v.config.notes, hintProcessing) - message(v.config, n.info, hintProcessing, $idgen.gFrontendId) + message(v.config, n.info, hintProcessing, $idgen.gFrontEndId) const verbosePass* = makePass(open = verboseOpen, process = verboseProcess) diff --git a/compiler/passes.nim b/compiler/passes.nim index 7c6acd936..39e023ae0 100644 --- a/compiler/passes.nim +++ b/compiler/passes.nim @@ -90,7 +90,7 @@ proc processTopLevelStmt(graph: ModuleGraph, n: PNode, a: var TPassContextArray) proc resolveMod(conf: ConfigRef; module, relativeTo: string): FileIndex = let fullPath = findModule(conf, module, relativeTo) if fullPath.isEmpty: - result = InvalidFileIDX + result = InvalidFileIdx else: result = fileInfoIdx(conf, fullPath) diff --git a/compiler/platform.nim b/compiler/platform.nim index 2dee33b75..64e37961e 100644 --- a/compiler/platform.nim +++ b/compiler/platform.nim @@ -21,7 +21,7 @@ type # conditionals to condsyms (end of module). osNone, osDos, osWindows, osOs2, osLinux, osMorphos, osSkyos, osSolaris, osIrix, osNetbsd, osFreebsd, osOpenbsd, osDragonfly, osAix, osPalmos, osQnx, - osAmiga, osAtari, osNetware, osMacos, osMacosx, osHaiku, osAndroid, osVxworks + osAmiga, osAtari, osNetware, osMacos, osMacosx, osHaiku, osAndroid, osVxWorks osGenode, osJS, osNimVM, osStandalone, osNintendoSwitch type diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 327a6ff9b..938881842 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -20,38 +20,38 @@ const const procPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl, - wMagic, wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader, + wMagic, wNoSideEffect, wSideEffect, wNoreturn, wDynlib, wHeader, wCompilerProc, wNonReloadable, wCore, wProcVar, wDeprecated, wVarargs, wCompileTime, wMerge, wBorrow, wExtern, wImportCompilerProc, wThread, wImportCpp, wImportObjC, wAsmNoStackFrame, wError, wDiscardable, wNoInit, wCodegenDecl, wGensym, wInject, wRaises, wTags, wLocks, wDelegator, wGcSafe, - wConstructor, wExportNims, wUsed, wLiftLocals, wStacktrace, wLinetrace, wNoDestroy} + wConstructor, wExportNims, wUsed, wLiftLocals, wStackTrace, wLineTrace, wNoDestroy} converterPragmas* = procPragmas - {wNoDestroy} methodPragmas* = procPragmas+{wBase}-{wImportCpp, wNoDestroy} templatePragmas* = {wDeprecated, wError, wGensym, wInject, wDirty, wDelegator, wExportNims, wUsed, wPragma} macroPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, - wNodecl, wMagic, wNosideeffect, wCompilerProc, wNonReloadable, wCore, wDeprecated, wExtern, + wNodecl, wMagic, wNoSideEffect, wCompilerProc, wNonReloadable, wCore, wDeprecated, wExtern, wImportCpp, wImportObjC, wError, wDiscardable, wGensym, wInject, wDelegator, wExportNims, wUsed} - iteratorPragmas* = {FirstCallConv..LastCallConv, wNosideeffect, wSideeffect, + iteratorPragmas* = {FirstCallConv..LastCallConv, wNoSideEffect, wSideEffect, wImportc, wExportc, wNodecl, wMagic, wDeprecated, wBorrow, wExtern, wImportCpp, wImportObjC, wError, wDiscardable, wGensym, wInject, wRaises, wTags, wLocks, wGcSafe, wExportNims, wUsed} - exprPragmas* = {wLine, wLocks, wNoRewrite, wGcSafe, wNosideeffect} - stmtPragmas* = {wChecks, wObjChecks, wFieldChecks, wRangechecks, - wBoundchecks, wOverflowchecks, wNilchecks, wMovechecks, wAssertions, + exprPragmas* = {wLine, wLocks, wNoRewrite, wGcSafe, wNoSideEffect} + stmtPragmas* = {wChecks, wObjChecks, wFieldChecks, wRangeChecks, + wBoundChecks, wOverflowChecks, wNilChecks, wStyleChecks, wAssertions, wWarnings, wHints, - wLinedir, wStacktrace, wLinetrace, wOptimization, wHint, wWarning, wError, + wLineDir, wStackTrace, wLineTrace, wOptimization, wHint, wWarning, wError, wFatal, wDefine, wUndef, wCompile, wLink, wLinksys, wPure, wPush, wPop, wBreakpoint, wWatchPoint, wPassl, wPassc, wDeadCodeElimUnused, # deprecated, always on wDeprecated, - wFloatchecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, + wFloatChecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, wLinearScanEnd, wPatterns, wTrMacros, wEffects, wNoForward, wReorder, wComputedGoto, wInjectStmt, wDeprecated, wExperimental, wThis} lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl, - wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader, + wNoSideEffect, wSideEffect, wNoreturn, wDynlib, wHeader, wDeprecated, wExtern, wThread, wImportCpp, wImportObjC, wAsmNoStackFrame, wRaises, wLocks, wTags, wGcSafe, wCodegenDecl} typePragmas* = {wImportc, wExportc, wDeprecated, wMagic, wAcyclic, wNodecl, @@ -69,7 +69,7 @@ const wExtern, wImportCpp, wImportObjC, wError, wGensym, wInject, wExportNims, wIntDefine, wStrDefine, wBoolDefine, wUsed, wCompilerProc, wCore} letPragmas* = varPragmas - procTypePragmas* = {FirstCallConv..LastCallConv, wVarargs, wNosideeffect, + procTypePragmas* = {FirstCallConv..LastCallConv, wVarargs, wNoSideEffect, wThread, wRaises, wLocks, wTags, wGcSafe} forVarPragmas* = {wInject, wGensym} allRoutinePragmas* = methodPragmas + iteratorPragmas + lambdaPragmas @@ -161,7 +161,7 @@ proc processImportObjC(c: PContext; s: PSym, extname: string, info: TLineInfo) = incl(s.flags, sfNamedParamCall) excl(s.flags, sfForward) let m = s.getModule() - incl(m.flags, sfCompileToObjC) + incl(m.flags, sfCompileToObjc) proc newEmptyStrNode(c: PContext; n: PNode): PNode {.noinline.} = result = newNodeIT(nkStrLit, n.info, getSysType(c.graph, n.info, tyString)) @@ -331,20 +331,20 @@ proc pragmaToOptions(w: TSpecialWord): TOptions {.inline.} = of wChecks: ChecksOptions of wObjChecks: {optObjCheck} of wFieldChecks: {optFieldCheck} - of wRangechecks: {optRangeCheck} - of wBoundchecks: {optBoundsCheck} - of wOverflowchecks: {optOverflowCheck} - of wNilchecks: {optNilCheck} - of wFloatchecks: {optNaNCheck, optInfCheck} + of wRangeChecks: {optRangeCheck} + of wBoundChecks: {optBoundsCheck} + of wOverflowChecks: {optOverflowCheck} + of wNilChecks: {optNilCheck} + of wFloatChecks: {optNaNCheck, optInfCheck} of wNanChecks: {optNaNCheck} of wInfChecks: {optInfCheck} - of wMovechecks: {optMoveCheck} + of wStyleChecks: {optStyleCheck} of wAssertions: {optAssert} of wWarnings: {optWarns} of wHints: {optHints} - of wLinedir: {optLineDir} - of wStacktrace: {optStackTrace} - of wLinetrace: {optLineTrace} + of wLineDir: {optLineDir} + of wStackTrace: {optStackTrace} + of wLineTrace: {optLineTrace} of wDebugger: {optEndb} of wProfiler: {optProfiler, optMemTracker} of wMemTracker: {optMemTracker} @@ -491,7 +491,7 @@ proc processCompile(c: PContext, n: PNode) = let dest = getStrLit(c, it, 1) var found = parentDir(toFullPath(c.config, n.info)) / s for f in os.walkFiles(found): - let obj = completeCFilePath(c.config, AbsoluteFile(dest % extractFilename(f))) + let obj = completeCfilePath(c.config, AbsoluteFile(dest % extractFilename(f))) docompile(c, it, AbsoluteFile f, obj) else: let s = expectStrLit(c, n) @@ -501,7 +501,7 @@ proc processCompile(c: PContext, n: PNode) = else: found = findFile(c.config, s) if found.isEmpty: found = AbsoluteFile s - let obj = toObjFile(c.config, completeCFilePath(c.config, found, false)) + let obj = toObjFile(c.config, completeCfilePath(c.config, found, false)) docompile(c, it, found, obj) proc processLink(c: PContext, n: PNode) = @@ -863,12 +863,12 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, incl(sym.loc.flags, lfNoDecl) # implies nodecl, because otherwise header would not make sense if sym.loc.r == nil: sym.loc.r = rope(sym.name.s) - of wNosideeffect: + of wNoSideEffect: noVal(c, it) if sym != nil: incl(sym.flags, sfNoSideEffect) if sym.typ != nil: incl(sym.typ.flags, tfNoSideEffect) - of wSideeffect: + of wSideEffect: noVal(c, it) incl(sym.flags, sfSideEffect) of wNoreturn: @@ -1011,12 +1011,12 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, noVal(c, it) if sym != nil: incl(sym.flags, sfNoInit) of wCodegenDecl: processCodegenDecl(c, it, sym) - of wChecks, wObjChecks, wFieldChecks, wRangechecks, wBoundchecks, - wOverflowchecks, wNilchecks, wAssertions, wWarnings, wHints, - wLinedir, wOptimization, wMovechecks, wCallconv, wDebugger, wProfiler, - wFloatchecks, wNanChecks, wInfChecks, wPatterns, wTrMacros: + of wChecks, wObjChecks, wFieldChecks, wRangeChecks, wBoundChecks, + wOverflowChecks, wNilChecks, wAssertions, wWarnings, wHints, + wLineDir, wOptimization, wStyleChecks, wCallconv, wDebugger, wProfiler, + wFloatChecks, wNanChecks, wInfChecks, wPatterns, wTrMacros: processOption(c, it, c.config.options) - of wStacktrace, wLinetrace: + of wStackTrace, wLineTrace: if sym.kind in {skProc, skMethod, skConverter}: processOption(c, it, sym.options) else: diff --git a/compiler/reorder.nim b/compiler/reorder.nim index 0fb006c91..e341885ee 100644 --- a/compiler/reorder.nim +++ b/compiler/reorder.nim @@ -151,7 +151,7 @@ proc expandIncludes(graph: ModuleGraph, module: PSym, n: PNode, if a.kind == nkIncludeStmt: for i in 0..<a.len: var f = checkModuleName(graph.config, a.sons[i]) - if f != InvalidFileIDX: + if f != InvalidFileIdx: if containsOrIncl(includedFiles, f.int): localError(graph.config, a.info, "recursive dependency: '$1'" % toMsgFilename(graph.config, f)) diff --git a/compiler/rodutils.nim b/compiler/rodutils.nim index 70fc39648..43fb42de9 100644 --- a/compiler/rodutils.nim +++ b/compiler/rodutils.nim @@ -35,7 +35,7 @@ proc c_snprintf(s: cstring; n:uint; frmt: cstring): cint {.importc: "snprintf", proc toStrMaxPrecision*(f: BiggestFloat, literalPostfix = ""): string = case classify(f) - of fcNaN: + of fcNan: result = "NAN" of fcNegZero: result = "-0.0" & literalPostfix diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 5c299b95b..bd9f18645 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -152,7 +152,7 @@ proc checkConvertible(c: PContext, targetTyp: PType, src: PNode): TConvStatus = src.intVal notin firstOrd(c.config, targetTyp)..lastOrd(c.config, targetTyp): result = convNotInRange elif src.kind in nkFloatLit..nkFloat64Lit and - (classify(src.floatVal) in {fcNaN, fcNegInf, fcInf} or + (classify(src.floatVal) in {fcNan, fcNegInf, fcInf} or src.floatVal.int64 notin firstOrd(c.config, targetTyp)..lastOrd(c.config, targetTyp)): result = convNotInRange elif targetBaseTyp.kind in tyFloat..tyFloat64: @@ -160,7 +160,7 @@ proc checkConvertible(c: PContext, targetTyp: PType, src: PNode): TConvStatus = not floatRangeCheck(src.floatVal, targetTyp): result = convNotInRange elif src.kind in nkCharLit..nkUInt64Lit and - not floatRangeCheck(src.intval.float, targetTyp): + not floatRangeCheck(src.intVal.float, targetTyp): result = convNotInRange else: # we use d, s here to speed up that operation a bit: @@ -1621,7 +1621,7 @@ proc borrowCheck(c: PContext, n, le, ri: PNode) = template resultTypeIsInferrable(typ: PType): untyped = typ.isMetaType and typ.kind != tyTypeDesc -proc goodLineInfo(arg: PNode): TLineinfo = +proc goodLineInfo(arg: PNode): TLineInfo = if arg.kind == nkStmtListExpr and arg.len > 0: goodLineInfo(arg[^1]) else: @@ -2108,7 +2108,7 @@ proc instantiateCreateFlowVarCall(c: PContext; t: PType; # since it's an instantiation, we unmark it as a compilerproc. Otherwise # codegen would fail: if sfCompilerProc in result.flags: - result.flags = result.flags - {sfCompilerProc, sfExportC, sfImportC} + result.flags = result.flags - {sfCompilerProc, sfExportc, sfImportc} result.loc.r = nil proc setMs(n: PNode, s: PSym): PNode = diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 9323f1cee..2f07940c8 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -157,7 +157,7 @@ proc makeRange(typ: PType, first, last: BiggestInt; g: ModuleGraph): PType = let lowerNode = newIntNode(nkIntLit, minA) if typ.kind == tyInt and minA == maxA: result = getIntLitType(g, lowerNode) - elif typ.kind in {tyUint, tyUInt64}: + elif typ.kind in {tyUInt, tyUInt64}: # these are not ordinal types, so you get no subrange type for these: result = typ else: @@ -187,7 +187,7 @@ proc fitLiteral(c: ConfigRef, n: PNode): PNode = result = n let typ = n.typ.skipTypes(abstractRange) - if typ.kind in tyUInt..tyUint32: + if typ.kind in tyUInt..tyUInt32: result.intVal = result.intVal and lastOrd(c, typ, fixedUnsigned=true) proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode = @@ -431,7 +431,7 @@ proc foldConv(n, a: PNode; g: ModuleGraph; check = false): PNode = # XXX range checks? case dstTyp.kind - of tyInt..tyInt64, tyUint..tyUInt64: + of tyInt..tyInt64, tyUInt..tyUInt64: case srcTyp.kind of tyFloat..tyFloat64: result = newIntNodeT(int(getFloat(a)), n, g) @@ -441,7 +441,7 @@ proc foldConv(n, a: PNode; g: ModuleGraph; check = false): PNode = let toSigned = dstTyp.kind in tyInt..tyInt64 var val = a.getOrdValue - if dstTyp.kind in {tyInt, tyInt64, tyUint, tyUInt64}: + if dstTyp.kind in {tyInt, tyInt64, tyUInt, tyUInt64}: # No narrowing needed discard elif dstTyp.kind in {tyInt..tyInt64}: diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index e63d65a82..30f3ac03f 100644 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -497,13 +497,13 @@ proc semGenericStmt(c: PContext, n: PNode, proc semGenericStmt(c: PContext, n: PNode): PNode = var ctx: GenericCtx - ctx.toMixin = initIntset() + ctx.toMixin = initIntSet() result = semGenericStmt(c, n, {}, ctx) semIdeForTemplateOrGeneric(c, result, ctx.cursorInBody) proc semConceptBody(c: PContext, n: PNode): PNode = var ctx: GenericCtx - ctx.toMixin = initIntset() + ctx.toMixin = initIntSet() result = semGenericStmt(c, n, {withinConcept}, ctx) semIdeForTemplateOrGeneric(c, result, ctx.cursorInBody) diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 7e75dde6d..0e1c9cb07 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -74,7 +74,7 @@ type init: seq[int] # list of initialized variables guards: TModel # nested guards locked: seq[PNode] # locked locations - gcUnsafe, isRecursive, isToplevel, hasSideEffect, inEnforcedGcSafe: bool + gcUnsafe, isRecursive, isTopLevel, hasSideEffect, inEnforcedGcSafe: bool inEnforcedNoSideEffects: bool maxLockLevel, currLockLevel: TLockLevel config: ConfigRef @@ -263,7 +263,7 @@ proc useVar(a: PEffects, n: PNode) = # prevent superfluous warnings about the same variable: a.init.add s.id if {sfGlobal, sfThread} * s.flags != {} and s.kind in {skVar, skLet} and - s.magic != mNimVm: + s.magic != mNimvm: if s.guard != nil: guardGlobal(a, n, s.guard) if {sfGlobal, sfThread} * s.flags == {sfGlobal} and (tfHasGCedMem in s.typ.flags or s.typ.isGCedMem): @@ -476,7 +476,7 @@ proc propagateEffects(tracked: PEffects, n: PNode, s: PSym) = markSideEffect(tracked, s) mergeLockLevels(tracked, n, s.getLockLevel) -proc procVarcheck(n: PNode; conf: ConfigRef) = +proc procVarCheck(n: PNode; conf: ConfigRef) = if n.kind in nkSymChoices: for x in n: procVarCheck(x, conf) elif n.kind == nkSym and n.sym.magic != mNone and n.sym.kind in routineKinds: @@ -485,7 +485,7 @@ proc procVarcheck(n: PNode; conf: ConfigRef) = proc notNilCheck(tracked: PEffects, n: PNode, paramType: PType) = let n = n.skipConv if paramType.isNil or paramType.kind != tyTypeDesc: - procVarcheck skipConvAndClosure(n), tracked.config + procVarCheck skipConvAndClosure(n), tracked.config #elif n.kind in nkSymChoices: # echo "came here" let paramType = paramType.skipTypesOrNil(abstractInst) @@ -833,7 +833,7 @@ proc track(tracked: PEffects, n: PNode) = createTypeBoundOps(tracked.graph, tracked.c, it.typ, it.info) let iterCall = n[n.len-2] let loopBody = n[n.len-1] - if tracked.owner.kind != skMacro and iterCall.safelen > 1: + if tracked.owner.kind != skMacro and iterCall.safeLen > 1: # XXX this is a bit hacky: if iterCall[1].typ != nil and iterCall[1].typ.skipTypes(abstractVar).kind notin {tyVarargs, tyOpenArray}: createTypeBoundOps(tracked.graph, tracked.c, iterCall[1].typ, iterCall[1].info) @@ -861,7 +861,7 @@ proc track(tracked: PEffects, n: PNode) = lockLocations(tracked, pragmaList.sons[i]) elif pragma == wGcSafe: enforcedGcSafety = true - elif pragma == wNosideeffect: + elif pragma == wNoSideEffect: enforceNoSideEffects = true if enforcedGcSafety: tracked.inEnforcedGcSafe = true if enforceNoSideEffects: tracked.inEnforcedNoSideEffects = true @@ -1035,5 +1035,5 @@ proc trackTopLevelStmt*(c: PContext; module: PSym; n: PNode) = var effects = newNode(nkEffectList, n.info) var t: TEffects initEffects(g, effects, module, t, c) - t.isToplevel = true + t.isTopLevel = true track(t, n) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 430380944..e26bcbed7 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -333,7 +333,7 @@ proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym = suggestSym(c.config, info, result, c.graph.usageSym) proc checkNilable(c: PContext; v: PSym) = - if {sfGlobal, sfImportC} * v.flags == {sfGlobal} and + if {sfGlobal, sfImportc} * v.flags == {sfGlobal} and {tfNotNil, tfNeedsInit} * v.typ.flags != {}: if v.astdef.isNil: message(c.config, v.info, warnProveInit, v.name.s) @@ -1009,7 +1009,6 @@ proc typeSectionLeftSidePass(c: PContext, n: PNode) = let typsym = pkg.tab.strTableGet(typName) if typsym.isNil: s = semIdentDef(c, name[1], skType) - styleCheckDef(c.config, s) onDef(name[1].info, s) s.typ = newTypeS(tyObject, c) s.typ.sym = s @@ -1024,7 +1023,6 @@ proc typeSectionLeftSidePass(c: PContext, n: PNode) = s = typsym else: s = semIdentDef(c, name, skType) - styleCheckDef(c.config, s) onDef(name.info, s) s.typ = newTypeS(tyForward, c) s.typ.sym = s # process pragmas: @@ -1253,6 +1251,8 @@ proc typeSectionFinalPass(c: PContext, n: PNode) = if a.kind == nkCommentStmt: continue let name = typeSectionTypeName(c, a.sons[0]) var s = name.sym + # check the style here after the pragmas have been processed: + styleCheckDef(c.config, s) # compute the type's size and check for illegal recursions: if a.sons[1].kind == nkEmpty: var x = a[2] @@ -1286,7 +1286,7 @@ proc semAllTypeSections(c: PContext; n: PNode): PNode = of nkIncludeStmt: for i in 0..<n.len: var f = checkModuleName(c.config, n.sons[i]) - if f != InvalidFileIDX: + if f != InvalidFileIdx: if containsOrIncl(c.includedFiles, f.int): localError(c.config, n.info, errRecursiveDependencyX % toMsgFilename(c.config, f)) else: @@ -2021,7 +2021,7 @@ proc semMacroDef(c: PContext, n: PNode): PNode = proc incMod(c: PContext, n: PNode, it: PNode, includeStmtResult: PNode) = var f = checkModuleName(c.config, it) - if f != InvalidFileIDX: + if f != InvalidFileIdx: if containsOrIncl(c.includedFiles, f.int): localError(c.config, n.info, errRecursiveDependencyX % toMsgFilename(c.config, f)) else: diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 351aa588d..632dc916c 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1614,8 +1614,8 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType = elif op.id == ord(wType): checkSonsLen(n, 2, c.config) result = semTypeof(c, n[1], prev) - elif op.s == "typeof" and n[0].kind == nkSym and n[0].sym.magic == mTypeof: - result = semTypeOf2(c, n, prev) + elif op.s == "typeof" and n[0].kind == nkSym and n[0].sym.magic == mTypeOf: + result = semTypeof2(c, n, prev) elif op.s == "owned" and optNimV2 notin c.config.globalOptions and n.len == 2: result = semTypeExpr(c, n[1], prev) else: @@ -1640,7 +1640,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType = of mSet: result = semSet(c, n, prev) of mOrdinal: result = semOrdinal(c, n, prev) of mSeq: - if c.config.selectedGc == gcDestructors and optNimV2 notin c.config.globalOptions: + if c.config.selectedGC == gcDestructors and optNimV2 notin c.config.globalOptions: let s = c.graph.sysTypes[tySequence] assert s != nil assert prev == nil @@ -1658,7 +1658,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType = c.typesWithOps.add((result, result)) else: result = semContainer(c, n, tySequence, "seq", prev) - if c.config.selectedGc == gcDestructors: + if c.config.selectedGC == gcDestructors: incl result.flags, tfHasAsgn of mOpt: result = semContainer(c, n, tyOpt, "opt", prev) of mVarargs: result = semVarargs(c, n, prev) @@ -1842,7 +1842,7 @@ proc processMagicType(c: PContext, m: PSym) = of mString: setMagicType(c.config, m, tyString, szUncomputedSize) rawAddSon(m.typ, getSysType(c.graph, m.info, tyChar)) - if c.config.selectedGc == gcDestructors: + if c.config.selectedGC == gcDestructors: incl m.typ.flags, tfHasAsgn of mCstring: setMagicIntegral(c.config, m, tyCString, c.config.target.ptrSize) @@ -1883,7 +1883,7 @@ proc processMagicType(c: PContext, m: PSym) = setMagicIntegral(c.config, m, tyUncheckedArray, szUncomputedSize) of mSeq: setMagicType(c.config, m, tySequence, szUncomputedSize) - if c.config.selectedGc == gcDestructors: + if c.config.selectedGC == gcDestructors: incl m.typ.flags, tfHasAsgn assert c.graph.sysTypes[tySequence] == nil c.graph.sysTypes[tySequence] = m.typ diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index af840e80c..9c1730798 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -598,7 +598,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType = skipIntLiteralParams(result) of tySequence: - if cl.isReturnType and cl.c.config.selectedGc == gcDestructors and + if cl.isReturnType and cl.c.config.selectedGC == gcDestructors and result.attachedOps[attachedDestructor].isNil and result[0].kind != tyEmpty and optNimV2 notin cl.c.config.globalOptions: let s = cl.c.graph.sysTypes[tySequence] diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim index 046479de4..c69797391 100644 --- a/compiler/sighashes.nim +++ b/compiler/sighashes.nim @@ -249,7 +249,7 @@ proc hashType*(t: PType; flags: set[ConsiderFlag] = {CoType}): SigHash = var c: MD5Context md5Init c hashType c, t, flags+{CoOwnerSig} - md5Final c, result.Md5Digest + md5Final c, result.MD5Digest when defined(debugSigHashes): db.exec(sql"INSERT OR IGNORE INTO sighashes(type, hash) VALUES (?, ?)", typeToString(t), $result) @@ -272,7 +272,7 @@ proc hashProc*(s: PSym): SigHash = # hash, we also hash the line information. This is pretty bad, but the best # solution for now: #c &= s.info.line - md5Final c, result.Md5Digest + md5Final c, result.MD5Digest proc hashNonProc*(s: PSym): SigHash = var c: MD5Context @@ -288,7 +288,7 @@ proc hashNonProc*(s: PSym): SigHash = # might cause: if s.kind == skParam: c &= s.position - md5Final c, result.Md5Digest + md5Final c, result.MD5Digest proc hashOwner*(s: PSym): SigHash = var c: MD5Context @@ -301,7 +301,7 @@ proc hashOwner*(s: PSym): SigHash = c &= "." c &= m.name.s - md5Final c, result.Md5Digest + md5Final c, result.MD5Digest proc sigHash*(s: PSym): SigHash = if s.kind in routineKinds and s.typ != nil: @@ -368,14 +368,14 @@ proc symBodyDigest*(graph: ModuleGraph, sym: PSym): SigHash = md5Init(c) c.hashType(sym.typ, {CoProc}) c &= char(sym.kind) - c.md5Final(result.Md5Digest) + c.md5Final(result.MD5Digest) graph.symBodyHashes[sym.id] = result # protect from recursion in the body if sym.ast != nil: md5Init(c) c.md5Update(cast[cstring](result.addr), sizeof(result)) hashBodyTree(graph, c, sym.ast[bodyPos]) - c.md5Final(result.Md5Digest) + c.md5Final(result.MD5Digest) graph.symBodyHashes[sym.id] = result proc idOrSig*(s: PSym, currentModule: string, diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index c37151a8f..39dcfedcf 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1494,7 +1494,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, # Workaround for regression #4589 if f.sons[i].kind != tyTypeDesc: return result = isGeneric - elif x.kind == tyGenericInst and isGenericSubType(c, x, f, depth, f) and + elif x.kind == tyGenericInst and isGenericSubtype(c, x, f, depth, f) and (sonsLen(x) - 1 == sonsLen(f)): # do not recurse here in order to not K bind twice for this code: # @@ -1545,7 +1545,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, # Here object inheriting from generic/specialized generic object # crossing path with metatypes/aliases, so we need to separate them # by checking sym.id - let genericSubtype = isGenericSubType(c, x, f, depth, f) + let genericSubtype = isGenericSubtype(c, x, f, depth, f) if not (genericSubtype and aobj.sym.id != fobj.sym.id) and aOrig.kind != tyGenericBody: depth = -1 diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 5887837f6..5130f30c9 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -253,7 +253,7 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo; result.add t.n.sons[1].copyTree of tyPointer: result = atomicType("pointer", mPointer) of tyString: result = atomicType("string", mString) - of tyCString: result = atomicType("cstring", mCString) + of tyCString: result = atomicType("cstring", mCstring) of tyInt: result = atomicType("int", mInt) of tyInt8: result = atomicType("int8", mInt8) of tyInt16: result = atomicType("int16", mInt16) @@ -263,11 +263,11 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo; of tyFloat32: result = atomicType("float32", mFloat32) of tyFloat64: result = atomicType("float64", mFloat64) of tyFloat128: result = atomicType("float128", mFloat128) - of tyUInt: result = atomicType("uint", mUint) - of tyUInt8: result = atomicType("uint8", mUint8) - of tyUInt16: result = atomicType("uint16", mUint16) - of tyUInt32: result = atomicType("uint32", mUint32) - of tyUInt64: result = atomicType("uint64", mUint64) + of tyUInt: result = atomicType("uint", mUInt) + of tyUInt8: result = atomicType("uint8", mUInt8) + of tyUInt16: result = atomicType("uint16", mUInt16) + of tyUInt32: result = atomicType("uint32", mUInt32) + of tyUInt64: result = atomicType("uint64", mUInt64) of tyVarargs: result = mapTypeToBracket("varargs", mVarargs, t, info) of tyProxy: result = atomicType("error", mNone) of tyBuiltInTypeClass: diff --git a/compiler/wordrecg.nim b/compiler/wordrecg.nim index a26b86c75..837ce4268 100644 --- a/compiler/wordrecg.nim +++ b/compiler/wordrecg.nim @@ -43,16 +43,16 @@ type wImportCpp, wImportObjC, wImportCompilerProc, wImportc, wExportc, wExportNims, wIncompleteStruct, wRequiresInit, - wAlign, wNodecl, wPure, wSideeffect, wHeader, + wAlign, wNodecl, wPure, wSideEffect, wHeader, wNoSideEffect, wGcSafe, wNoreturn, wMerge, wLib, wDynlib, - wCompilerproc, wCore, wProcVar, wBase, wUsed, + wCompilerProc, wCore, wProcVar, wBase, wUsed, wFatal, wError, wWarning, wHint, wLine, wPush, wPop, wDefine, wUndef, - wLinedir, wStacktrace, wLinetrace, wLink, wCompile, + wLineDir, wStackTrace, wLineTrace, wLink, wCompile, wLinksys, wDeprecated, wVarargs, wCallconv, wBreakpoint, wDebugger, wNimcall, wStdcall, wCdecl, wSafecall, wSyscall, wInline, wNoInline, - wFastcall, wClosure, wNoconv, wOn, wOff, wChecks, wRangechecks, - wBoundchecks, wOverflowchecks, wNilchecks, - wFloatchecks, wNanChecks, wInfChecks, wMoveChecks, + wFastcall, wClosure, wNoconv, wOn, wOff, wChecks, wRangeChecks, + wBoundChecks, wOverflowChecks, wNilChecks, + wFloatChecks, wNanChecks, wInfChecks, wStyleChecks, wNonReloadable, wExecuteOnReload, wAssertions, wPatterns, wTrMacros, wWarnings, wHints, wOptimization, wRaises, wWrites, wReads, wSize, wEffects, wTags, @@ -142,7 +142,7 @@ const "cdecl", "safecall", "syscall", "inline", "noinline", "fastcall", "closure", "noconv", "on", "off", "checks", "rangechecks", "boundchecks", "overflowchecks", "nilchecks", - "floatchecks", "nanchecks", "infchecks", "movechecks", + "floatchecks", "nanchecks", "infchecks", "stylechecks", "nonreloadable", "executeonreload", "assertions", "patterns", "trmacros", "warnings", "hints", @@ -192,7 +192,6 @@ proc canonPragmaSpelling*(w: TSpecialWord): string = of wIncompleteStruct: "incompleteStruct" of wRequiresInit: "requiresInit" of wSideEffect: "sideEffect" - of wCompilerProc: "compilerProc" of wLineDir: "lineDir" of wStackTrace: "stackTrace" of wLineTrace: "lineTrace" @@ -203,12 +202,11 @@ proc canonPragmaSpelling*(w: TSpecialWord): string = of wFloatChecks: "floatChecks" of wNanChecks: "nanChecks" of wInfChecks: "infChecks" - of wMoveChecks: "moveChecks" + of wStyleChecks: "styleChecks" of wNonReloadable: "nonReloadable" of wExecuteOnReload: "executeOnReload" of wDeadCodeElimUnused: "deadCodeElim" of wCompileTime: "compileTime" - of wNoInit: "noInit" of wFieldChecks: "fieldChecks" of wLinearScanEnd: "linearScanEnd" of wComputedGoto: "computedGoto" |