Skip to content

Commit bd34dec

Browse files
committed
Merge branch 'araq-ic-system' into araq-ic0
2 parents 855e606 + 51028a8 commit bd34dec

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

lib/system.nim

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,28 @@ when not defined(nimscript):
17401740
when not declared(sysFatal):
17411741
include "system/fatal"
17421742

1743+
proc echo*(x: varargs[typed, `$`]) {.magic: "Echo", benign, sideEffect.}
1744+
## Writes and flushes the parameters to the standard output.
1745+
##
1746+
## Special built-in that takes a variable number of arguments. Each argument
1747+
## is converted to a string via `$`, so it works for user-defined
1748+
## types that have an overloaded `$` operator.
1749+
## It is roughly equivalent to `writeLine(stdout, x); flushFile(stdout)`, but
1750+
## available for the JavaScript target too.
1751+
##
1752+
## Unlike other IO operations this is guaranteed to be thread-safe as
1753+
## `echo` is very often used for debugging convenience. If you want to use
1754+
## `echo` inside a `proc without side effects
1755+
## <manual.html#pragmas-nosideeffect-pragma>`_ you can use `debugEcho
1756+
## <#debugEcho,varargs[typed,]>`_ instead.
1757+
1758+
proc debugEcho*(x: varargs[typed, `$`]) {.magic: "Echo", noSideEffect,
1759+
tags: [], raises: [].}
1760+
## Same as `echo <#echo,varargs[typed,]>`_, but as a special semantic rule,
1761+
## `debugEcho` pretends to be free of side effects, so that it can be used
1762+
## for debugging routines marked as `noSideEffect
1763+
## <manual.html#pragmas-nosideeffect-pragma>`_.
1764+
17431765
type
17441766
PFrame* = ptr TFrame ## Represents a runtime frame of the call stack;
17451767
## part of the debugger API.
@@ -2002,27 +2024,6 @@ elif hasAlloc:
20022024
inc(i)
20032025
{.pop.}
20042026

2005-
proc echo*(x: varargs[typed, `$`]) {.magic: "Echo", benign, sideEffect.}
2006-
## Writes and flushes the parameters to the standard output.
2007-
##
2008-
## Special built-in that takes a variable number of arguments. Each argument
2009-
## is converted to a string via `$`, so it works for user-defined
2010-
## types that have an overloaded `$` operator.
2011-
## It is roughly equivalent to `writeLine(stdout, x); flushFile(stdout)`, but
2012-
## available for the JavaScript target too.
2013-
##
2014-
## Unlike other IO operations this is guaranteed to be thread-safe as
2015-
## `echo` is very often used for debugging convenience. If you want to use
2016-
## `echo` inside a `proc without side effects
2017-
## <manual.html#pragmas-nosideeffect-pragma>`_ you can use `debugEcho
2018-
## <#debugEcho,varargs[typed,]>`_ instead.
2019-
2020-
proc debugEcho*(x: varargs[typed, `$`]) {.magic: "Echo", noSideEffect,
2021-
tags: [], raises: [].}
2022-
## Same as `echo <#echo,varargs[typed,]>`_, but as a special semantic rule,
2023-
## `debugEcho` pretends to be free of side effects, so that it can be used
2024-
## for debugging routines marked as `noSideEffect
2025-
## <manual.html#pragmas-nosideeffect-pragma>`_.
20262027

20272028
when hostOS == "standalone" and defined(nogc):
20282029
proc nimToCStringConv(s: NimString): cstring {.compilerproc, inline.} =

lib/system/excpt.nim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ proc writeToStdErr(msg: string) {.inline.} =
4343
writeToStdErr(msg.cstring, msg.len)
4444

4545
proc cstrToStrBuiltin(x: cstring): string {.magic: "CStrToStr", noSideEffect.}
46+
when defined(genode):
47+
template `$`(s: string): string = s
4648

4749
proc showErrorMessage(data: cstring, length: int) {.gcsafe, raises: [].} =
4850
var toWrite = true
@@ -55,7 +57,7 @@ proc showErrorMessage(data: cstring, length: int) {.gcsafe, raises: [].} =
5557
if toWrite:
5658
when defined(genode):
5759
# stderr not available by default, use the LOG session
58-
echo data
60+
echo cstrToStrBuiltin(data)
5961
else:
6062
writeToStdErr(data, length)
6163

@@ -638,7 +640,7 @@ when defined(cpp) and appType != "lib" and not gotoBasedExceptions and
638640
msg = currException.getStackTrace() & "Error: unhandled exception: " &
639641
currException.msg & " [" & cstrToStrBuiltin(currException.name) & "]"
640642
except StdException as e:
641-
msg = "Error: unhandled cpp exception: " & $e.what()
643+
msg = "Error: unhandled cpp exception: " & cstrToStrBuiltin(e.what())
642644
except:
643645
msg = "Error: unhandled unknown cpp exception"
644646

0 commit comments

Comments
 (0)