summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-source-map.h
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-29 14:49:26 +0800
committerGitHub <noreply@github.com>2024-10-29 14:49:26 +0800
commitf65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch)
treeea1d61342cd29368e19135000ec2948813096205 /source/compiler-core/slang-source-map.h
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'source/compiler-core/slang-source-map.h')
-rw-r--r--source/compiler-core/slang-source-map.h94
1 files changed, 47 insertions, 47 deletions
diff --git a/source/compiler-core/slang-source-map.h b/source/compiler-core/slang-source-map.h
index 4060fadb8..73952225a 100644
--- a/source/compiler-core/slang-source-map.h
+++ b/source/compiler-core/slang-source-map.h
@@ -1,21 +1,20 @@
#ifndef SLANG_COMPILER_CORE_SOURCE_MAP_H
#define SLANG_COMPILER_CORE_SOURCE_MAP_H
-#include "slang.h"
-
-#include "../core/slang-string.h"
#include "../core/slang-list.h"
-
#include "../core/slang-string-slice-pool.h"
+#include "../core/slang-string.h"
+#include "slang.h"
-namespace Slang {
+namespace Slang
+{
-class SourceMap
+class SourceMap
{
public:
typedef SourceMap ThisType;
- SLANG_CLASS_GUID(0x731383ea, 0xe516, 0x4cc3, { 0xa6, 0xcf, 0x37, 0xd2, 0x8c, 0x24, 0x5c, 0x5e });
+ SLANG_CLASS_GUID(0x731383ea, 0xe516, 0x4cc3, {0xa6, 0xcf, 0x37, 0xd2, 0x8c, 0x24, 0x5c, 0x5e});
struct Entry
{
@@ -33,73 +32,71 @@ public:
bool operator==(const ThisType& rhs) const
{
return generatedColumn == rhs.generatedColumn &&
- sourceFileIndex == rhs.sourceFileIndex &&
- sourceLine == rhs.sourceLine &&
- sourceColumn == rhs.sourceColumn &&
- nameIndex == rhs.nameIndex;
+ sourceFileIndex == rhs.sourceFileIndex && sourceLine == rhs.sourceLine &&
+ sourceColumn == rhs.sourceColumn && nameIndex == rhs.nameIndex;
}
SLANG_FORCE_INLINE bool operator!=(const ThisType& rhs) const { return !(*this == rhs); }
// Note! All column/line are zero indexed
- Index generatedColumn; ///< The generated column
- Index sourceFileIndex; ///< The index into the source name/contents
- Index sourceLine; ///< The line number in the originating source
- Index sourceColumn; ///< The column number in the originating source
- Index nameIndex; ///< Name index
+ Index generatedColumn; ///< The generated column
+ Index sourceFileIndex; ///< The index into the source name/contents
+ Index sourceLine; ///< The line number in the originating source
+ Index sourceColumn; ///< The column number in the originating source
+ Index nameIndex; ///< Name index
};
- /// Get the total number of generated lines
+ /// Get the total number of generated lines
Count getGeneratedLineCount() const { return m_lineStarts.getCount(); }
- /// Get the entries on the line
+ /// Get the entries on the line
SLANG_FORCE_INLINE ConstArrayView<Entry> getEntriesForLine(Index generatedLine) const;
-
- /// Advance to the specified line index.
- /// It is an error to specify a line *before* the current line. It should either be the current
- /// output line or a later output line. Interveining lines will be set as empty
+
+ /// Advance to the specified line index.
+ /// It is an error to specify a line *before* the current line. It should either be the current
+ /// output line or a later output line. Interveining lines will be set as empty
void advanceToLine(Index lineIndex);
- /// Add an entry to the current line
+ /// Add an entry to the current line
void addEntry(const Entry& entry) { m_lineEntries.add(entry); }
- /// Given the slice returns the index
+ /// Given the slice returns the index
Index getSourceFileIndex(const UnownedStringSlice& slice);
- /// Get the name index
+ /// Get the name index
Index getNameIndex(const UnownedStringSlice& slice);
- /// Given a row and col index, find the closest entry
- /// NOTE! Zero indexed line and column.
+ /// Given a row and col index, find the closest entry
+ /// NOTE! Zero indexed line and column.
Index findEntry(Index lineIndex, Index colIndex) const;
- /// Given an entry index return the entry
- const Entry& getEntryByIndex(Index i) const {return m_lineEntries[i]; }
+ /// Given an entry index return the entry
+ const Entry& getEntryByIndex(Index i) const { return m_lineEntries[i]; }
- /// Given the sourceFileIndex return the name
+ /// Given the sourceFileIndex return the name
UnownedStringSlice getSourceFileName(Index sourceFileIndex) const;
- /// Clear the contents of the source map
+ /// Clear the contents of the source map
void clear();
- /// Swap this with rhs
+ /// Swap this with rhs
void swapWith(ThisType& rhs);
- /// ==
- ///
- /// Note that equality requires that entries for a line must be *in the same order*
- /// even though strictly speaking with different orders could be considered equivalent.
+ /// ==
+ ///
+ /// Note that equality requires that entries for a line must be *in the same order*
+ /// even though strictly speaking with different orders could be considered equivalent.
bool operator==(const ThisType& rhs) const;
- /// !=
+ /// !=
bool operator!=(const ThisType& rhs) const { return !(*this == rhs); }
- /// Ctor
- SourceMap():
- m_slicePool(StringSlicePool::Style::Default)
+ /// Ctor
+ SourceMap()
+ : m_slicePool(StringSlicePool::Style::Default)
{
clear();
}
- /// Copy Ctor
+ /// Copy Ctor
SourceMap(const ThisType& rhs) = default;
- /// Assignment
+ /// Assignment
ThisType& operator=(const ThisType& rhs) = default;
String m_file;
@@ -107,10 +104,10 @@ public:
List<StringSlicePool::Handle> m_sources;
- /// Storage for the contents. Can be unset null to indicate not set.
+ /// Storage for the contents. Can be unset null to indicate not set.
List<StringSlicePool::Handle> m_sourcesContent;
-
- /// The names
+
+ /// The names
List<StringSlicePool::Handle> m_names;
List<Index> m_lineStarts;
@@ -120,13 +117,16 @@ public:
};
// -------------------------------------------------------------
-SLANG_FORCE_INLINE ConstArrayView<SourceMap::Entry> SourceMap::getEntriesForLine(Index generatedLine) const
+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 = (generatedLine + 1 >= m_lineStarts.getCount()) ? m_lineEntries.getCount() : 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();