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.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/slang/source-loc.cpp b/source/slang/source-loc.cpp
index 80556ac37..3042c3bd4 100644
--- a/source/slang/source-loc.cpp
+++ b/source/slang/source-loc.cpp
@@ -1,6 +1,8 @@
// source-loc.cpp
#include "source-loc.h"
+#include "compiler.h"
+
namespace Slang {
String ExpandedSourceLoc::getPath() const
@@ -70,15 +72,18 @@ SourceRange SourceManager::allocateSourceRange(UInt size)
SourceFile* SourceManager::allocateSourceFile(
String const& path,
- String const& content)
+ ISlangBlob* contentBlob)
{
- UInt size = content.Length();
+ char const* contentBegin = (char const*) contentBlob->getBufferPointer();
+ UInt contentSize = contentBlob->getBufferSize();
+ char const* contentEnd = contentBegin + contentSize;
- SourceRange sourceRange = allocateSourceRange(size);
+ SourceRange sourceRange = allocateSourceRange(contentSize);
SourceFile* sourceFile = new SourceFile();
sourceFile->path = path;
- sourceFile->content = content;
+ sourceFile->contentBlob = contentBlob;
+ sourceFile->content = UnownedStringSlice(contentBegin, contentEnd);
sourceFile->sourceRange = sourceRange;
Entry entry;
@@ -91,6 +96,14 @@ SourceFile* SourceManager::allocateSourceFile(
return sourceFile;
}
+SourceFile* SourceManager::allocateSourceFile(
+ String const& path,
+ String const& content)
+{
+ ComPtr<ISlangBlob> contentBlob = createStringBlob(content);
+ return allocateSourceFile(path, contentBlob);
+}
+
SourceLoc SourceManager::allocateSourceFileForLineDirective(
SourceLoc const& directiveLoc,
String const& path,