From ce879112cb16e3def1b8673104e7123b8b17ee2a Mon Sep 17 00:00:00 2001 From: Yong He Date: Sun, 21 Jan 2018 07:09:55 -0500 Subject: Improvements and bug fixes for global type parameters 1. allow spReflection_FindTypeByName to accept arbitrary type expression string 2. allow const int generic value to be used as expression value, and as array size 3. various bug fixes in witness table specialization / function cloning during specializeIRForEntryPoint to avoid creating duplicate global values, not copying the right definition of a function from the other module, not cloning witness tables that are required by specializeGenerics etc. --- source/slang/check.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'source/slang/check.cpp') diff --git a/source/slang/check.cpp b/source/slang/check.cpp index c4aa9bfba..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 checkProperType(TranslationUnitRequest * tu, TypeExp typeExp) + { + RefPtr 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) { @@ -6956,15 +6973,9 @@ namespace Slang { RefPtr typeExpr = entryPoint->compileRequest->parseTypeString(entryPoint->getTranslationUnit(), name, s); - DiagnosticSink nSink; - SemanticsVisitor visitor( - &nSink, - translationUnit->compileRequest, - translationUnit); - auto typeOut = visitor.CheckProperType(TypeExp(typeExpr)); - if (!nSink.errorCount) - { - type = typeOut.type; + type = checkProperType(translationUnit, TypeExp(typeExpr)); + if (type) + { break; } } -- cgit v1.2.3