summaryrefslogtreecommitdiff
path: root/source/core/slang-signal.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-10-04 14:15:51 -0400
committerGitHub <noreply@github.com>2021-10-04 14:15:51 -0400
commit97bb82ebcdf8f1391b9d93b5a8d7b1dfc4e88e52 (patch)
treef120ba282cbea96d23ed179737984a4610d3b520 /source/core/slang-signal.h
parentb3dfe383c6d31ff3dbd76dcfb32de8d536382f3e (diff)
Removing exceptions from core/compiler-core (#1953)
* #include an absolute path didn't work - because paths were taken to always be relative. * Refactor Stream. Working on all tests. * Split out CharEncode. * Make method names lower camel. m_prefix in Writer/Reader * Tidy up around CharEncode interface. * Small improvements around encode/decode. * Better use of types. * Remove readLine from TextReader. * Remove exceptions from Stream/Text handling. * Fix some typos. * Fix tabbing. * Fix missing override. * Remove remaining exception throw/catch via using signal mechanism. * Remove exceptions that are not used anymore. * Document the Stream interface. * Remove index for decoding 'get byte' function. * Fix CharReader -> ByteReader.
Diffstat (limited to 'source/core/slang-signal.h')
-rw-r--r--source/core/slang-signal.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/core/slang-signal.h b/source/core/slang-signal.h
new file mode 100644
index 000000000..2151bdcfe
--- /dev/null
+++ b/source/core/slang-signal.h
@@ -0,0 +1,44 @@
+#ifndef SLANG_CORE_SIGNAL_H
+#define SLANG_CORE_SIGNAL_H
+
+#include "slang-common.h"
+
+namespace Slang
+{
+
+enum class SignalType
+{
+ Unexpected,
+ Unimplemented,
+ AssertFailure,
+ Unreachable,
+ InvalidOperation,
+ AbortCompilation,
+};
+
+
+// Note that message can be passed as nullptr for no message.
+SLANG_RETURN_NEVER void handleSignal(SignalType type, char const* message);
+
+#define SLANG_UNEXPECTED(reason) \
+ ::Slang::handleSignal(::Slang::SignalType::Unexpected, reason)
+
+#define SLANG_UNIMPLEMENTED_X(what) \
+ ::Slang::handleSignal(::Slang::SignalType::Unimplemented, what)
+
+#define SLANG_UNREACHABLE(msg) \
+ ::Slang::handleSignal(::Slang::SignalType::Unreachable, msg)
+
+#define SLANG_ASSERT_FAILURE(msg) \
+ ::Slang::handleSignal(::Slang::SignalType::AssertFailure, msg)
+
+#define SLANG_INVALID_OPERATION(msg) \
+ ::Slang::handleSignal(::Slang::SignalType::InvalidOperation, msg)
+
+#define SLANG_ABORT_COMPILATION(msg) \
+ ::Slang::handleSignal(::Slang::SignalType::AbortCompilation, msg)
+
+
+}
+
+#endif