summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index e3b675cd7..eab9401b4 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -372,12 +372,12 @@ SlangResult CompileRequest::loadFile(String const& path, ISlangBlob** outBlob)
RefPtr<Expr> CompileRequest::parseTypeString(TranslationUnitRequest * translationUnit, String typeStr, RefPtr<Scope> scope)
{
- Slang::SourceFile srcFile;
- srcFile.content = UnownedStringSlice(typeStr.begin(), typeStr.end());
+ Slang::RefPtr<Slang::SourceFile> srcFile = sourceManager->newSourceFile(String("type string"), typeStr);
+
DiagnosticSink sink;
sink.sourceManager = sourceManager;
auto tokens = preprocessSource(
- &srcFile,
+ srcFile,
&sink,
nullptr,
Dictionary<String,String>(),
@@ -675,7 +675,7 @@ void CompileRequest::addTranslationUnitSourceBlob(
String const& path,
ISlangBlob* sourceBlob)
{
- RefPtr<SourceFile> sourceFile = getSourceManager()->allocateSourceFile(path, sourceBlob);
+ RefPtr<SourceFile> sourceFile = getSourceManager()->newSourceFile(path, sourceBlob);
addTranslationUnitSourceFile(translationUnitIndex, sourceFile);
}
@@ -685,7 +685,7 @@ void CompileRequest::addTranslationUnitSourceString(
String const& path,
String const& source)
{
- RefPtr<SourceFile> sourceFile = getSourceManager()->allocateSourceFile(path, source);
+ RefPtr<SourceFile> sourceFile = getSourceManager()->newSourceFile(path, source);
addTranslationUnitSourceFile(translationUnitIndex, sourceFile);
}
@@ -804,7 +804,7 @@ RefPtr<ModuleDecl> CompileRequest::loadModule(
// TODO: decide which options, if any, should be inherited.
translationUnit->compileFlags = 0;
- RefPtr<SourceFile> sourceFile = getSourceManager()->allocateSourceFile(path, sourceBlob);
+ RefPtr<SourceFile> sourceFile = getSourceManager()->newSourceFile(path, sourceBlob);
translationUnit->sourceFiles.Add(sourceFile);
@@ -883,10 +883,9 @@ RefPtr<ModuleDecl> CompileRequest::findOrImportModule(
IncludeHandlerImpl includeHandler;
includeHandler.request = this;
- auto expandedLoc = getSourceManager()->expandSourceLoc(loc);
-
- String pathIncludedFrom = expandedLoc.getSpellingPath();
-
+ // Get the original path
+ String pathIncludedFrom= getSourceManager()->getPath(loc, SourceLocType::Original);
+
String foundPath;
ComPtr<ISlangBlob> foundSourceBlob;
IncludeResult includeResult = includeHandler.TryToFindIncludeFile(fileName, pathIncludedFrom, &foundPath, foundSourceBlob.writeRef());
@@ -971,8 +970,6 @@ void Session::addBuiltinSource(
auto translationUnitIndex = compileRequest->addTranslationUnit(SourceLanguage::Slang, path);
- RefPtr<SourceFile> sourceFile = builtinSourceManager.allocateSourceFile(path, source);
-
compileRequest->addTranslationUnitSourceString(
translationUnitIndex,
path,