summaryrefslogtreecommitdiff
path: root/source/slang/check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/check.cpp')
-rw-r--r--source/slang/check.cpp48
1 files changed, 32 insertions, 16 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index dfc09c485..52558ee15 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -6849,6 +6849,23 @@ namespace Slang
return (!decl->primaryDecl) || (decl == decl->primaryDecl);
}
+ RefPtr<Type> checkProperType(TranslationUnitRequest * tu, TypeExp typeExp)
+ {
+ RefPtr<Type> type;
+ DiagnosticSink nSink;
+ nSink.sourceManager = tu->compileRequest->sourceManager;
+ SemanticsVisitor visitor(
+ &nSink,
+ tu->compileRequest,
+ tu);
+ auto typeOut = visitor.CheckProperType(typeExp);
+ if (!nSink.errorCount)
+ {
+ type = typeOut.type;
+ }
+ return type;
+ }
+
void validateEntryPoint(
EntryPointRequest* entryPoint)
{
@@ -6944,26 +6961,25 @@ namespace Slang
entryPoint->decl = entryPointFuncDecl;
// Lookup generic parameter types in global scope
+ List<RefPtr<Scope>> scopesToTry;
+ scopesToTry.Add(entryPoint->getTranslationUnit()->SyntaxNode->scope);
+ for (auto & module : entryPoint->compileRequest->loadedModulesList)
+ scopesToTry.Add(module->moduleDecl->scope);
for (auto name : entryPoint->genericParameterTypeNames)
- {
- 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.
- sink->diagnose(translationUnitSyntax, Diagnostics::entryPointTypeParameterNotFound, name);
- return;
- }
+ {
+ // parse type name
RefPtr<Type> type;
- if (auto aggType = firstDeclWithName->As<AggTypeDecl>())
- {
- type = DeclRefType::Create(entryPoint->compileRequest->mSession, DeclRef<Decl>(aggType, nullptr));
- }
- else if (auto typeDefDecl = firstDeclWithName->As<TypeDefDecl>())
+ for (auto & s : scopesToTry)
{
- type = GetType(DeclRef<TypeDefDecl>(typeDefDecl, nullptr));
+ RefPtr<Expr> typeExpr = entryPoint->compileRequest->parseTypeString(entryPoint->getTranslationUnit(),
+ name, s);
+ type = checkProperType(translationUnit, TypeExp(typeExpr));
+ if (type)
+ {
+ break;
+ }
}
- else
+ if (!type)
{
sink->diagnose(firstDeclWithName, Diagnostics::entryPointTypeSymbolNotAType, name);
return;