From 0d206996cd68b9f08ae1b4d9da6f16293984302c Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 4 Feb 2019 12:11:18 -0500 Subject: Feature/casting tidyup (#822) * Use 'is' over 'as' where appropriate. * dynamic_cast -> dynamicCast * Replace 'dynamicCast' with 'as' where has no change in behavior/ambiguity. * Replace dynamicCast with as where doesn't change behavior/non ambiguous. --- source/slang/mangle.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'source/slang/mangle.cpp') diff --git a/source/slang/mangle.cpp b/source/slang/mangle.cpp index 1ccd32b07..a61e4e666 100644 --- a/source/slang/mangle.cpp +++ b/source/slang/mangle.cpp @@ -65,7 +65,7 @@ namespace Slang ManglingContext* context, Val* val) { - if( auto constVal = dynamic_cast(val) ) + if( auto constVal = as(val) ) { auto cVal = constVal->value; if(cVal >= 0 && cVal <= 9 ) @@ -112,17 +112,17 @@ namespace Slang { // TODO: actually implement this bit... - if( auto basicType = dynamic_cast(type) ) + if( auto basicType = dynamicCast(type) ) { emitBaseType(context, basicType->baseType); } - else if( auto vecType = dynamic_cast(type) ) + else if( auto vecType = dynamicCast(type) ) { emitRaw(context, "v"); emitSimpleIntVal(context, vecType->elementCount); emitType(context, vecType->elementType); } - else if( auto matType = dynamic_cast(type) ) + else if( auto matType = dynamicCast(type) ) { emitRaw(context, "m"); emitSimpleIntVal(context, matType->getRowCount()); @@ -130,21 +130,21 @@ namespace Slang emitSimpleIntVal(context, matType->getColumnCount()); emitType(context, matType->getElementType()); } - else if( auto namedType = dynamic_cast(type) ) + else if( auto namedType = dynamicCast(type) ) { emitType(context, GetType(namedType->declRef)); } - else if( auto declRefType = dynamic_cast(type) ) + else if( auto declRefType = dynamicCast(type) ) { emitQualifiedName(context, declRefType->declRef); } - else if (auto arrType = dynamic_cast(type)) + else if (auto arrType = dynamicCast(type)) { emitRaw(context, "a"); emitSimpleIntVal(context, arrType->ArrayLength); emitType(context, arrType->baseType); } - else if( auto taggedUnionType = dynamic_cast(type) ) + else if( auto taggedUnionType = dynamicCast(type) ) { emitRaw(context, "u"); for( auto caseType : taggedUnionType->caseTypes ) @@ -163,11 +163,11 @@ namespace Slang ManglingContext* context, Val* val) { - if( auto type = dynamic_cast(val) ) + if( auto type = dynamicCast(val) ) { emitType(context, type); } - else if( auto witness = dynamic_cast(val) ) + else if( auto witness = dynamicCast(val) ) { // We don't emit witnesses as part of a mangled // name, because the way that the front-end @@ -182,7 +182,7 @@ namespace Slang // to mangle in the constraints even when // the whole thing is specialized... } - else if( auto genericParamIntVal = dynamic_cast(val) ) + else if( auto genericParamIntVal = dynamicCast(val) ) { // TODO: we shouldn't be including the names of generic parameters // anywhere in mangled names, since changing parameter names @@ -195,7 +195,7 @@ namespace Slang emitRaw(context, "K"); emitName(context, genericParamIntVal->declRef.GetName()); } - else if( auto constantIntVal = dynamic_cast(val) ) + else if( auto constantIntVal = dynamicCast(val) ) { // TODO: need to figure out what prefix/suffix is needed // to allow demangling later. @@ -296,15 +296,15 @@ namespace Slang UInt genericParameterCount = 0; for( auto mm : getMembers(parentGenericDeclRef) ) { - if(as(mm)) + if(mm.is()) { genericParameterCount++; } - else if(as(mm)) + else if(mm.is()) { genericParameterCount++; } - else if(as(mm)) + else if(mm.is()) { genericParameterCount++; } @@ -386,18 +386,18 @@ namespace Slang // // Functions will get no prefix, since we assume // they are a common case: - if(dynamic_cast(decl)) + if(as(decl)) {} // Types will get a `T` prefix: - else if(dynamic_cast(decl)) + else if(as(decl)) emitRaw(context, "T"); - else if(dynamic_cast(decl)) + else if(as(decl)) emitRaw(context, "T"); // Variables will get a `V` prefix: // // TODO: probably need to pull constant-buffer // declarations out of this... - else if(dynamic_cast(decl)) + else if(as(decl)) emitRaw(context, "V"); else { -- cgit v1.2.3