diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-04-20 13:42:20 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-20 13:42:20 -0400 |
| commit | 088644c21c015eb60a41a59f417990023f1f4ef8 (patch) | |
| tree | 596d224f99e35dcd3d66507cfe297bc25407336d /source/compiler-core/slang-source-map.h | |
| parent | 4e67cdedbef8f643c90b48172d5419d3dd1839db (diff) | |
Improve SourceMap coverage/testing (#2818)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP around more value like behavior for SourceMap/StringPool.
* Use default impls on SourceMap ctor/assignment.
* Handle comparison of SourceMaps.
Some small fixes.
Expand unit tests.
Diffstat (limited to 'source/compiler-core/slang-source-map.h')
| -rw-r--r-- | source/compiler-core/slang-source-map.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/compiler-core/slang-source-map.h b/source/compiler-core/slang-source-map.h index e0c8d065a..0c55d3a1a 100644 --- a/source/compiler-core/slang-source-map.h +++ b/source/compiler-core/slang-source-map.h @@ -19,6 +19,8 @@ public: struct Entry { + typedef Entry ThisType; + void init() { generatedColumn = 0; @@ -28,6 +30,16 @@ public: nameIndex = 0; } + bool operator==(const ThisType& rhs) const + { + return generatedColumn == rhs.generatedColumn && + sourceFileIndex == rhs.sourceFileIndex && + sourceLine == rhs.sourceLine && + sourceColumn == rhs.sourceColumn && + nameIndex == rhs.nameIndex; + } + SLANG_FORCE_INLINE bool operator!=(const ThisType& rhs) const { return !(*this == rhs); } + // Note! All column/line are zero indexed Index generatedColumn; ///< The generated column Index sourceFileIndex; ///< The index into the source name/contents @@ -71,12 +83,24 @@ public: /// Swap this with rhs void swapWith(ThisType& rhs); + /// == + /// + /// Note that equality requires that entries for a line must be *in the same order* + /// even though strictly speaking with different orders could be considered equivalent. + bool operator==(const ThisType& rhs) const; + /// != + bool operator!=(const ThisType& rhs) const { return !(*this == rhs); } + /// Ctor SourceMap(): m_slicePool(StringSlicePool::Style::Default) { clear(); } + /// Copy Ctor + SourceMap(const ThisType& rhs) = default; + /// Assignment + ThisType& operator=(const ThisType& rhs) = default; String m_file; String m_sourceRoot; |
