diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/core/slang-downstream-compiler.h | 14 | ||||
| -rw-r--r-- | source/core/slang-string-util.cpp | 8 | ||||
| -rw-r--r-- | source/core/slang-string-util.h | 4 |
3 files changed, 20 insertions, 6 deletions
diff --git a/source/core/slang-downstream-compiler.h b/source/core/slang-downstream-compiler.h index f43c4b560..7c9831dac 100644 --- a/source/core/slang-downstream-compiler.h +++ b/source/core/slang-downstream-compiler.h @@ -18,6 +18,8 @@ namespace Slang struct DownstreamDiagnostic { + typedef DownstreamDiagnostic ThisType; + enum class Type { Unknown, @@ -38,6 +40,18 @@ struct DownstreamDiagnostic stage = Stage::Compile; fileLine = 0; } + + bool operator==(const ThisType& rhs) const + { + return type == rhs.type && + stage == rhs.stage && + text == rhs.text && + code == rhs.code && + filePath == rhs.filePath && + fileLine == rhs.fileLine; + } + bool operator!=(const ThisType& rhs) const { return !(*this == rhs); } + static UnownedStringSlice getTypeText(Type type); Type type; ///< The type of error diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp index a859c6945..cac7c7cfa 100644 --- a/source/core/slang-string-util.cpp +++ b/source/core/slang-string-util.cpp @@ -136,12 +136,12 @@ namespace Slang { } } -/* static */int StringUtil::indexOfInSplit(const UnownedStringSlice& in, char splitChar, const UnownedStringSlice& find) +/* static */Index StringUtil::indexOfInSplit(const UnownedStringSlice& in, char splitChar, const UnownedStringSlice& find) { const char* start = in.begin(); const char* end = in.end(); - for (int i = 0; start < end; ++i) + for (Index i = 0; start < end; ++i) { // Move cur so it's either at the end or at next split character const char* cur = start; @@ -162,12 +162,12 @@ namespace Slang { return -1; } -UnownedStringSlice StringUtil::getAtInSplit(const UnownedStringSlice& in, char splitChar, int index) +UnownedStringSlice StringUtil::getAtInSplit(const UnownedStringSlice& in, char splitChar, Index index) { const char* start = in.begin(); const char* end = in.end(); - for (int i = 0; start < end; ++i) + for (Index i = 0; start < end; ++i) { // Move cur so it's either at the end or at next split character const char* cur = start; diff --git a/source/core/slang-string-util.h b/source/core/slang-string-util.h index dee4c7d66..dade8a61d 100644 --- a/source/core/slang-string-util.h +++ b/source/core/slang-string-util.h @@ -39,11 +39,11 @@ struct StringUtil /// Equivalent to doing a split and then finding the index of 'find' on the array /// Returns -1 if not found - static int indexOfInSplit(const UnownedStringSlice& in, char splitChar, const UnownedStringSlice& find); + static Index indexOfInSplit(const UnownedStringSlice& in, char splitChar, const UnownedStringSlice& find); /// Given the entry at the split index specified. /// Will return slice with begin() == nullptr if not found or input has begin() == nullptr) - static UnownedStringSlice getAtInSplit(const UnownedStringSlice& in, char splitChar, int index); + static UnownedStringSlice getAtInSplit(const UnownedStringSlice& in, char splitChar, Index index); /// Returns the size in bytes needed to hold the formatted string using the specified args, NOT including a terminating 0 /// NOTE! The caller *should* assume this will consume the va_list (use va_copy to make a copy to be consumed) |
