From 65368683ad92b858d0a391cb29d37c0476784b40 Mon Sep 17 00:00:00 2001 From: r00ster91 Date: Fri, 3 Mar 2023 18:35:03 +0100 Subject: add @trap builtin This introduces a new builtin function that compiles down to something that results in an illegal instruction exception/interrupt. It can be used to exit a program abnormally. This implements the builtin for all backends. --- doc/langref.html.in | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'doc/langref.html.in') diff --git a/doc/langref.html.in b/doc/langref.html.in index e016ef13f8..0290d3acd6 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -7818,12 +7818,14 @@ comptime {

This function inserts a platform-specific debug trap instruction which causes debuggers to break there. + Unlike for {#syntax#}@trap(){#endsyntax#}, execution may continue after this point if the program is resumed.

This function is only valid within function scope.

- + {#see_also|@trap#} {#header_close#} + {#header_open|@mulAdd#}
{#syntax#}@mulAdd(comptime T: type, a: T, b: T, c: T) T{#endsyntax#}

@@ -9393,6 +9395,19 @@ fn List(comptime T: type) type {

{#header_close#} + {#header_open|@trap#} +
{#syntax#}@trap() noreturn{#endsyntax#}
+

+ This function inserts a platform-specific trap/jam instruction which can be used to exit the program abnormally. + This may be implemented by explicitly emitting an invalid instruction which may cause an illegal instruction exception of some sort. + Unlike for {#syntax#}@breakpoint(){#endsyntax#}, execution does not continue after this point. +

+

+ This function is only valid within function scope. +

+ {#see_also|@breakpoint#} + {#header_close#} + {#header_open|@truncate#}
{#syntax#}@truncate(comptime T: type, integer: anytype) T{#endsyntax#}

-- cgit v1.2.3