summaryrefslogtreecommitdiffstats
path: root/source/slang/syntax.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/syntax.cpp')
-rw-r--r--source/slang/syntax.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp
index 38618c7d3..6b58809a6 100644
--- a/source/slang/syntax.cpp
+++ b/source/slang/syntax.cpp
@@ -12,10 +12,8 @@ namespace Slang
bool BasicExpressionType::EqualsImpl(Type * type)
{
- auto basicType = dynamic_cast<const BasicExpressionType*>(type);
- if (basicType == nullptr)
- return false;
- return basicType->baseType == this->baseType;
+ auto basicType = dynamicCast<const BasicExpressionType>(type);
+ return basicType && basicType->baseType == this->baseType;
}
RefPtr<Type> BasicExpressionType::CreateCanonicalType()
@@ -130,7 +128,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
bool Type::EqualsVal(Val* val)
{
- if (auto type = dynamic_cast<Type*>(val))
+ if (auto type = dynamicCast<Type>(val))
return const_cast<Type*>(this)->Equals(type);
return false;
}
@@ -455,7 +453,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
SubtypeWitness* subtypeWitness,
Decl* requirementKey)
{
- if(auto declaredSubtypeWitness = dynamic_cast<DeclaredSubtypeWitness*>(subtypeWitness))
+ if(auto declaredSubtypeWitness = as<DeclaredSubtypeWitness>(subtypeWitness))
{
if(auto inheritanceDeclRef = declaredSubtypeWitness->declRef.as<InheritanceDecl>())
{
@@ -529,7 +527,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
// the case we especially care about is when this type references a declaration
// of a generic parameter, since that is what we might be substituting...
- if (auto genericTypeParamDecl = dynamic_cast<GenericTypeParamDecl*>(declRef.getDecl()))
+ if (auto genericTypeParamDecl = as<GenericTypeParamDecl>(declRef.getDecl()))
{
// search for a substitution that might apply to us
for(auto s = subst.substitutions; s; s = s->outer)
@@ -567,7 +565,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
}
}
}
- else if (auto globalGenParam = dynamic_cast<GlobalGenericParamDecl*>(declRef.getDecl()))
+ else if (auto globalGenParam = as<GlobalGenericParamDecl>(declRef.getDecl()))
{
// search for a substitution that might apply to us
for(auto s = subst.substitutions; s; s = s->outer)
@@ -1275,7 +1273,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
bool GenericParamIntVal::EqualsVal(Val* val)
{
- if (auto genericParamVal = dynamic_cast<GenericParamIntVal*>(val))
+ if (auto genericParamVal = as<GenericParamIntVal>(val))
{
return declRef.Equals(genericParamVal->declRef);
}
@@ -1365,7 +1363,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
// both must be NULL, or non-NULL
if (!this || !subst)
return !this && !subst;
- auto genericSubst = dynamic_cast<GenericSubstitution*>(subst);
+ auto genericSubst = as<GenericSubstitution>(subst);
if (!genericSubst)
return false;
if (genericDecl != genericSubst->genericDecl)
@@ -1415,7 +1413,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
if (!subst)
return false;
- if (auto thisTypeSubst = dynamic_cast<ThisTypeSubstitution*>(subst))
+ if (auto thisTypeSubst = as<ThisTypeSubstitution>(subst))
{
return witness->EqualsVal(thisTypeSubst->witness);
}
@@ -1464,7 +1462,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
{
if (!subst)
return false;
- if (auto genSubst = dynamic_cast<GlobalGenericParamSubstitution*>(subst))
+ if (auto genSubst = as<GlobalGenericParamSubstitution>(subst))
{
if (paramDecl != genSubst->paramDecl)
return false;
@@ -1900,7 +1898,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
// to the parent declaration as were applied to the child.
RefPtr<Substitutions> substToApply = substitutions.substitutions;
- if(auto interfaceDecl = dynamic_cast<InterfaceDecl*>(decl))
+ if(auto interfaceDecl = as<InterfaceDecl>(decl))
{
// The declaration being referenced is an `interface` declaration,
// and there might be a this-type substitution in place.
@@ -1916,7 +1914,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
}
}
- if (auto parentGenericDecl = dynamic_cast<GenericDecl*>(parentDecl))
+ if (auto parentGenericDecl = as<GenericDecl>(parentDecl))
{
// The parent of this declaration is a generic, which means
// that the decl-ref to the current declaration might include
@@ -2152,7 +2150,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
bool TypeEqualityWitness::EqualsVal(Val* val)
{
- auto otherWitness = dynamic_cast<TypeEqualityWitness*>(val);
+ auto otherWitness = as<TypeEqualityWitness>(val);
if (!otherWitness)
return false;
return sub->Equals(otherWitness->sub);
@@ -2178,7 +2176,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
bool DeclaredSubtypeWitness::EqualsVal(Val* val)
{
- auto otherWitness = dynamic_cast<DeclaredSubtypeWitness*>(val);
+ auto otherWitness = as<DeclaredSubtypeWitness>(val);
if(!otherWitness)
return false;
@@ -2347,7 +2345,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
bool TransitiveSubtypeWitness::EqualsVal(Val* val)
{
- auto otherWitness = dynamic_cast<TransitiveSubtypeWitness*>(val);
+ auto otherWitness = as<TransitiveSubtypeWitness>(val);
if(!otherWitness)
return false;