summaryrefslogtreecommitdiffstats
path: root/source/slang/check.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-01-19 18:20:23 -0500
committerYong He <yonghe@outlook.com>2018-01-19 22:21:29 -0500
commit9d515dd257498cba9144dd31f2f3219e997e03d0 (patch)
tree131571608747f80354236ba62ca946c7fc703db7 /source/slang/check.cpp
parent2079b941bc5849b6ab33774fb90cefe9c2d624cb (diff)
Allow arbitrary type string as type argument in spAddEntryPointEx.
Diffstat (limited to 'source/slang/check.cpp')
-rw-r--r--source/slang/check.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index dfc09c485..7cfb317fb 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -6945,25 +6945,26 @@ namespace Slang
// Lookup generic parameter types in global 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>())
- {
- type = GetType(DeclRef<TypeDefDecl>(typeDefDecl, nullptr));
+ for (auto & module : entryPoint->compileRequest->loadedModulesList)
+ {
+ RefPtr<Expr> typeExpr = entryPoint->compileRequest->parseTypeString(entryPoint->getTranslationUnit(),
+ name, module->moduleDecl->scope);
+ DiagnosticSink nSink;
+ SemanticsVisitor visitor(
+ &nSink,
+ translationUnit->compileRequest,
+ translationUnit);
+ auto typeOut = visitor.CheckProperType(TypeExp(typeExpr));
+ if (!nSink.errorCount)
+ {
+ type = typeOut.type;
+ break;
+ }
}
- else
+ if (!type)
{
sink->diagnose(firstDeclWithName, Diagnostics::entryPointTypeSymbolNotAType, name);
return;