diff options
author | Adam Strzelecki <ono@java.pl> | 2015-06-06 11:07:23 +0200 |
---|---|---|
committer | Adam Strzelecki <ono@java.pl> | 2015-07-03 12:37:42 +0200 |
commit | 14e6ff678053c98a156d47f431c1f6c3c2cb1400 (patch) | |
tree | c3b6c05848bbc8efb5013bbea26742641eacfc5f /compiler | |
parent | e43daf3d240207bab19c3014a8788717868d5897 (diff) | |
download | Nim-14e6ff678053c98a156d47f431c1f6c3c2cb1400.tar.gz |
Introduce NotesVerbosity defining verbosity levels
This solves two issues: 1. Some notes were enabled explicitly for some verbosity levels, so --hintName:on has no effect if verbosity level was too low. 2. Verbosity level for notes is not longer scattered across the source code, instead if now lives in msgs.nim NotesVerbosity array 3. Individual note settings have stronger effect than verbosity setting, so --hintName:off will disable hint regardless of high verbosity setting, and vice-versa --hintName:on will enable hint even on low verbosity setting.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/commands.nim | 15 | ||||
-rw-r--r-- | compiler/main.nim | 5 | ||||
-rw-r--r-- | compiler/msgs.nim | 19 | ||||
-rw-r--r-- | compiler/nimblecmd.nim | 2 | ||||
-rw-r--r-- | compiler/nimconf.nim | 2 | ||||
-rw-r--r-- | compiler/passaux.nim | 2 | ||||
-rw-r--r-- | compiler/rodread.nim | 2 | ||||
-rw-r--r-- | compiler/syntaxes.nim | 2 |
8 files changed, 36 insertions, 13 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim index e3d3bc432..8d54488cb 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -141,6 +141,10 @@ proc expectArg(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = proc expectNoArg(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = if arg != "": localError(info, errCmdLineNoArgExpected, addPrefix(switch)) +var + enableNotes: TNoteKinds + disableNotes: TNoteKinds + proc processSpecificNote(arg: string, state: TSpecialWord, pass: TCmdLinePass, info: TLineInfo; orig: string) = var id = "" # arg = "X]:on|off" @@ -162,8 +166,12 @@ proc processSpecificNote(arg: string, state: TSpecialWord, pass: TCmdLinePass, if x >= 0: n = TNoteKind(x + ord(warnMin)) else: localError(info, "unknown warning: " & id) case whichKeyword(substr(arg, i)) - of wOn: incl(gNotes, n) - of wOff: excl(gNotes, n) + of wOn: + incl(gNotes, n) + incl(enableNotes, n) + of wOff: + excl(gNotes, n) + incl(disableNotes, n) else: localError(info, errOnOrOffExpectedButXFound, arg) proc processCompile(filename: string) = @@ -508,6 +516,9 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = of "verbosity": expectArg(switch, arg, pass, info) gVerbosity = parseInt(arg) + gNotes = NotesVerbosity[gVerbosity] + incl(gNotes, enableNotes) + excl(gNotes, disableNotes) of "parallelbuild": expectArg(switch, arg, pass, info) gNumberOfProcessors = parseInt(arg) diff --git a/compiler/main.nim b/compiler/main.nim index 6bac4b77a..1fe764541 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -359,9 +359,8 @@ proc mainCommand* = else: rawMessage(errInvalidCommandX, command) - if (msgs.gErrorCounter == 0 and - gCmd notin {cmdInterpret, cmdRun, cmdDump} and - gVerbosity > 0): + if msgs.gErrorCounter == 0 and + gCmd notin {cmdInterpret, cmdRun, cmdDump}: rawMessage(hintSuccessX, [$gLinesCompiled, formatFloat(epochTime() - gLastCmdTime, ffDecimal, 3), formatSize(getTotalMem()), diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 937b4bd61..ec6aa1604 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -484,6 +484,21 @@ type ESuggestDone* = object of Exception const + NotesVerbosity*: array[0..3, TNoteKinds] = [ + {low(TNoteKind)..high(TNoteKind)} - {warnShadowIdent, warnUninit, + warnProveField, warnProveIndex, + warnGcUnsafe, + hintSuccessX, hintPath, hintConf, + hintProcessing, + hintCodeBegin, hintCodeEnd}, + {low(TNoteKind)..high(TNoteKind)} - {warnShadowIdent, warnUninit, + warnProveField, warnProveIndex, + warnGcUnsafe, + hintCodeBegin, hintCodeEnd}, + {low(TNoteKind)..high(TNoteKind)}, + {low(TNoteKind)..high(TNoteKind)}] + +const InvalidFileIDX* = int32(-1) var @@ -571,9 +586,7 @@ proc raiseRecoverableError*(msg: string) {.noinline, noreturn.} = proc sourceLine*(i: TLineInfo): Rope var - gNotes*: TNoteKinds = {low(TNoteKind)..high(TNoteKind)} - - {warnShadowIdent, warnUninit, - warnProveField, warnProveIndex, warnGcUnsafe} + gNotes*: TNoteKinds = NotesVerbosity[1] # defaults to verbosity of 1 gErrorCounter*: int = 0 # counts the number of errors gHintCounter*: int = 0 gWarnCounter*: int = 0 diff --git a/compiler/nimblecmd.nim b/compiler/nimblecmd.nim index 23f3331a2..2044f104f 100644 --- a/compiler/nimblecmd.nim +++ b/compiler/nimblecmd.nim @@ -60,7 +60,7 @@ iterator chosen(packages: StringTableRef): string = proc addNimblePath(p: string, info: TLineInfo) = if not contains(options.searchPaths, p): - if gVerbosity >= 1: message(info, hintPath, p) + message(info, hintPath, p) lists.prependStr(options.lazyPaths, p) proc addPathWithNimFiles(p: string, info: TLineInfo) = diff --git a/compiler/nimconf.nim b/compiler/nimconf.nim index 711b476e6..b9c78cecc 100644 --- a/compiler/nimconf.nim +++ b/compiler/nimconf.nim @@ -211,7 +211,7 @@ proc readConfigFile(filename: string) = while tok.tokType != tkEof: parseAssignment(L, tok) if len(condStack) > 0: lexMessage(L, errTokenExpected, "@end") closeLexer(L) - if gVerbosity >= 1: rawMessage(hintConf, filename) + rawMessage(hintConf, filename) proc getUserConfigPath(filename: string): string = result = joinPath(getConfigDir(), filename) diff --git a/compiler/passaux.nim b/compiler/passaux.nim index f754c80e5..c3bafe7df 100644 --- a/compiler/passaux.nim +++ b/compiler/passaux.nim @@ -15,7 +15,7 @@ import proc verboseOpen(s: PSym): PPassContext = #MessageOut('compiling ' + s.name.s); result = nil # we don't need a context - if gVerbosity > 0: rawMessage(hintProcessing, s.name.s) + rawMessage(hintProcessing, s.name.s) proc verboseProcess(context: PPassContext, n: PNode): PNode = result = n diff --git a/compiler/rodread.nim b/compiler/rodread.nim index c1c27aedb..080c93a26 100644 --- a/compiler/rodread.nim +++ b/compiler/rodread.nim @@ -838,7 +838,7 @@ proc checkDep(fileIdx: int32): TReasonForRecompile = if res != rrNone: result = rrModDeps # we cannot break here, because of side-effects of `checkDep` - if result != rrNone and gVerbosity > 0: + if result != rrNone: rawMessage(hintProcessing, reasonToFrmt[result] % filename) if result != rrNone or optForceFullMake in gGlobalOptions: # recompilation is necessary: diff --git a/compiler/syntaxes.nim b/compiler/syntaxes.nim index 7f9e25f82..5fd81d87e 100644 --- a/compiler/syntaxes.nim +++ b/compiler/syntaxes.nim @@ -139,7 +139,7 @@ proc applyFilter(p: var TParsers, n: PNode, filename: string, of filtReplace: result = filterReplace(stdin, filename, n) if f != filtNone: - if gVerbosity >= 2: + if hintCodeBegin in gNotes: rawMessage(hintCodeBegin, []) msgWriteln(result.s) rawMessage(hintCodeEnd, []) |