make system/fatal importable (#20719)
This commit is contained in:
parent
49e793e8c4
commit
d735c447d3
3 changed files with 15 additions and 16 deletions
|
|
@ -9,8 +9,7 @@
|
||||||
|
|
||||||
## This module implements assertion handling.
|
## This module implements assertion handling.
|
||||||
|
|
||||||
when not declared(sysFatal):
|
import system/fatal
|
||||||
include "system/fatal"
|
|
||||||
|
|
||||||
import std/private/miscdollars
|
import std/private/miscdollars
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1637,8 +1637,13 @@ when not defined(nimscript):
|
||||||
## for debug builds. Since it's usually used for debugging, this
|
## for debug builds. Since it's usually used for debugging, this
|
||||||
## is proclaimed to have no IO effect!
|
## is proclaimed to have no IO effect!
|
||||||
|
|
||||||
when not declared(sysFatal):
|
|
||||||
include "system/fatal"
|
when defined(nimHasExceptionsQuery):
|
||||||
|
const gotoBasedExceptions = compileOption("exceptions", "goto")
|
||||||
|
else:
|
||||||
|
const gotoBasedExceptions = false
|
||||||
|
|
||||||
|
import system/fatal
|
||||||
|
|
||||||
when not defined(nimscript):
|
when not defined(nimscript):
|
||||||
{.push stackTrace: off, profiler: off.}
|
{.push stackTrace: off, profiler: off.}
|
||||||
|
|
|
||||||
|
|
@ -9,27 +9,22 @@
|
||||||
|
|
||||||
{.push profiler: off.}
|
{.push profiler: off.}
|
||||||
|
|
||||||
when defined(nimHasExceptionsQuery):
|
|
||||||
const gotoBasedExceptions = compileOption("exceptions", "goto")
|
|
||||||
else:
|
|
||||||
const gotoBasedExceptions = false
|
|
||||||
|
|
||||||
when hostOS == "standalone":
|
when hostOS == "standalone":
|
||||||
include "$projectpath/panicoverride"
|
include "$projectpath/panicoverride"
|
||||||
|
|
||||||
func sysFatal(exceptn: typedesc, message: string) {.inline.} =
|
func sysFatal*(exceptn: typedesc, message: string) {.inline.} =
|
||||||
panic(message)
|
panic(message)
|
||||||
|
|
||||||
func sysFatal(exceptn: typedesc, message, arg: string) {.inline.} =
|
func sysFatal*(exceptn: typedesc, message, arg: string) {.inline.} =
|
||||||
rawoutput(message)
|
rawoutput(message)
|
||||||
panic(arg)
|
panic(arg)
|
||||||
|
|
||||||
elif (defined(nimQuirky) or defined(nimPanics)) and not defined(nimscript):
|
elif (defined(nimQuirky) or defined(nimPanics)) and not defined(nimscript):
|
||||||
import ansi_c
|
import system/ansi_c
|
||||||
|
|
||||||
func name(t: typedesc): string {.magic: "TypeTrait".}
|
func name(t: typedesc): string {.magic: "TypeTrait".}
|
||||||
|
|
||||||
func sysFatal(exceptn: typedesc, message, arg: string) {.inline, noreturn.} =
|
func sysFatal*(exceptn: typedesc, message, arg: string) {.inline, noreturn.} =
|
||||||
when nimvm:
|
when nimvm:
|
||||||
# TODO when doAssertRaises works in CT, add a test for it
|
# TODO when doAssertRaises works in CT, add a test for it
|
||||||
raise (ref exceptn)(msg: message & arg)
|
raise (ref exceptn)(msg: message & arg)
|
||||||
|
|
@ -46,14 +41,14 @@ elif (defined(nimQuirky) or defined(nimPanics)) and not defined(nimscript):
|
||||||
cstderr.rawWrite buf
|
cstderr.rawWrite buf
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
func sysFatal(exceptn: typedesc, message: string) {.inline, noreturn.} =
|
func sysFatal*(exceptn: typedesc, message: string) {.inline, noreturn.} =
|
||||||
sysFatal(exceptn, message, "")
|
sysFatal(exceptn, message, "")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
func sysFatal(exceptn: typedesc, message: string) {.inline, noreturn.} =
|
func sysFatal*(exceptn: typedesc, message: string) {.inline, noreturn.} =
|
||||||
raise (ref exceptn)(msg: message)
|
raise (ref exceptn)(msg: message)
|
||||||
|
|
||||||
func sysFatal(exceptn: typedesc, message, arg: string) {.inline, noreturn.} =
|
func sysFatal*(exceptn: typedesc, message, arg: string) {.inline, noreturn.} =
|
||||||
raise (ref exceptn)(msg: message & arg)
|
raise (ref exceptn)(msg: message & arg)
|
||||||
|
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue