msgs: One msgWriteln with optional flags
Instead of msgWriteln, outWriteln and stdoutWriteln doing essentially the same.
This commit is contained in:
parent
a90e23a4dd
commit
acb6a36656
3 changed files with 19 additions and 24 deletions
|
|
@ -317,11 +317,12 @@ proc mainCommand* =
|
||||||
(key: "lib_paths", val: libpaths)
|
(key: "lib_paths", val: libpaths)
|
||||||
]
|
]
|
||||||
|
|
||||||
outWriteln($dumpdata)
|
msgWriteln($dumpdata, {msgStdout, msgSkipHook})
|
||||||
else:
|
else:
|
||||||
outWriteln("-- list of currently defined symbols --")
|
msgWriteln("-- list of currently defined symbols --",
|
||||||
for s in definedSymbolNames(): outWriteln(s)
|
{msgStdout, msgSkipHook})
|
||||||
outWriteln("-- end of list --")
|
for s in definedSymbolNames(): msgWriteln(s, {msgStdout, msgSkipHook})
|
||||||
|
msgWriteln("-- end of list --", {msgStdout, msgSkipHook})
|
||||||
|
|
||||||
for it in iterSearchPath(searchPaths): msgWriteln(it)
|
for it in iterSearchPath(searchPaths): msgWriteln(it)
|
||||||
of "check":
|
of "check":
|
||||||
|
|
|
||||||
|
|
@ -727,20 +727,23 @@ proc `??`* (info: TLineInfo, filename: string): bool =
|
||||||
|
|
||||||
var gTrackPos*: TLineInfo
|
var gTrackPos*: TLineInfo
|
||||||
|
|
||||||
proc outWriteln*(s: string) =
|
type
|
||||||
## Writes to stdout. Always.
|
MsgFlag* = enum ## flags altering msgWriteln behavior
|
||||||
if eStdOut in errorOutputs:
|
msgStdout, ## force writing to stdout, even stderr is default
|
||||||
writeLine(stdout, s)
|
msgSkipHook ## skip message hook even if it is present
|
||||||
flushFile(stdout)
|
MsgFlags* = set[MsgFlag]
|
||||||
|
|
||||||
proc msgWriteln*(s: string) =
|
proc msgWriteln*(s: string, flags: MsgFlags = {}) =
|
||||||
## Writes to stderr. If --stdout option is given, writes to stdout instead.
|
## Writes given message string to stderr by default.
|
||||||
|
## If ``--stdout`` option is given, writes to stdout instead. If message hook
|
||||||
|
## is present, then it is used to output message rather than stderr/stdout.
|
||||||
|
## This behavior can be altered by given optional flags.
|
||||||
|
|
||||||
#if gCmd == cmdIdeTools and optCDebug notin gGlobalOptions: return
|
#if gCmd == cmdIdeTools and optCDebug notin gGlobalOptions: return
|
||||||
|
|
||||||
if not isNil(writelnHook):
|
if not isNil(writelnHook) and msgSkipHook notin flags:
|
||||||
writelnHook(s)
|
writelnHook(s)
|
||||||
elif optStdout in gGlobalOptions:
|
elif optStdout in gGlobalOptions or msgStdout in flags:
|
||||||
if eStdOut in errorOutputs:
|
if eStdOut in errorOutputs:
|
||||||
writeLine(stdout, s)
|
writeLine(stdout, s)
|
||||||
flushFile(stdout)
|
flushFile(stdout)
|
||||||
|
|
@ -751,15 +754,6 @@ proc msgWriteln*(s: string) =
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
flushFile(stderr)
|
flushFile(stderr)
|
||||||
|
|
||||||
proc stdoutWriteln*(s: string) =
|
|
||||||
## Writes to stdout.
|
|
||||||
## Should be used only for VM time equivalents to procs outputting to stdout.
|
|
||||||
if not isNil(writelnHook):
|
|
||||||
writelnHook(s)
|
|
||||||
else:
|
|
||||||
writeLine(stdout, s)
|
|
||||||
flushFile(stdout)
|
|
||||||
|
|
||||||
macro callIgnoringStyle(theProc: typed, first: typed,
|
macro callIgnoringStyle(theProc: typed, first: typed,
|
||||||
args: varargs[expr]): stmt =
|
args: varargs[expr]): stmt =
|
||||||
let typForegroundColor = bindSym"ForegroundColor".getType
|
let typForegroundColor = bindSym"ForegroundColor".getType
|
||||||
|
|
|
||||||
|
|
@ -811,13 +811,13 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
of opcEcho:
|
of opcEcho:
|
||||||
let rb = instr.regB
|
let rb = instr.regB
|
||||||
if rb == 1:
|
if rb == 1:
|
||||||
stdoutWriteln(regs[ra].node.strVal)
|
msgWriteln(regs[ra].node.strVal, {msgStdout})
|
||||||
else:
|
else:
|
||||||
var outp = ""
|
var outp = ""
|
||||||
for i in ra..ra+rb-1:
|
for i in ra..ra+rb-1:
|
||||||
#if regs[i].kind != rkNode: debug regs[i]
|
#if regs[i].kind != rkNode: debug regs[i]
|
||||||
outp.add(regs[i].node.strVal)
|
outp.add(regs[i].node.strVal)
|
||||||
stdoutWriteln(outp)
|
msgWriteln(outp, {msgStdout})
|
||||||
of opcContainsSet:
|
of opcContainsSet:
|
||||||
decodeBC(rkInt)
|
decodeBC(rkInt)
|
||||||
regs[ra].intVal = ord(inSet(regs[rb].node, regs[rc].regToNode))
|
regs[ra].intVal = ord(inSet(regs[rb].node, regs[rc].regToNode))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue