From 3726194fbe3da234eb30b6371e5b4ab1ea388f93 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Sat, 2 Feb 2019 11:58:54 -0500 Subject: Feature/as refactor review (#821) * Replace dynamicCast with as where does not change behavior (ie not Type derived). Use free function where scoping is clear. * Replace uses of dynamicCast with as when there is no difference in behavior. * Remove the IsXXXX methods from Type. * Don't have separate smart pointer to store canonicalType on Type. * Simplify Slang.FilteredMemberRefList.Adjust, such does the cast directly. * Use free as where appropriate. * Use free function version of casts where appropriate. * Fix text in casting.md * Fix typos in decl-refs.md * Remove the uses of free function as on RefDecl. Add 'canAs' to RefDecl as a way to test if a cast is possible. Moved 'as' into RefDeclBase. * Use 'is' to test for as cast on smart pointers. Fix small scope issue. * * Cache stringType and enumTypeType on the Session * Make DeclRefType::Create return a RefPtr * Make casting of result use the *method* .as (cos using free function would mean objects being wrongly destroyed) * Make results from createInstance ref'd to avoid possible leaks. * Fix typo in template parameter for is on RefPtr. --- source/slang/parameter-binding.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source/slang/parameter-binding.cpp') diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index 904ec3129..e722ccbb9 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -785,12 +785,12 @@ static bool validateSpecializationsMatch( for(;;) { // Skip any global generic substitutions. - if(auto leftGlobalGeneric = ll.as()) + if(auto leftGlobalGeneric = as(ll)) { ll = leftGlobalGeneric->outer; continue; } - if(auto rightGlobalGeneric = rr.as()) + if(auto rightGlobalGeneric = as(rr)) { rr = rightGlobalGeneric->outer; continue; @@ -806,7 +806,7 @@ static bool validateSpecializationsMatch( ll = ll->outer; rr = rr->outer; - if(auto leftGeneric = leftSubst.as()) + if(auto leftGeneric = as(leftSubst)) { if(auto rightGeneric = as(rightSubst)) { @@ -816,9 +816,9 @@ static bool validateSpecializationsMatch( } } } - else if(auto leftThisType = leftSubst.as()) + else if(auto leftThisType = as(leftSubst)) { - if(auto rightThisType = rightSubst.as()) + if(auto rightThisType = as(rightSubst)) { if(validateThisTypeSubstitutionsMatch(context, leftThisType, rightThisType, stack)) { @@ -2494,7 +2494,7 @@ static void collectEntryPointParameters( // for( auto taggedUnionType : entryPoint->taggedUnionTypes ) { - auto substType = taggedUnionType->Substitute(typeSubst).dynamicCast(); + auto substType = taggedUnionType->Substitute(typeSubst).as(); auto typeLayout = CreateTypeLayout(context->layoutContext, substType); entryPointLayout->taggedUnionTypeLayouts.Add(typeLayout); } @@ -2610,7 +2610,7 @@ static void collectEntryPointParameters( auto resultTypeLayout = processEntryPointVaryingParameterDecl( context, entryPointFuncDecl, - resultType->Substitute(typeSubst).dynamicCast(), + resultType->Substitute(typeSubst).as(), state, resultLayout); -- cgit v1.2.3