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