summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-source-map.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-04-19 17:06:56 -0400
committerGitHub <noreply@github.com>2023-04-19 17:06:56 -0400
commit588991f6df3d6813378721166a7260990835817e (patch)
treefca8c57fedb1967af20ca2da50bbd7dc8afc6a07 /source/compiler-core/slang-source-map.cpp
parent520a3c064c42e8cd50ef4fde21539870d5b19cb7 (diff)
Make SourceMap a value type (#2812)
* #include an absolute path didn't work - because paths were taken to always be relative. * Moved JSON source map writing logic to JSONSourceMapUtil. * Use ArtifactHandler to read/write SourceMaps. Use ObjectCastableAdapter to hold SourceMap Only serialize SourceMap <-> JSON on demand. * Make some types swappable. * BoxValue impl. * Added asBoxValue. * Remove const get funcs. * Fix typo in asBoxValue. * Fix another typo in asBoxValue. * Slightly simplify conversion to blob of SourceMap. * Small fix for asBoxValue
Diffstat (limited to 'source/compiler-core/slang-source-map.cpp')
-rw-r--r--source/compiler-core/slang-source-map.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/compiler-core/slang-source-map.cpp b/source/compiler-core/slang-source-map.cpp
index 4ea50eb3f..7a6e368a4 100644
--- a/source/compiler-core/slang-source-map.cpp
+++ b/source/compiler-core/slang-source-map.cpp
@@ -4,7 +4,7 @@ namespace Slang {
void SourceMap::clear()
{
- String empty;
+ const String empty;
m_file = empty;
m_sourceRoot = empty;
@@ -23,6 +23,18 @@ void SourceMap::clear()
m_slicePool.clear();
}
+void SourceMap::swapWith(ThisType& rhs)
+{
+ m_file.swapWith(rhs.m_file);
+ m_sourceRoot.swapWith(rhs.m_sourceRoot);
+ m_sources.swapWith(rhs.m_sources);
+ m_names.swapWith(rhs.m_names);
+ m_sourcesContent.swapWith(rhs.m_sourcesContent);
+ m_lineStarts.swapWith(rhs.m_lineStarts);
+ m_lineEntries.swapWith(rhs.m_lineEntries);
+ m_slicePool.swapWith(rhs.m_slicePool);
+}
+
void SourceMap::advanceToLine(Index nextLineIndex)
{
const Count currentLineIndex = getGeneratedLineCount() - 1;