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-dictionary.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'source/core/slang-dictionary.h') diff --git a/source/core/slang-dictionary.h b/source/core/slang-dictionary.h index 51b61de60..eef7d6908 100644 --- a/source/core/slang-dictionary.h +++ b/source/core/slang-dictionary.h @@ -171,7 +171,7 @@ namespace Slang } if (insertPos != -1) return FindPositionResult(-1, insertPos); - throw InvalidOperationException("Hash map is full. This indicates an error in Key::Equal or Key::getHashCode."); + SLANG_ASSERT_FAILURE("Hash map is full. This indicates an error in Key::Equal or Key::getHashCode."); } TValue & _Insert(KeyValuePair&& kvPair, int pos) { @@ -217,12 +217,12 @@ namespace Slang return true; } else - throw InvalidOperationException("Inconsistent find result returned. This is a bug in Dictionary implementation."); + SLANG_ASSERT_FAILURE("Inconsistent find result returned. This is a bug in Dictionary implementation."); } void Add(KeyValuePair&& kvPair) { if (!AddIfNotExists(_Move(kvPair))) - throw KeyExistsException("The key already exists in Dictionary."); + SLANG_ASSERT_FAILURE("The key already exists in Dictionary."); } TValue& Set(KeyValuePair&& kvPair) { @@ -236,7 +236,7 @@ namespace Slang return _Insert(_Move(kvPair), pos.InsertionPosition); } else - throw InvalidOperationException("Inconsistent find result returned. This is a bug in Dictionary implementation."); + SLANG_ASSERT_FAILURE("Inconsistent find result returned. This is a bug in Dictionary implementation."); } public: class Iterator @@ -358,7 +358,7 @@ namespace Slang return nullptr; } else - throw InvalidOperationException("Inconsistent find result returned. This is a bug in Dictionary implementation."); + SLANG_ASSERT_FAILURE("Inconsistent find result returned. This is a bug in Dictionary implementation."); } /// This differs from TryGetValueOrAdd, in that it always returns the Value held in the Dictionary. @@ -379,7 +379,7 @@ namespace Slang return _Insert(_Move(kvPair), pos.InsertionPosition); } else - throw InvalidOperationException("Inconsistent find result returned. This is a bug in Dictionary implementation."); + SLANG_ASSERT_FAILURE("Inconsistent find result returned. This is a bug in Dictionary implementation."); } template @@ -440,7 +440,7 @@ namespace Slang return dict->hashMap[pos.ObjectPosition].Value; } else - throw KeyNotFoundException("The key does not exists in dictionary."); + SLANG_ASSERT_FAILURE("The key does not exists in dictionary."); } inline TValue & operator()() const { @@ -742,8 +742,7 @@ namespace Slang } if (insertPos != -1) return FindPositionResult(-1, insertPos); - throw InvalidOperationException( - "Hash map is full. This indicates an error in Key::Equal or Key::GetHashCode."); + SLANG_ASSERT_FAILURE("Hash map is full. This indicates an error in Key::Equal or Key::GetHashCode."); } TValue& _Insert(KeyValuePair&& kvPair, int pos) { @@ -791,13 +790,12 @@ namespace Slang return true; } else - throw InvalidOperationException("Inconsistent find result returned. This is a " - "bug in Dictionary implementation."); + SLANG_ASSERT_FAILURE("Inconsistent find result returned. This is a bug in Dictionary implementation."); } void Add(KeyValuePair&& kvPair) { if (!AddIfNotExists(_Move(kvPair))) - throw KeyExistsException("The key already exists in Dictionary."); + SLANG_ASSERT_FAILURE("The key already exists in Dictionary."); } TValue& Set(KeyValuePair&& kvPair) { @@ -814,8 +812,7 @@ namespace Slang return _Insert(_Move(kvPair), pos.InsertionPosition); } else - throw InvalidOperationException("Inconsistent find result returned. This is a " - "bug in Dictionary implementation."); + SLANG_ASSERT_FAILURE("Inconsistent find result returned. This is a bug in Dictionary implementation."); } public: @@ -923,7 +920,7 @@ namespace Slang } else { - throw KeyNotFoundException("The key does not exists in dictionary."); + SLANG_ASSERT_FAILURE("The key does not exists in dictionary."); } } inline TValue& operator()() const { return GetValue(); } -- cgit v1.2.3