diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-02-04 12:11:18 -0500 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2019-02-04 09:11:18 -0800 |
| commit | 0d206996cd68b9f08ae1b4d9da6f16293984302c (patch) | |
| tree | 023fe84547955b1356a770f407433f45e1fb8048 /source/slang/parser.cpp | |
| parent | 3726194fbe3da234eb30b6371e5b4ab1ea388f93 (diff) | |
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.
Diffstat (limited to 'source/slang/parser.cpp')
| -rw-r--r-- | source/slang/parser.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp index 0c6419ae3..076111711 100644 --- a/source/slang/parser.cpp +++ b/source/slang/parser.cpp @@ -795,7 +795,7 @@ namespace Slang return nullptr; auto decl = lookupResult.item.declRef.getDecl(); - if( auto syntaxDecl = dynamic_cast<SyntaxDecl*>(decl) ) + if( auto syntaxDecl = as<SyntaxDecl>(decl) ) { return syntaxDecl; } @@ -1323,7 +1323,7 @@ namespace Slang static RefPtr<VarDeclBase> CreateVarDeclForContext( ContainerDecl* containerDecl ) { - if (dynamic_cast<CallableDecl*>(containerDecl)) + if (as<CallableDecl>(containerDecl)) { // Function parameters always use their dedicated syntax class. // @@ -1685,15 +1685,7 @@ namespace Slang if (!lookupResult.isValid() || lookupResult.isOverloaded()) return false; - auto decl = lookupResult.item.declRef.getDecl(); - if (auto genericDecl = dynamic_cast<GenericDecl*>(decl)) - { - return true; - } - else - { - return false; - } + return lookupResult.item.declRef.is<GenericDecl>(); } static RefPtr<Expr> tryParseGenericApp( @@ -3321,11 +3313,11 @@ namespace Slang return false; auto decl = lookupResult.item.declRef.getDecl(); - if( auto typeDecl = dynamic_cast<AggTypeDecl*>(decl) ) + if( auto typeDecl = as<AggTypeDecl>(decl) ) { return true; } - else if( auto typeVarDecl = dynamic_cast<SimpleTypeDecl*>(decl) ) + else if( auto typeVarDecl = as<SimpleTypeDecl>(decl) ) { return true; } |
