summaryrefslogtreecommitdiff
path: root/source/slang/source-loc.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-01-10 16:01:05 -0500
committerGitHub <noreply@github.com>2019-01-10 16:01:05 -0500
commitdbf5f413cd7a7b0448312a6f198b2a544087ac58 (patch)
treef9dce7776ed118f5b97e2446dccbb2631edec3d8 /source/slang/source-loc.h
parenteb331446e3bee812d1df19cf59eb2d23d287ac74 (diff)
Improvements around review of debug serialization info (#769)
* * Make SourceView and SourceFile no longer derive from RefObject * Both have life time now managed by SourceManager * Tidied up a little around the serialization test code - just create the IRModule once * Simplified code around deleting SourceView/File. * Looked into generateIRForTranslationUnit - seems reasonable to just call it once, because it has side effects.
Diffstat (limited to 'source/slang/source-loc.h')
-rw-r--r--source/slang/source-loc.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/source/slang/source-loc.h b/source/slang/source-loc.h
index b6b353181..ee4049473 100644
--- a/source/slang/source-loc.h
+++ b/source/slang/source-loc.h
@@ -141,7 +141,7 @@ struct SourceRange
// A logical or physical storage object for a range of input code
// that has logically contiguous source locations.
-class SourceFile : public RefObject
+class SourceFile
{
public:
@@ -217,7 +217,7 @@ struct SourceManager;
It is distinct from a SourceFile - because a SourceFile may be included multiple times, with different interpretations (depending
on #defines for example).
*/
-class SourceView: public RefObject
+class SourceView
{
public:
@@ -285,7 +285,7 @@ class SourceView: public RefObject
SourceManager* m_sourceManager; /// Get the manager this belongs to
SourceRange m_range; ///< The range that this SourceView applies to
- RefPtr<SourceFile> m_sourceFile; ///< The source file can hold the line breaks
+ SourceFile* m_sourceFile; ///< The source file. Can hold the line breaks
List<Entry> m_entries; ///< An array entries describing how we should interpret a range, starting from the start location.
};
@@ -298,9 +298,9 @@ struct SourceManager
SourceRange allocateSourceRange(UInt size);
/// Create a SourceFile defined with the specified path, and content held within a blob
- 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);
+ SourceFile* createSourceFileWithSize(const PathInfo& pathInfo, size_t contentSize);
+ SourceFile* createSourceFileWithString(const PathInfo& pathInfo, const String& contents);
+ SourceFile* createSourceFileWithBlob(const PathInfo& pathInfo, ISlangBlob* blob);
/// Get the humane source location
HumaneSourceLoc getHumaneLoc(SourceLoc loc, SourceLocType type = SourceLocType::Nominal);
@@ -348,6 +348,7 @@ struct SourceManager
SourceManager() :
m_memoryArena(2048)
{}
+ ~SourceManager();
protected:
@@ -362,16 +363,19 @@ struct SourceManager
// The location to be used by the next source file to be loaded
SourceLoc m_nextLoc;
- // All of the SourceViews. These are held in increasing order of range, so can find by doing a binary chop.
- List<RefPtr<SourceView> > m_sourceViews;
+ // All of the SourceViews constructed on this SourceManager. These are held in increasing order of range, so can find by doing a binary chop.
+ List<SourceView*> m_sourceViews;
+ // All of the SourceFiles constructed on this SourceManager. This owns the SourceFile.
+ List<SourceFile*> m_sourceFiles;
+
StringSlicePool m_slicePool;
// Memory arena that can be used for holding data to held in scope as long as the Source is
- // Can be used for storing the decoded contents of Token.Content for exampel
+ // Can be used for storing the decoded contents of Token. Content for example.
MemoryArena m_memoryArena;
// Maps canonical paths to source files
- Dictionary<String, RefPtr<SourceFile> > m_sourceFiles;
+ Dictionary<String, SourceFile*> m_sourceFileMap;
};
} // namespace Slang