Merge branch 'araq-ic-system' into araq-ic0

This commit is contained in:
araq
2025-11-18 22:29:16 +01:00
2 changed files with 26 additions and 23 deletions

View File

@@ -1740,6 +1740,28 @@ when not defined(nimscript):
when not declared(sysFatal):
include "system/fatal"
proc echo*(x: varargs[typed, `$`]) {.magic: "Echo", benign, sideEffect.}
## Writes and flushes the parameters to the standard output.
##
## Special built-in that takes a variable number of arguments. Each argument
## is converted to a string via `$`, so it works for user-defined
## types that have an overloaded `$` operator.
## It is roughly equivalent to `writeLine(stdout, x); flushFile(stdout)`, but
## available for the JavaScript target too.
##
## Unlike other IO operations this is guaranteed to be thread-safe as
## `echo` is very often used for debugging convenience. If you want to use
## `echo` inside a `proc without side effects
## <manual.html#pragmas-nosideeffect-pragma>`_ you can use `debugEcho
## <#debugEcho,varargs[typed,]>`_ instead.
proc debugEcho*(x: varargs[typed, `$`]) {.magic: "Echo", noSideEffect,
tags: [], raises: [].}
## Same as `echo <#echo,varargs[typed,]>`_, but as a special semantic rule,
## `debugEcho` pretends to be free of side effects, so that it can be used
## for debugging routines marked as `noSideEffect
## <manual.html#pragmas-nosideeffect-pragma>`_.
type
PFrame* = ptr TFrame ## Represents a runtime frame of the call stack;
## part of the debugger API.
@@ -2002,27 +2024,6 @@ elif hasAlloc:
inc(i)
{.pop.}
proc echo*(x: varargs[typed, `$`]) {.magic: "Echo", benign, sideEffect.}
## Writes and flushes the parameters to the standard output.
##
## Special built-in that takes a variable number of arguments. Each argument
## is converted to a string via `$`, so it works for user-defined
## types that have an overloaded `$` operator.
## It is roughly equivalent to `writeLine(stdout, x); flushFile(stdout)`, but
## available for the JavaScript target too.
##
## Unlike other IO operations this is guaranteed to be thread-safe as
## `echo` is very often used for debugging convenience. If you want to use
## `echo` inside a `proc without side effects
## <manual.html#pragmas-nosideeffect-pragma>`_ you can use `debugEcho
## <#debugEcho,varargs[typed,]>`_ instead.
proc debugEcho*(x: varargs[typed, `$`]) {.magic: "Echo", noSideEffect,
tags: [], raises: [].}
## Same as `echo <#echo,varargs[typed,]>`_, but as a special semantic rule,
## `debugEcho` pretends to be free of side effects, so that it can be used
## for debugging routines marked as `noSideEffect
## <manual.html#pragmas-nosideeffect-pragma>`_.
when hostOS == "standalone" and defined(nogc):
proc nimToCStringConv(s: NimString): cstring {.compilerproc, inline.} =

View File

@@ -43,6 +43,8 @@ proc writeToStdErr(msg: string) {.inline.} =
writeToStdErr(msg.cstring, msg.len)
proc cstrToStrBuiltin(x: cstring): string {.magic: "CStrToStr", noSideEffect.}
when defined(genode):
template `$`(s: string): string = s
proc showErrorMessage(data: cstring, length: int) {.gcsafe, raises: [].} =
var toWrite = true
@@ -55,7 +57,7 @@ proc showErrorMessage(data: cstring, length: int) {.gcsafe, raises: [].} =
if toWrite:
when defined(genode):
# stderr not available by default, use the LOG session
echo data
echo cstrToStrBuiltin(data)
else:
writeToStdErr(data, length)
@@ -638,7 +640,7 @@ when defined(cpp) and appType != "lib" and not gotoBasedExceptions and
msg = currException.getStackTrace() & "Error: unhandled exception: " &
currException.msg & " [" & cstrToStrBuiltin(currException.name) & "]"
except StdException as e:
msg = "Error: unhandled cpp exception: " & $e.what()
msg = "Error: unhandled cpp exception: " & cstrToStrBuiltin(e.what())
except:
msg = "Error: unhandled unknown cpp exception"