From 97bb82ebcdf8f1391b9d93b5a8d7b1dfc4e88e52 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 4 Oct 2021 14:15:51 -0400 Subject: 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. --- source/core/slang-signal.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 source/core/slang-signal.h (limited to 'source/core/slang-signal.h') 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 -- cgit v1.2.3