diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-01-07 09:31:31 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-07 09:31:31 -0500 |
| commit | eb331446e3bee812d1df19cf59eb2d23d287ac74 (patch) | |
| tree | 34e2bc99746606cf53e775c423871496e9ee302d /source/slang/source-loc.h | |
| parent | d155eaa92d56a4ec00109d25c8c70fe12fb96c2e (diff) | |
Feature/serialization debug info (#767)
* Remove AppContext. Use StdChannels to hold writers, and TestToolUtil to hold test tool specific functionality.
* StdChannels -> StdWriters
* getStdOut -> getOut, getStdError -> getError
* Renamed main.cpp files of tools to try and stop visual studio getting confused between files - such that clicking on an error takes editor to the right location.
* Work in progress on being able to serialize debug information.
* * Added MemoryStream
* First pass converting to IRSerialData
* Able to read and write IRSerialData with debug data
* Start at reconstruting IR serialized data.
* First pass of generation debug SourceLocs from debug data. Works for test set for line nos.
* Bug fixes.
Moved testing of serialization into IRSerialUtil
* Work around problem with irModule = generateIRForTranslationUnit(translationUnit); two times in a row produces different output(!). Fix by just creating once.
* Remove problem with use of ternary op in slang.cpp on gcc/clang.
* Added -verify-debug-serial-ir option that makes IR modules go through full serialization with debug information and verification.
* Add a test that does serial debug verification that is run by default on linux.
Diffstat (limited to 'source/slang/source-loc.h')
| -rw-r--r-- | source/slang/source-loc.h | 50 |
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); |
