diff options
-rwxr-xr-x | rod/commands.nim | 8 | ||||
-rwxr-xr-x | rod/condsyms.nim | 12 | ||||
-rwxr-xr-x | rod/evals.nim | 4 | ||||
-rwxr-xr-x | rod/extccomp.nim | 2 | ||||
-rwxr-xr-x | rod/main.nim | 4 | ||||
-rwxr-xr-x | rod/msgs.nim | 15 | ||||
-rwxr-xr-x | rod/nimconf.nim | 6 | ||||
-rwxr-xr-x | rod/rodread.nim | 6 | ||||
-rw-r--r-- | rod/suggest.nim | 10 | ||||
-rwxr-xr-x | rod/syntaxes.nim | 2 |
10 files changed, 36 insertions, 33 deletions
diff --git a/rod/commands.nim b/rod/commands.nim index 6ba615cf1..83c01f0ed 100755 --- a/rod/commands.nim +++ b/rod/commands.nim @@ -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) = diff --git a/rod/condsyms.nim b/rod/condsyms.nim index b6c3b90af..7a7505511 100755 --- a/rod/condsyms.nim +++ b/rod/condsyms.nim @@ -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) diff --git a/rod/evals.nim b/rod/evals.nim index bb32804fe..c4b054437 100755 --- a/rod/evals.nim +++ b/rod/evals.nim @@ -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) diff --git a/rod/extccomp.nim b/rod/extccomp.nim index bb29cea33..ea64c16b6 100755 --- a/rod/extccomp.nim +++ b/rod/extccomp.nim @@ -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) = diff --git a/rod/main.nim b/rod/main.nim index 55ac32caa..2ec65be58 100755 --- a/rod/main.nim +++ b/rod/main.nim @@ -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() diff --git a/rod/msgs.nim b/rod/msgs.nim index ef3886344..dd60c4cae 100755 --- a/rod/msgs.nim +++ b/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) diff --git a/rod/nimconf.nim b/rod/nimconf.nim index 836be5097..231377978 100755 --- a/rod/nimconf.nim +++ b/rod/nimconf.nim @@ -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) - \ No newline at end of file + diff --git a/rod/rodread.nim b/rod/rodread.nim index 3159ec961..36cb29185 100755 --- a/rod/rodread.nim +++ b/rod/rodread.nim @@ -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 diff --git a/rod/suggest.nim b/rod/suggest.nim index ab1119f9c..f553bde90 100644 --- a/rod/suggest.nim +++ b/rod/suggest.nim @@ -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) = diff --git a/rod/syntaxes.nim b/rod/syntaxes.nim index 44c594fea..adb17efee 100755 --- a/rod/syntaxes.nim +++ b/rod/syntaxes.nim @@ -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, |