diff options
| author | Yong He <yonghe@outlook.com> | 2023-12-05 10:06:19 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-05 10:06:19 -0800 |
| commit | 1050e0eb96d6c8e7a6cfb253458155e1014625c3 (patch) | |
| tree | ce6c3cbde591759fa2fe2aeb05cb132e50a9a419 /source/compiler-core/slang-include-system.cpp | |
| parent | 4fb3b10b81cf8c976ebd1ebb7fcde7708f022957 (diff) | |
Support `include` for pulling file into the current module. (#3377)
* Support `include` for pulling file into the current module.
* Add auto-completion, hover info and goto-def support.
* Disable warning for missing `module` declaration for now.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/compiler-core/slang-include-system.cpp')
| -rw-r--r-- | source/compiler-core/slang-include-system.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source/compiler-core/slang-include-system.cpp b/source/compiler-core/slang-include-system.cpp index f0a850a81..1b768d506 100644 --- a/source/compiler-core/slang-include-system.cpp +++ b/source/compiler-core/slang-include-system.cpp @@ -113,15 +113,15 @@ SlangResult IncludeSystem::findFile(String const& pathToInclude, String const& p return SLANG_E_NOT_FOUND; } -SlangResult IncludeSystem::loadFile(const PathInfo& pathInfo, ComPtr<ISlangBlob>& outBlob) +SlangResult IncludeSystem::loadFile(const PathInfo& pathInfo, ComPtr<ISlangBlob>& outBlob, SourceFile*& outSourceFile) { if (m_sourceManager) { // See if this an already loaded source file - SourceFile* sourceFile = m_sourceManager->findSourceFileRecursively(pathInfo.uniqueIdentity); + outSourceFile = m_sourceManager->findSourceFileRecursively(pathInfo.uniqueIdentity); // If not create a new one, and add to the list of known source files - if (!sourceFile) + if (!outSourceFile) { ComPtr<ISlangBlob> foundSourceBlob; if (SLANG_FAILED(m_fileSystemExt->loadFile(pathInfo.foundPath.getBuffer(), foundSourceBlob.writeRef()))) @@ -129,17 +129,17 @@ SlangResult IncludeSystem::loadFile(const PathInfo& pathInfo, ComPtr<ISlangBlob> return SLANG_E_CANNOT_OPEN; } - sourceFile = m_sourceManager->createSourceFileWithBlob(pathInfo, foundSourceBlob); - m_sourceManager->addSourceFile(pathInfo.uniqueIdentity, sourceFile); + outSourceFile = m_sourceManager->createSourceFileWithBlob(pathInfo, foundSourceBlob); + m_sourceManager->addSourceFile(pathInfo.uniqueIdentity, outSourceFile); outBlob = foundSourceBlob; return SLANG_OK; } else { - if (sourceFile->getContentBlob()) + if (outSourceFile->getContentBlob()) { - outBlob = sourceFile->getContentBlob(); + outBlob = outSourceFile->getContentBlob(); return SLANG_OK; } @@ -149,7 +149,7 @@ SlangResult IncludeSystem::loadFile(const PathInfo& pathInfo, ComPtr<ISlangBlob> return SLANG_E_CANNOT_OPEN; } - sourceFile->setContents(foundSourceBlob); + outSourceFile->setContents(foundSourceBlob); outBlob = foundSourceBlob; return SLANG_OK; @@ -158,6 +158,7 @@ SlangResult IncludeSystem::loadFile(const PathInfo& pathInfo, ComPtr<ISlangBlob> else { // If we don't have the source manager, just load + outSourceFile = nullptr; return m_fileSystemExt->loadFile(pathInfo.foundPath.getBuffer(), outBlob.writeRef()); } } |
