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/mangle.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source/slang/mangle.cpp') diff --git a/source/slang/mangle.cpp b/source/slang/mangle.cpp index b153cb8dd..1ccd32b07 100644 --- a/source/slang/mangle.cpp +++ b/source/slang/mangle.cpp @@ -264,9 +264,11 @@ namespace Slang // Special case: accessors need some way to distinguish themselves // so that a getter/setter/ref-er don't all compile to the same name. - if(declRef.as()) emitRaw(context, "Ag"); - if(declRef.as()) emitRaw(context, "As"); - if(declRef.as()) emitRaw(context, "Ar"); + { + if (declRef.is()) emitRaw(context, "Ag"); + if (declRef.is()) emitRaw(context, "As"); + if (declRef.is()) emitRaw(context, "Ar"); + } // Are we the "inner" declaration beneath a generic decl? if(parentGenericDeclRef && (parentGenericDeclRef.getDecl()->inner.Ptr() == declRef.getDecl())) @@ -294,15 +296,15 @@ namespace Slang UInt genericParameterCount = 0; for( auto mm : getMembers(parentGenericDeclRef) ) { - if(mm.as()) + if(as(mm)) { genericParameterCount++; } - else if(mm.as()) + else if(as(mm)) { genericParameterCount++; } - else if(mm.as()) + else if(as(mm)) { genericParameterCount++; } @@ -358,7 +360,7 @@ namespace Slang // Don't print result type for an initializer/constructor, // since it is implicit in the qualified name. - if (!callableDeclRef.as()) + if (!callableDeclRef.is()) { emitType(context, GetResultType(callableDeclRef)); } -- cgit v1.2.3