mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-09 13:18:11 +00:00
--stdout make compiler messages go to stderr
This commit is contained in:
@@ -129,14 +129,14 @@ var
|
||||
proc HelpOnError(pass: TCmdLinePass) =
|
||||
if (pass == passCmd1) and not helpWritten:
|
||||
# BUGFIX 19
|
||||
MessageOut(getCommandLineDesc())
|
||||
MsgWriteln(getCommandLineDesc())
|
||||
helpWritten = true
|
||||
quit(0)
|
||||
|
||||
proc writeAdvancedUsage(pass: TCmdLinePass) =
|
||||
if (pass == passCmd1) and not advHelpWritten:
|
||||
# BUGFIX 19
|
||||
MessageOut(`%`(HelpMessage, [VersionAsString,
|
||||
MsgWriteln(`%`(HelpMessage, [VersionAsString,
|
||||
platform.os[platform.hostOS].name,
|
||||
cpu[platform.hostCPU].name]) & AdvancedUsage)
|
||||
advHelpWritten = true
|
||||
@@ -147,14 +147,14 @@ proc writeVersionInfo(pass: TCmdLinePass) =
|
||||
if (pass == passCmd1) and not versionWritten:
|
||||
versionWritten = true
|
||||
helpWritten = true
|
||||
messageOut(`%`(HelpMessage, [VersionAsString,
|
||||
MsgWriteln(`%`(HelpMessage, [VersionAsString,
|
||||
platform.os[platform.hostOS].name,
|
||||
cpu[platform.hostCPU].name]))
|
||||
quit(0)
|
||||
|
||||
proc writeCommandLineUsage() =
|
||||
if not helpWritten:
|
||||
messageOut(getCommandLineDesc())
|
||||
MsgWriteln(getCommandLineDesc())
|
||||
helpWritten = true
|
||||
|
||||
proc InvalidCmdLineOption(pass: TCmdLinePass, switch: string, info: TLineInfo) =
|
||||
|
||||
@@ -44,11 +44,11 @@ proc isDefined(symbol: PIdent): bool =
|
||||
proc ListSymbols() =
|
||||
var it: TTabIter
|
||||
var s = InitTabIter(it, gSymbols)
|
||||
MessageOut("-- List of currently defined symbols --")
|
||||
OutWriteln("-- List of currently defined symbols --")
|
||||
while s != nil:
|
||||
if s.position == 1: MessageOut(s.name.s)
|
||||
if s.position == 1: OutWriteln(s.name.s)
|
||||
s = nextIter(it, gSymbols)
|
||||
MessageOut("-- End of list --")
|
||||
OutWriteln("-- End of list --")
|
||||
|
||||
proc countDefinedSymbols(): int =
|
||||
var it: TTabIter
|
||||
@@ -67,8 +67,7 @@ proc InitDefines() =
|
||||
of cpuI386: DefineSymbol("x86")
|
||||
of cpuIa64: DefineSymbol("itanium")
|
||||
of cpuAmd64: DefineSymbol("x8664")
|
||||
else:
|
||||
nil
|
||||
else: nil
|
||||
case targetOS
|
||||
of osDOS:
|
||||
DefineSymbol("msdos")
|
||||
@@ -93,8 +92,7 @@ proc InitDefines() =
|
||||
DefineSymbol("macintosh")
|
||||
DefineSymbol("unix")
|
||||
DefineSymbol("posix")
|
||||
else:
|
||||
nil
|
||||
else: nil
|
||||
DefineSymbol("cpu" & $cpu[targetCPU].bit)
|
||||
DefineSymbol(normalize(endianToStr[cpu[targetCPU].endian]))
|
||||
DefineSymbol(cpu[targetCPU].name)
|
||||
|
||||
@@ -79,11 +79,11 @@ proc stackTraceAux(x: PStackFrame) =
|
||||
if x != nil:
|
||||
stackTraceAux(x.next)
|
||||
var info = if x.call != nil: x.call.info else: UnknownLineInfo()
|
||||
messageOut(`%`("file: $1, line: $2",
|
||||
MsgWriteln(`%`("file: $1, line: $2",
|
||||
[toFilename(info), $(toLineNumber(info))]))
|
||||
|
||||
proc stackTrace(c: PEvalContext, n: PNode, msg: TMsgKind, arg: string = "") =
|
||||
messageOut("stack trace: (most recent call last)")
|
||||
MsgWriteln("stack trace: (most recent call last)")
|
||||
stackTraceAux(c.tos)
|
||||
Fatal(n.info, msg, arg)
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ proc addFileToLink*(filename: string) =
|
||||
# BUGFIX: was ``appendStr``
|
||||
|
||||
proc execExternalProgram*(cmd: string) =
|
||||
if (optListCmd in gGlobalOptions) or (gVerbosity > 0): MessageOut(cmd)
|
||||
if (optListCmd in gGlobalOptions) or (gVerbosity > 0): MsgWriteln(cmd)
|
||||
if execCmd(cmd) != 0: rawMessage(errExecutionOfProgramFailed, "")
|
||||
|
||||
proc generateScript(projectFile: string, script: PRope) =
|
||||
|
||||
@@ -254,7 +254,7 @@ proc MainCommand(cmd, filename: string) =
|
||||
of wDump:
|
||||
gCmd = cmdDump
|
||||
condsyms.ListSymbols()
|
||||
for it in iterSearchPath(): MessageOut(it)
|
||||
for it in iterSearchPath(): MsgWriteln(it)
|
||||
of wCheck:
|
||||
gCmd = cmdCheck
|
||||
wantFile(filename)
|
||||
@@ -267,7 +267,7 @@ proc MainCommand(cmd, filename: string) =
|
||||
gCmd = cmdScan
|
||||
wantFile(filename)
|
||||
CommandScan(filename)
|
||||
MessageOut("Beware: Indentation tokens depend on the parser\'s state!")
|
||||
MsgWriteln("Beware: Indentation tokens depend on the parser\'s state!")
|
||||
of wI:
|
||||
gCmd = cmdInteractive
|
||||
CommandInteractive()
|
||||
|
||||
15
rod/msgs.nim
15
rod/msgs.nim
@@ -438,10 +438,15 @@ proc addCheckpoint*(info: TLineInfo) =
|
||||
proc addCheckpoint*(filename: string, line: int) =
|
||||
addCheckpoint(newLineInfo(filename, line, - 1))
|
||||
|
||||
proc MessageOut*(s: string) =
|
||||
# change only this proc to put it elsewhere
|
||||
proc OutWriteln*(s: string) =
|
||||
## Writes to stdout. Always.
|
||||
Writeln(stdout, s)
|
||||
|
||||
proc MsgWriteln*(s: string) =
|
||||
## Writes to stdout. If --stdout option is given, writes to stderr instead.
|
||||
if optStdout in gGlobalOptions: Writeln(stderr, s)
|
||||
else: Writeln(stdout, s)
|
||||
|
||||
proc coordToStr(coord: int): string =
|
||||
if coord == -1: result = "???"
|
||||
else: result = $coord
|
||||
@@ -493,7 +498,7 @@ proc writeContext(lastinfo: TLineInfo) =
|
||||
for i in countup(0, len(msgContext) - 1):
|
||||
if not sameLineInfo(msgContext[i], lastInfo) and
|
||||
not sameLineInfo(msgContext[i], info):
|
||||
MessageOut(`%`(posErrorFormat, [toFilename(msgContext[i]),
|
||||
MsgWriteln(`%`(posErrorFormat, [toFilename(msgContext[i]),
|
||||
coordToStr(msgContext[i].line),
|
||||
coordToStr(msgContext[i].col),
|
||||
getMessageStr(errInstantiationFrom, "")]))
|
||||
@@ -515,7 +520,7 @@ proc rawMessage*(msg: TMsgKind, args: openarray[string]) =
|
||||
if not (msg in gNotes): return
|
||||
frmt = rawHintFormat
|
||||
inc(gHintCounter)
|
||||
MessageOut(`%`(frmt, `%`(msgKindToString(msg), args)))
|
||||
MsgWriteln(`%`(frmt, `%`(msgKindToString(msg), args)))
|
||||
handleError(msg, doAbort)
|
||||
|
||||
proc rawMessage*(msg: TMsgKind, arg: string) =
|
||||
@@ -545,7 +550,7 @@ proc liMessage(info: TLineInfo, msg: TMsgKind, arg: string,
|
||||
frmt = posHintFormat
|
||||
inc(gHintCounter)
|
||||
if not ignoreMsg:
|
||||
MessageOut(frmt % [toFilename(info), coordToStr(info.line),
|
||||
MsgWriteln(frmt % [toFilename(info), coordToStr(info.line),
|
||||
coordToStr(info.col), getMessageStr(msg, arg)])
|
||||
handleError(msg, eh)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2008 Andreas Rumpf
|
||||
# (c) Copyright 2011 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
@@ -139,7 +139,7 @@ proc parseDirective(L: var TLexer, tok: PToken) =
|
||||
doEnd(L, tok)
|
||||
of wWrite:
|
||||
ppGetTok(L, tok)
|
||||
msgs.MessageOut(tokToStr(tok))
|
||||
msgs.MsgWriteln(tokToStr(tok))
|
||||
ppGetTok(L, tok)
|
||||
of wPutEnv:
|
||||
ppGetTok(L, tok)
|
||||
@@ -254,4 +254,4 @@ proc LoadConfig(project: string) =
|
||||
if not (optSkipProjConfigFile in gGlobalOptions) and (project != ""):
|
||||
conffile = changeFileExt(project, "cfg")
|
||||
if existsFile(conffile): readConfigFile(conffile)
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
# (c) Copyright 2011 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
@@ -648,7 +648,7 @@ proc processRodFile(r: PRodReader, crc: TCrc32) =
|
||||
r.cgenIdx = r.pos + 2
|
||||
skipSection(r)
|
||||
else:
|
||||
MessageOut("skipping section: " & $r.pos)
|
||||
MsgWriteln("skipping section: " & $r.pos)
|
||||
skipSection(r)
|
||||
if r.s[r.pos] == '\x0A':
|
||||
inc(r.pos)
|
||||
@@ -810,7 +810,7 @@ proc checkDep(filename: string): TReasonForRecompile =
|
||||
else:
|
||||
result = rrRodDoesNotExist
|
||||
if (result != rrNone) and (gVerbosity > 0):
|
||||
MessageOut(`%`(reasonToFrmt[result], [filename]))
|
||||
MsgWriteln(`%`(reasonToFrmt[result], [filename]))
|
||||
if (result != rrNone) or (optForceFullMake in gGlobalOptions):
|
||||
# recompilation is necessary:
|
||||
r = nil
|
||||
|
||||
@@ -42,13 +42,13 @@ proc filterSym(s: PSym): bool {.inline.} =
|
||||
|
||||
proc suggestField(s: PSym) =
|
||||
if filterSym(s):
|
||||
MessageOut(SymToStr(s, isLocal=true, sectionSuggest))
|
||||
OutWriteln(SymToStr(s, isLocal=true, sectionSuggest))
|
||||
|
||||
template wholeSymTab(cond, section: expr) =
|
||||
for i in countdown(c.tab.tos-1, 0):
|
||||
for it in items(c.tab.stack[i]):
|
||||
if cond:
|
||||
MessageOut(SymToStr(it, isLocal = i > ModuleTablePos, section))
|
||||
OutWriteln(SymToStr(it, isLocal = i > ModuleTablePos, section))
|
||||
|
||||
proc suggestSymList(list: PNode) =
|
||||
for i in countup(0, sonsLen(list) - 1):
|
||||
@@ -115,11 +115,11 @@ proc suggestFieldAccess(c: PContext, n: PNode) =
|
||||
# all symbols accessible, because we are in the current module:
|
||||
for it in items(c.tab.stack[ModuleTablePos]):
|
||||
if filterSym(it):
|
||||
MessageOut(SymToStr(it, isLocal=false, sectionSuggest))
|
||||
OutWriteln(SymToStr(it, isLocal=false, sectionSuggest))
|
||||
else:
|
||||
for it in items(n.sym.tab):
|
||||
if filterSym(it):
|
||||
MessageOut(SymToStr(it, isLocal=false, sectionSuggest))
|
||||
OutWriteln(SymToStr(it, isLocal=false, sectionSuggest))
|
||||
else:
|
||||
# fallback:
|
||||
suggestEverything(c, n)
|
||||
@@ -228,7 +228,7 @@ proc suggestExpr*(c: PContext, node: PNode) =
|
||||
|
||||
if optDef in gGlobalOptions:
|
||||
var n = findClosestSym(fuzzySemCheck(c, node))
|
||||
if n != nil: MessageOut(SymToStr(n.sym, isLocal=false, sectionDef))
|
||||
if n != nil: OutWriteln(SymToStr(n.sym, isLocal=false, sectionDef))
|
||||
quit(0)
|
||||
|
||||
proc suggestStmt*(c: PContext, n: PNode) =
|
||||
|
||||
@@ -140,7 +140,7 @@ proc applyFilter(p: var TParsers, n: PNode, filename: string,
|
||||
if f != filtNone:
|
||||
if gVerbosity >= 2:
|
||||
rawMessage(hintCodeBegin, [])
|
||||
messageOut(result.s)
|
||||
MsgWriteln(result.s)
|
||||
rawMessage(hintCodeEnd, [])
|
||||
|
||||
proc evalPipe(p: var TParsers, n: PNode, filename: string,
|
||||
|
||||
Reference in New Issue
Block a user