diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-03-24 09:56:59 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-24 09:56:59 -0400 |
| commit | e794de0d63e6de9be564c971fd40486ecf631293 (patch) | |
| tree | 903bd4100fd9c259d68f2893c61a36880e182f14 /source/compiler-core/slang-source-map.h | |
| parent | 03c10833beb331e234554808c2a80d3cadecc7c0 (diff) | |
Obfuscated source map writing (#2727)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP produce obfuscated source map and write when container is specified.
* Make the sourcemap generated name stable.
Diffstat (limited to 'source/compiler-core/slang-source-map.h')
| -rw-r--r-- | source/compiler-core/slang-source-map.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/source/compiler-core/slang-source-map.h b/source/compiler-core/slang-source-map.h index 739cf1992..accd2473f 100644 --- a/source/compiler-core/slang-source-map.h +++ b/source/compiler-core/slang-source-map.h @@ -43,7 +43,7 @@ struct SourceMap : public RefObject SlangResult encode(JSONContainer* container, DiagnosticSink* sink, JSONValue& outValue); /// Get the total number of generated lines - Count getGeneratedLineCount() const { return m_lineStarts.getCount() - 1; } + Count getGeneratedLineCount() const { return m_lineStarts.getCount(); } /// Get the entries on the line SLANG_FORCE_INLINE ConstArrayView<Entry> getEntriesForLine(Index generatedLine) const; @@ -53,7 +53,7 @@ struct SourceMap : public RefObject void advanceToLine(Index lineIndex); /// Add an entry to the current line - void addEntry(const Entry& entry); + void addEntry(const Entry& entry) { m_lineEntries.add(entry); } /// Given the slice returns the index Index getSourceFileIndex(const UnownedStringSlice& slice); @@ -91,18 +91,20 @@ struct SourceMap : public RefObject // ------------------------------------------------------------- SLANG_FORCE_INLINE ConstArrayView<SourceMap::Entry> SourceMap::getEntriesForLine(Index generatedLine) const { + SLANG_ASSERT(generatedLine >= 0 && generatedLine < m_lineStarts.getCount()); + const Index start = m_lineStarts[generatedLine]; - const Index end = m_lineStarts[generatedLine + 1]; - + + const Index end = (generatedLine + 1 >= m_lineStarts.getCount()) ? m_lineEntries.getCount() : m_lineStarts[generatedLine + 1]; + const auto entries = m_lineEntries.begin(); - SLANG_ASSERT(start >= 0 && start < m_lineEntries.getCount()); + SLANG_ASSERT(start >= 0 && start <= m_lineEntries.getCount()); SLANG_ASSERT(end >= start && end >= 0 && end <= m_lineEntries.getCount()); return ConstArrayView<SourceMap::Entry>(entries + start, end - start); } - } // namespace Slang #endif // SLANG_COMPILER_CORE_SOURCE_MAP_H |
