From 588991f6df3d6813378721166a7260990835817e Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 19 Apr 2023 17:06:56 -0400 Subject: 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 --- source/compiler-core/slang-source-map.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/compiler-core/slang-source-map.cpp') 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; -- cgit v1.2.3