summaryrefslogtreecommitdiff
path: root/source/slang/source-loc.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/source-loc.h')
-rw-r--r--source/slang/source-loc.h50
1 files changed, 43 insertions, 7 deletions
diff --git a/source/slang/source-loc.h b/source/slang/source-loc.h
index 6949d659a..b6b353181 100644
--- a/source/slang/source-loc.h
+++ b/source/slang/source-loc.h
@@ -149,17 +149,47 @@ public:
/// Note that this is lazily evaluated - the line breaks are only calculated on the first request
const List<uint32_t>& getLineBreakOffsets();
+ /// Set the line break offsets
+ void setLineBreakOffsets(const uint32_t* offsets, UInt numOffsets);
+
/// Calculate the line based on the offset
int calcLineIndexFromOffset(int offset);
/// Calculate the offset for a line
int calcColumnIndex(int line, int offset);
- PathInfo pathInfo; ///< The path The logical file path to report for locations inside this span.
- ComPtr<ISlangBlob> contentBlob; ///< A blob that owns the storage for the file contents
- UnownedStringSlice content; ///< The actual contents of the file.
+ /// Get the content holding blob
+ ISlangBlob* getContentBlob() const { return m_contentBlob; }
+
+ /// True if has full set content
+ bool hasContent() const { return m_contentBlob != nullptr; }
+
+ /// Get the content size
+ size_t getContentSize() const { return m_contentSize; }
+
+ /// Get the content
+ const UnownedStringSlice& getContent() const { return m_content; }
+
+ /// Get path info
+ const PathInfo& getPathInfo() const { return m_pathInfo; }
+
+ /// Set the content as a blob
+ void setContents(ISlangBlob* blob);
+ /// Set the content as a string
+ void setContents(const String& content);
+
+ /// Ctor
+ SourceFile(const PathInfo& pathInfo, size_t contentSize);
+ /// Dtor
+ ~SourceFile();
protected:
+
+ PathInfo m_pathInfo; ///< The path The logical file path to report for locations inside this span.
+ ComPtr<ISlangBlob> m_contentBlob; ///< A blob that owns the storage for the file contents. If nullptr, there is no contents
+ UnownedStringSlice m_content; ///< The actual contents of the file.
+ size_t m_contentSize; ///< The size of the actual contents
+
// In order to speed up lookup of line number information,
// we will cache the starting offset of each line break in
// the input file:
@@ -221,13 +251,19 @@ class SourceView: public RefObject
const SourceRange& getRange() const { return m_range; }
/// Get the entries
const List<Entry>& getEntries() const { return m_entries; }
+ /// Set the entries list
+ void setEntries(const Entry* entries, UInt numEntries) { m_entries.Clear(); m_entries.AddRange(entries, numEntries); }
+
/// Get the source file holds the contents this view
SourceFile* getSourceFile() const { return m_sourceFile; }
/// Get the source manager
SourceManager* getSourceManager() const { return m_sourceManager; }
/// Get the associated 'content' (the source text)
- const UnownedStringSlice& getContent() const { return m_sourceFile->content; }
+ const UnownedStringSlice& getContent() const { return m_sourceFile->getContent(); }
+
+ /// Get the size of the content
+ size_t getContentSize() const { return m_sourceFile->getContentSize(); }
/// Get the humane location
/// Type determines if the location wanted is the original, or the 'normal' (which modifys behavior based on #line directives)
@@ -262,9 +298,9 @@ struct SourceManager
SourceRange allocateSourceRange(UInt size);
/// Create a SourceFile defined with the specified path, and content held within a blob
- SourceFile* createSourceFile(const PathInfo& pathInfo, ISlangBlob* content);
- /// Create a SourceFile with specified path. Create a Blob that contains the content.
- SourceFile* createSourceFile(const PathInfo& pathInfo, String const& content);
+ RefPtr<SourceFile> createSourceFileWithSize(const PathInfo& pathInfo, size_t contentSize);
+ RefPtr<SourceFile> createSourceFileWithString(const PathInfo& pathInfo, const String& contents);
+ RefPtr<SourceFile> createSourceFileWithBlob(const PathInfo& pathInfo, ISlangBlob* blob);
/// Get the humane source location
HumaneSourceLoc getHumaneLoc(SourceLoc loc, SourceLocType type = SourceLocType::Nominal);