diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-04-19 17:06:56 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-19 17:06:56 -0400 |
| commit | 588991f6df3d6813378721166a7260990835817e (patch) | |
| tree | fca8c57fedb1967af20ca2da50bbd7dc8afc6a07 /source/slang/slang-emit-source-writer.cpp | |
| parent | 520a3c064c42e8cd50ef4fde21539870d5b19cb7 (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/slang/slang-emit-source-writer.cpp')
| -rw-r--r-- | source/slang/slang-emit-source-writer.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/slang/slang-emit-source-writer.cpp b/source/slang/slang-emit-source-writer.cpp index f66f36758..985d0a0bf 100644 --- a/source/slang/slang-emit-source-writer.cpp +++ b/source/slang/slang-emit-source-writer.cpp @@ -18,7 +18,7 @@ namespace Slang { -SourceWriter::SourceWriter(SourceManager* sourceManager, LineDirectiveMode lineDirectiveMode, SourceMap* sourceMap) +SourceWriter::SourceWriter(SourceManager* sourceManager, LineDirectiveMode lineDirectiveMode, IBoxValue<SourceMap>* sourceMap) { m_sourceMap = sourceMap; m_lineDirectiveMode = lineDirectiveMode; @@ -360,23 +360,25 @@ void SourceWriter::_updateSourceMap(const HumaneSourceLoc& sourceLocation) if (sourceLocation.line <= 0) return; + auto sourceMap = m_sourceMap->getPtr(); + // We need to work out the current column in the generated (ie being written) output Index generatedLineIndex, generatedColumnIndex; _calcLocation(generatedLineIndex, generatedColumnIndex); // Advance to the current output line - m_sourceMap->advanceToLine(generatedLineIndex); + sourceMap->advanceToLine(generatedLineIndex); // Add the entry into the map, mapping back to the original source SourceMap::Entry entry; entry.init(); - entry.sourceFileIndex = m_sourceMap->getSourceFileIndex(sourceLocation.pathInfo.getName().getUnownedSlice()); + entry.sourceFileIndex = sourceMap->getSourceFileIndex(sourceLocation.pathInfo.getName().getUnownedSlice()); entry.sourceLine = sourceLocation.line - 1; entry.sourceColumn = sourceLocation.column - 1; entry.generatedColumn = generatedColumnIndex; - m_sourceMap->addEntry(entry); + sourceMap->addEntry(entry); } void SourceWriter::_emitLineDirectiveIfNeeded(const HumaneSourceLoc& sourceLocation) |
