hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 218d566b85609cbe88b732927138b6451ba2a38d
parent 8896188829a00923d51bc8ec471bd138de5f965a
Author: Joe Finney <me@spxtr.net>
Date:   Mon, 31 Oct 2022 10:09:22 -0700

Add location parameter to rc::_abort.

This goes with the patch to harec that allows assert/abort to have
non-constant string inputs.

Signed-off-by: Joe Finney <me@spxtr.net>

Diffstat:
Mrt/+freebsd/abort.ha | 5++++-
Mrt/+linux/abort.ha | 5++++-
Mrt/abort+test.ha | 4++--
Mrt/abort.ha | 16+++-------------
4 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/rt/+freebsd/abort.ha b/rt/+freebsd/abort.ha @@ -1,10 +1,13 @@ // License: MPL-2.0 // (c) 2021 Drew DeVault <sir@cmpwn.com> -fn platform_abort(msg: str) void = { +fn platform_abort(loc: str, msg: str) void = { const prefix = "Abort: "; + const sep = ": "; const linefeed = "\n"; write(STDERR_FILENO, *(&prefix: **void): *const char, len(prefix)): void; + write(STDERR_FILENO, *(&loc: **void): *const char, len(loc)): void; + write(STDERR_FILENO, *(&sep: **void): *const char, len(sep)): void; write(STDERR_FILENO, *(&msg: **void): *const char, len(msg)): void; write(STDERR_FILENO, *(&linefeed: **void): *const char, 1): void; kill(getpid(), SIGABRT): void; diff --git a/rt/+linux/abort.ha b/rt/+linux/abort.ha @@ -1,10 +1,13 @@ // License: MPL-2.0 // (c) 2021 Drew DeVault <sir@cmpwn.com> -fn platform_abort(msg: str) void = { +fn platform_abort(loc: str, msg: str) void = { const prefix = "Abort: "; + const sep = ": "; const linefeed = "\n"; write(STDERR_FILENO, *(&prefix: **void): *const char, len(prefix)): void; + write(STDERR_FILENO, *(&loc: **void): *const char, len(loc)): void; + write(STDERR_FILENO, *(&sep: **void): *const char, len(sep)): void; write(STDERR_FILENO, *(&msg: **void): *const char, len(msg)): void; write(STDERR_FILENO, *(&linefeed: **void): *const char, 1): void; kill(getpid(), SIGABRT): void; diff --git a/rt/abort+test.ha b/rt/abort+test.ha @@ -2,8 +2,8 @@ // (c) 2021 Drew DeVault <sir@cmpwn.com> // (c) 2021 Eyal Sawady <ecs@d2evs.net> -export @noreturn @symbol("rt.abort") fn _abort(msg: str) void = { - reason = abort_reason { loc = "", msg = msg }; +export @noreturn @symbol("rt.abort") fn _abort(loc: str, msg: str) void = { + reason = abort_reason { loc = loc, msg = msg }; longjmp(&jmp, 1); }; diff --git a/rt/abort.ha b/rt/abort.ha @@ -1,8 +1,8 @@ // License: MPL-2.0 // (c) 2021 Drew DeVault <sir@cmpwn.com> -export @noreturn @symbol("rt.abort") fn _abort(msg: str) void = { - platform_abort(msg); +export @noreturn @symbol("rt.abort") fn _abort(loc: str, msg: str) void = { + platform_abort(loc, msg); }; // See harec:include/gen.h @@ -15,15 +15,5 @@ const reasons: [_]str = [ ]; export @noreturn fn abort_fixed(loc: str, i: int) void = { - // TODO: This is also platform-specific - const prefix = "Abort: "; - const sep = ": "; - const linefeed = "\n"; - write(STDERR_FILENO, *(&prefix: **void): *const char, len(prefix)): void; - write(STDERR_FILENO, *(&loc: **void): *const char, len(loc)): void; - write(STDERR_FILENO, *(&sep: **void): *const char, len(sep)): void; - write(STDERR_FILENO, *(&reasons[i]: **void): *const char, len(reasons[i])): void; - write(STDERR_FILENO, *(&linefeed: **void): *const char, 1): void; - kill(getpid(), SIGABRT): void; - for (true) void; + platform_abort(loc, reasons[i]); };