From 550405d2de2ca617046e73fe5ec7e5e1765a5c97 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 3 Jan 2018 17:15:03 -0800 Subject: Fix type lookup of global type arguments Global type argument lookup should be done in both loaded modules and current trnaslation units. This is the same as the logic of spReflection_FindTypeByName, so it is extracted into `CompileRequest::lookupGlobalDecl(Name*)` method and reused in places. --- source/slang/slang.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/slang/slang.cpp') 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 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 findOrImportModule( CompileRequest* request, Name* name, -- cgit v1.2.3