From 9d515dd257498cba9144dd31f2f3219e997e03d0 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 19 Jan 2018 18:20:23 -0500 Subject: Allow arbitrary type string as type argument in spAddEntryPointEx. --- source/slang/check.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'source/slang/check.cpp') 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; - if (auto aggType = firstDeclWithName->As()) - { - type = DeclRefType::Create(entryPoint->compileRequest->mSession, DeclRef(aggType, nullptr)); - } - else if (auto typeDefDecl = firstDeclWithName->As()) - { - type = GetType(DeclRef(typeDefDecl, nullptr)); + for (auto & module : entryPoint->compileRequest->loadedModulesList) + { + RefPtr 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; -- cgit v1.2.3