diff options
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/check.cpp | 3 | ||||
| -rw-r--r-- | source/slang/compiler.h | 2 | ||||
| -rw-r--r-- | source/slang/reflection.cpp | 12 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 16 |
4 files changed, 21 insertions, 12 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index dc5efbd73..46ed9da15 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -6777,7 +6777,8 @@ namespace Slang // Lookup generic parameter types in global scope for (auto name : entryPoint->genericParameterTypeNames) { - if (!translationUnitSyntax->memberDictionary.TryGetValue(name, firstDeclWithName)) + firstDeclWithName = entryPoint->compileRequest->lookupGlobalDecl(name); + if (!firstDeclWithName) { // If there doesn't appear to be any such declaration, then // we need to diagnose it as an error, and then bail out. diff --git a/source/slang/compiler.h b/source/slang/compiler.h index 2302c77c0..1fca4751c 100644 --- a/source/slang/compiler.h +++ b/source/slang/compiler.h @@ -373,6 +373,8 @@ namespace Slang Name* name, SourceLoc const& loc); + Decl* lookupGlobalDecl(Name* name); + SourceManager* getSourceManager() { return sourceManager; diff --git a/source/slang/reflection.cpp b/source/slang/reflection.cpp index 59b50891c..c9de75d6e 100644 --- a/source/slang/reflection.cpp +++ b/source/slang/reflection.cpp @@ -437,18 +437,8 @@ SLANG_API SlangReflectionType * spReflection_FindTypeByName(SlangReflection * re if (compileRequest->types.TryGetValue(name, result)) return (SlangReflectionType*)result.Ptr(); - Decl* resultDecl = nullptr; auto nameObj = compileRequest->getNamePool()->getName(name); - for (auto module : compileRequest->loadedModulesList) - { - if (module->moduleDecl->memberDictionary.TryGetValue(nameObj, resultDecl)) - break; - } - for (auto transUnit : compileRequest->translationUnits) - { - if (transUnit->SyntaxNode->memberDictionary.TryGetValue(nameObj, resultDecl)) - break; - } + Decl* resultDecl = compileRequest->lookupGlobalDecl(nameObj); if (resultDecl) { RefPtr<DeclRefType> declRefType = new DeclRefType(); diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 3156e5008..0b3e0ceb7 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -590,6 +590,22 @@ RefPtr<ModuleDecl> CompileRequest::findOrImportModule( loc); } +Decl * CompileRequest::lookupGlobalDecl(Name * name) +{ + Decl* resultDecl = nullptr; + for (auto module : loadedModulesList) + { + if (module->moduleDecl->memberDictionary.TryGetValue(name, resultDecl)) + break; + } + for (auto transUnit : translationUnits) + { + if (transUnit->SyntaxNode->memberDictionary.TryGetValue(name, resultDecl)) + break; + } + return resultDecl; +} + RefPtr<ModuleDecl> findOrImportModule( CompileRequest* request, Name* name, |
