From 11c547d1e94fa620f527c3590174e6e25ab21883 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 31 Jan 2019 10:14:26 -0500 Subject: Feature/as refactor (#817) * Made dynamicCast a free function. * Replace As with as or dynamicCast depending on if it is a type. * Fix problem with using non smart pointer cast. * Removed legacy asXXXX methods. * Remove As from Type. * Removed As from Qual type -> made coercable into Type*, such that can just use free 'as'. * Remove left over QualType::As() impl. * Remove As from SyntaxNodeBase. * Made as for instructions implemented by dynamicCast. * Replace As on DeclRef. Use the global as<> to do the cast. * Add const safe versions of dynamicCast and as for IRInst --- source/slang/mangle.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'source/slang/mangle.cpp') diff --git a/source/slang/mangle.cpp b/source/slang/mangle.cpp index 8ad0bc9f5..b153cb8dd 100644 --- a/source/slang/mangle.cpp +++ b/source/slang/mangle.cpp @@ -213,14 +213,14 @@ namespace Slang DeclRef declRef) { auto parentDeclRef = declRef.GetParent(); - auto parentGenericDeclRef = parentDeclRef.As(); + auto parentGenericDeclRef = parentDeclRef.as(); if( parentDeclRef ) { // In certain cases we want to skip emitting the parent if(parentGenericDeclRef && (parentGenericDeclRef.getDecl()->inner.Ptr() != declRef.getDecl())) { } - else if(parentDeclRef.As()) + else if(parentDeclRef.as()) { } else @@ -232,7 +232,7 @@ namespace Slang // A generic declaration is kind of a pseudo-declaration // as far as the user is concerned; so we don't want // to emit its name. - if(auto genericDeclRef = declRef.As()) + if(auto genericDeclRef = declRef.as()) { return; } @@ -240,7 +240,7 @@ namespace Slang // Inheritance declarations don't have meaningful names, // and so we should emit them based on the type // that is doing the inheriting. - if(auto inheritanceDeclRef = declRef.As()) + if(auto inheritanceDeclRef = declRef.as()) { emit(context, "I"); emitType(context, GetSup(inheritanceDeclRef)); @@ -250,7 +250,7 @@ namespace Slang // Similarly, an extension doesn't have a name worth // emitting, and we should base things on its target // type instead. - if(auto extensionDeclRef = declRef.As()) + if(auto extensionDeclRef = declRef.as()) { // TODO: as a special case, an "unconditional" extension // that is in the same module as the type it extends should @@ -264,9 +264,9 @@ 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.as()) emitRaw(context, "Ag"); + if(declRef.as()) emitRaw(context, "As"); + if(declRef.as()) emitRaw(context, "Ar"); // Are we the "inner" declaration beneath a generic decl? if(parentGenericDeclRef && (parentGenericDeclRef.getDecl()->inner.Ptr() == declRef.getDecl())) @@ -294,15 +294,15 @@ namespace Slang UInt genericParameterCount = 0; for( auto mm : getMembers(parentGenericDeclRef) ) { - if(mm.As()) + if(mm.as()) { genericParameterCount++; } - else if(mm.As()) + else if(mm.as()) { genericParameterCount++; } - else if(mm.As()) + else if(mm.as()) { genericParameterCount++; } @@ -314,16 +314,16 @@ namespace Slang emit(context, genericParameterCount); for( auto mm : getMembers(parentGenericDeclRef) ) { - if(auto genericTypeParamDecl = mm.As()) + if(auto genericTypeParamDecl = mm.as()) { emitRaw(context, "T"); } - else if(auto genericValueParamDecl = mm.As()) + else if(auto genericValueParamDecl = mm.as()) { emitRaw(context, "v"); emitType(context, GetType(genericValueParamDecl)); } - else if(mm.As()) + else if(mm.as()) { emitRaw(context, "C"); // TODO: actually emit info about the constraint @@ -342,7 +342,7 @@ namespace Slang // We'll also go ahead and emit the result type as well, // just for completeness. // - if( auto callableDeclRef = declRef.As()) + if( auto callableDeclRef = declRef.as()) { auto parameters = GetParameters(callableDeclRef); UInt parameterCount = parameters.Count(); @@ -358,7 +358,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.as()) { emitType(context, GetResultType(callableDeclRef)); } -- cgit v1.2.3