diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-02-04 17:30:51 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-04 17:30:51 -0500 |
| commit | 9b80537bc0272a9caf93f146d8964d9bdd4a407e (patch) | |
| tree | 13c2e92adca1b78b632bd8dd6cc1fecb5a12ded9 /source/slang/preprocessor.cpp | |
| parent | 0d206996cd68b9f08ae1b4d9da6f16293984302c (diff) | |
Feature/view path (#824)
* Use 'is' over 'as' where appropriate.
* dynamic_cast -> dynamicCast
* Replace 'dynamicCast' with 'as' where has no change in behavior/ambiguity.
* Replace dynamicCast with as where doesn't change behavior/non ambiguous.
* Keep a per view path to the file loaded - such that diagnostic messages always display the path to the requested file.
* Add simplifyPath to ISlangFileSystemExt
Simplify (if possible) paths that are set on SourceFile and SourcView - doing so makes reading paths simpler.
* Fix small typo.
* Improve documentation in source for getFileUniqueIdentity
* Fix override warning.
Diffstat (limited to 'source/slang/preprocessor.cpp')
| -rw-r--r-- | source/slang/preprocessor.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source/slang/preprocessor.cpp b/source/slang/preprocessor.cpp index 4ccb5d50e..91043bcf9 100644 --- a/source/slang/preprocessor.cpp +++ b/source/slang/preprocessor.cpp @@ -842,7 +842,7 @@ top: PathInfo pathInfo = PathInfo::makeTokenPaste(); SourceFile* sourceFile = sourceManager->createSourceFileWithString(pathInfo, sb.ProduceString()); - SourceView* sourceView = sourceManager->createSourceView(sourceFile); + SourceView* sourceView = sourceManager->createSourceView(sourceFile, nullptr); Lexer lexer; lexer.initialize(sourceView, GetSink(preprocessor), getNamePool(preprocessor), sourceManager->getMemoryArena()); @@ -1627,6 +1627,9 @@ static void HandleIncludeDirective(PreprocessorDirectiveContext* context) return; } + // Simplify the path + filePathInfo.foundPath = includeHandler->simplifyPath(filePathInfo.foundPath); + // Push the new file onto our stack of input streams // TODO(tfoley): check if we have made our include stack too deep auto sourceManager = context->preprocessor->getCompileRequest()->getSourceManager(); @@ -1643,12 +1646,13 @@ static void HandleIncludeDirective(PreprocessorDirectiveContext* context) return; } + sourceFile = sourceManager->createSourceFileWithBlob(filePathInfo, foundSourceBlob); sourceManager->addSourceFile(filePathInfo.uniqueIdentity, sourceFile); } // This is a new parse (even if it's a pre-existing source file), so create a new SourceUnit - SourceView* sourceView = sourceManager->createSourceView(sourceFile); + SourceView* sourceView = sourceManager->createSourceView(sourceFile, &filePathInfo); PreprocessorInputStream* inputStream = CreateInputStreamForSource(context->preprocessor, sourceView); inputStream->parent = context->preprocessor->inputStream; @@ -2259,8 +2263,8 @@ static void DefineMacro( SourceFile* keyFile = sourceManager->createSourceFileWithString(pathInfo, key); SourceFile* valueFile = sourceManager->createSourceFileWithString(pathInfo, value); - SourceView* keyView = sourceManager->createSourceView(keyFile); - SourceView* valueView = sourceManager->createSourceView(valueFile); + SourceView* keyView = sourceManager->createSourceView(keyFile, nullptr); + SourceView* valueView = sourceManager->createSourceView(valueFile, nullptr); // Use existing `Lexer` to generate a token stream. Lexer lexer; @@ -2319,7 +2323,7 @@ TokenList preprocessSource( SourceManager* sourceManager = translationUnit->compileRequest->getSourceManager(); - SourceView* sourceView = sourceManager->createSourceView(file); + SourceView* sourceView = sourceManager->createSourceView(file, nullptr); // create an initial input stream based on the provided buffer preprocessor.inputStream = CreateInputStreamForSource(&preprocessor, sourceView); |
