summaryrefslogtreecommitdiffstats
path: root/source/slang/source-loc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/source-loc.cpp')
-rw-r--r--source/slang/source-loc.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/source/slang/source-loc.cpp b/source/slang/source-loc.cpp
index c567dbf22..78477bb78 100644
--- a/source/slang/source-loc.cpp
+++ b/source/slang/source-loc.cpp
@@ -332,6 +332,19 @@ void SourceManager::initialize(
m_nextLoc = m_startLoc;
}
+SourceManager::~SourceManager()
+{
+ for (auto item : m_sourceViews)
+ {
+ delete item;
+ }
+
+ for (auto item : m_sourceFiles)
+ {
+ delete item;
+ }
+}
+
UnownedStringSlice SourceManager::allocateStringSlice(const UnownedStringSlice& slice)
{
const UInt numChars = slice.size();
@@ -359,22 +372,25 @@ SourceRange SourceManager::allocateSourceRange(UInt size)
return SourceRange(beginLoc, endLoc);
}
-RefPtr<SourceFile> SourceManager::createSourceFileWithSize(const PathInfo& pathInfo, size_t contentSize)
+SourceFile* SourceManager::createSourceFileWithSize(const PathInfo& pathInfo, size_t contentSize)
{
SourceFile* sourceFile = new SourceFile(pathInfo, contentSize);
+ m_sourceFiles.Add(sourceFile);
return sourceFile;
}
-RefPtr<SourceFile> SourceManager::createSourceFileWithString(const PathInfo& pathInfo, const String& contents)
+SourceFile* SourceManager::createSourceFileWithString(const PathInfo& pathInfo, const String& contents)
{
SourceFile* sourceFile = new SourceFile(pathInfo, contents.Length());
+ m_sourceFiles.Add(sourceFile);
sourceFile->setContents(contents);
return sourceFile;
}
-RefPtr<SourceFile> SourceManager::createSourceFileWithBlob(const PathInfo& pathInfo, ISlangBlob* blob)
+SourceFile* SourceManager::createSourceFileWithBlob(const PathInfo& pathInfo, ISlangBlob* blob)
{
- RefPtr<SourceFile> sourceFile(new SourceFile(pathInfo, blob->getBufferSize()));
+ SourceFile* sourceFile = new SourceFile(pathInfo, blob->getBufferSize());
+ m_sourceFiles.Add(sourceFile);
sourceFile->setContents(blob);
return sourceFile;
}
@@ -465,8 +481,8 @@ SourceView* SourceManager::findSourceViewRecursively(SourceLoc loc) const
SourceFile* SourceManager::findSourceFile(const String& canonicalPath) const
{
- RefPtr<SourceFile>* filePtr = m_sourceFiles.TryGetValue(canonicalPath);
- return (filePtr) ? filePtr->Ptr() : nullptr;
+ SourceFile*const* filePtr = m_sourceFileMap.TryGetValue(canonicalPath);
+ return (filePtr) ? *filePtr : nullptr;
}
SourceFile* SourceManager::findSourceFileRecursively(const String& canonicalPath) const
@@ -487,7 +503,7 @@ SourceFile* SourceManager::findSourceFileRecursively(const String& canonicalPath
void SourceManager::addSourceFile(const String& canonicalPath, SourceFile* sourceFile)
{
SLANG_ASSERT(!findSourceFileRecursively(canonicalPath));
- m_sourceFiles.Add(canonicalPath, sourceFile);
+ m_sourceFileMap.Add(canonicalPath, sourceFile);
}
HumaneSourceLoc SourceManager::getHumaneLoc(SourceLoc loc, SourceLocType type)