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-loc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/compiler-core/slang-source-loc.cpp') diff --git a/source/compiler-core/slang-source-loc.cpp b/source/compiler-core/slang-source-loc.cpp index 23cbdf839..3d992ee8d 100644 --- a/source/compiler-core/slang-source-loc.cpp +++ b/source/compiler-core/slang-source-loc.cpp @@ -211,7 +211,7 @@ SlangResult _findLocWithSourceMap(SourceManager* lookupSourceManager, SourceView auto sourceMap = sourceFile->getSourceMap(); SLANG_ASSERT(sourceMap); - entryIndex = sourceMap->findEntry(lineIndex, colIndex); + entryIndex = sourceMap->get().findEntry(lineIndex, colIndex); } if (entryIndex < 0) @@ -222,7 +222,7 @@ SlangResult _findLocWithSourceMap(SourceManager* lookupSourceManager, SourceView // Keep searching through source maps do { - auto sourceMap = sourceFile->getSourceMap(); + auto sourceMap = sourceFile->getSourceMap()->getPtr(); // Find the entry const auto& entry = sourceMap->getEntryByIndex(entryIndex); @@ -242,7 +242,7 @@ SlangResult _findLocWithSourceMap(SourceManager* lookupSourceManager, SourceView // If it has a source map, we try and look up the current location in it's source map if (auto foundSourceMap = foundSourceFile->getSourceMap()) { - const auto foundEntryIndex = foundSourceMap->findEntry(entry.sourceLine, entry.sourceColumn); + const auto foundEntryIndex = foundSourceMap->get().findEntry(entry.sourceLine, entry.sourceColumn); // If we found the entry repeat the lookup if (foundEntryIndex >= 0) @@ -258,7 +258,7 @@ SlangResult _findLocWithSourceMap(SourceManager* lookupSourceManager, SourceView } while (false); // Generate the HandleSourceLoc - auto sourceMap = sourceFile->getSourceMap(); + auto sourceMap = sourceFile->getSourceMap()->getPtr(); const auto& entry = sourceMap->getEntryByIndex(entryIndex); // We need to add the pool of the originating source view/file -- cgit v1.2.3