From 879ec1b385d290a4375682ec613a9e7a1967fc7d Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 10 Oct 2018 13:56:25 -0400 Subject: Feature/source loc refactor (#668) * * Remove the need for IRHighLevelDecoration in Emit * Use the IRLayoutDecoration for GeometryShaderPrimitiveTypeModifier * Initial look at at variable byte encoding, and simple unit test. * Fixing problems with comparison due to naming differences with slang/fxc. * * More tests and perf improvements for byte encoding. * Mechanism to detect processor and processor features in main slang header. * Split out cpu based defines into slang-cpu-defines.h so do not polute slang.h * Support for variable byte encoding on serialization. * Removed unused flag. * Fix warning. * Fix calcMsByte32 for 0 values without using intrinsic. * Fix a mistake in calculating maximum instruction size. * Introduced the idea of SourceUnit. * Small improvements around naming. Add more functionality - including getting the HumaneLoc. * Add support for #line default * Compiling with new SourceLoc handling. * Fix off by one on #line directives. * Can use 32bits for SourceLoc. Fix serialize to use that. * Small fixes and comment on usage. * Premake run. * Fix signed warning. * Fix typo on StringSlicePool::has found in review. --- source/slang/slang.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'source/slang/slang.cpp') 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 CompileRequest::parseTypeString(TranslationUnitRequest * translationUnit, String typeStr, RefPtr scope) { - Slang::SourceFile srcFile; - srcFile.content = UnownedStringSlice(typeStr.begin(), typeStr.end()); + Slang::RefPtr srcFile = sourceManager->newSourceFile(String("type string"), typeStr); + DiagnosticSink sink; sink.sourceManager = sourceManager; auto tokens = preprocessSource( - &srcFile, + srcFile, &sink, nullptr, Dictionary(), @@ -675,7 +675,7 @@ void CompileRequest::addTranslationUnitSourceBlob( String const& path, ISlangBlob* sourceBlob) { - RefPtr sourceFile = getSourceManager()->allocateSourceFile(path, sourceBlob); + RefPtr sourceFile = getSourceManager()->newSourceFile(path, sourceBlob); addTranslationUnitSourceFile(translationUnitIndex, sourceFile); } @@ -685,7 +685,7 @@ void CompileRequest::addTranslationUnitSourceString( String const& path, String const& source) { - RefPtr sourceFile = getSourceManager()->allocateSourceFile(path, source); + RefPtr sourceFile = getSourceManager()->newSourceFile(path, source); addTranslationUnitSourceFile(translationUnitIndex, sourceFile); } @@ -804,7 +804,7 @@ RefPtr CompileRequest::loadModule( // TODO: decide which options, if any, should be inherited. translationUnit->compileFlags = 0; - RefPtr sourceFile = getSourceManager()->allocateSourceFile(path, sourceBlob); + RefPtr sourceFile = getSourceManager()->newSourceFile(path, sourceBlob); translationUnit->sourceFiles.Add(sourceFile); @@ -883,10 +883,9 @@ RefPtr 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 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 = builtinSourceManager.allocateSourceFile(path, source); - compileRequest->addTranslationUnitSourceString( translationUnitIndex, path, -- cgit v1.2.3