Changeset e3e16bc for src/ResolvExpr


Ignore:
Timestamp:
Sep 13, 2017, 2:34:55 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
982832e
Parents:
9f5ecf5
Message:

Renamed safe_dynamic_cast to strict_dynamic_cast

Location:
src/ResolvExpr
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r9f5ecf5 re3e16bc  
    1515
    1616#include <algorithm>               // for copy
    17 #include <cassert>                 // for safe_dynamic_cast, assert, assertf
     17#include <cassert>                 // for strict_dynamic_cast, assert, assertf
    1818#include <iostream>                // for operator<<, cerr, ostream, endl
    1919#include <iterator>                // for back_insert_iterator, back_inserter
     
    336336
    337337        Cost computeApplicationConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) {
    338                 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr );
    339                 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
    340                 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
     338                ApplicationExpr *appExpr = strict_dynamic_cast< ApplicationExpr* >( alt.expr );
     339                PointerType *pointer = strict_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     340                FunctionType *function = strict_dynamic_cast< FunctionType* >( pointer->get_base() );
    341341
    342342                Cost convCost = Cost::zero;
     
    494494                        Cost cost = Cost::zero;
    495495                        std::list< Expression * > newExprs;
    496                         ObjectDecl * obj = safe_dynamic_cast< ObjectDecl * >( formal );
     496                        ObjectDecl * obj = strict_dynamic_cast< ObjectDecl * >( formal );
    497497                        if ( ! instantiateArgument( obj->get_type(), obj->get_init(), actualExpr, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( newExprs ) ) ) {
    498498                                deleteAll( newExprs );
     
    787787
    788788                        PRINT(
    789                                 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr );
    790                                 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
    791                                 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
     789                                ApplicationExpr *appExpr = strict_dynamic_cast< ApplicationExpr* >( withFunc->expr );
     790                                PointerType *pointer = strict_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     791                                FunctionType *function = strict_dynamic_cast< FunctionType* >( pointer->get_base() );
    792792                                std::cerr << "Case +++++++++++++ " << appExpr->get_function() << std::endl;
    793793                                std::cerr << "formals are:" << std::endl;
  • src/ResolvExpr/CommonType.cc

    r9f5ecf5 re3e16bc  
    1414//
    1515
    16 #include <cassert>                       // for safe_dynamic_cast
     16#include <cassert>                       // for strict_dynamic_cast
    1717#include <map>                           // for _Rb_tree_const_iterator
    1818#include <utility>                       // for pair
     
    100100                        // special case where one type has a reference depth of 1 larger than the other
    101101                        if ( diff > 0 ) {
    102                                 return handleReference( safe_dynamic_cast<ReferenceType *>( type1 ), type2, widenFirst, widenSecond, indexer, env, openVars );
     102                                return handleReference( strict_dynamic_cast<ReferenceType *>( type1 ), type2, widenFirst, widenSecond, indexer, env, openVars );
    103103                        } else if ( diff < 0 ) {
    104                                 return handleReference( safe_dynamic_cast<ReferenceType *>( type2 ), type1, widenSecond, widenFirst, indexer, env, openVars );
     104                                return handleReference( strict_dynamic_cast<ReferenceType *>( type2 ), type1, widenSecond, widenFirst, indexer, env, openVars );
    105105                        }
    106106                        // otherwise, both are reference types of the same depth and this is handled by the CommonType visitor.
     
    114114                                if ( TypeInstType *inst = dynamic_cast< TypeInstType* >( type2 ) ) {
    115115                                        if ( NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ) ) {
    116                                                 TypeDecl *type = safe_dynamic_cast< TypeDecl* >( nt );
     116                                                TypeDecl *type = strict_dynamic_cast< TypeDecl* >( nt );
    117117                                                if ( type->get_base() ) {
    118118                                                        Type::Qualifiers tq1 = type1->get_qualifiers(), tq2 = type2->get_qualifiers();
     
    301301                        NamedTypeDecl *nt = indexer.lookupType( inst->get_name() );
    302302                        if ( nt ) {
    303                                 TypeDecl *type = safe_dynamic_cast< TypeDecl* >( nt );
     303                                TypeDecl *type = strict_dynamic_cast< TypeDecl* >( nt );
    304304                                if ( type->get_base() ) {
    305305                                        Type::Qualifiers tq1 = inst->get_qualifiers(), tq2 = type2->get_qualifiers();
  • src/ResolvExpr/ConversionCost.cc

    r9f5ecf5 re3e16bc  
    9595                if ( diff > 0 ) {
    9696                        // TODO: document this
    97                         Cost cost = convertToReferenceCost( safe_dynamic_cast< ReferenceType * >( src )->get_base(), dest, diff-1, indexer, env, func );
     97                        Cost cost = convertToReferenceCost( strict_dynamic_cast< ReferenceType * >( src )->get_base(), dest, diff-1, indexer, env, func );
    9898                        cost.incReference();
    9999                        return cost;
    100100                } else if ( diff < -1 ) {
    101101                        // TODO: document this
    102                         Cost cost = convertToReferenceCost( src, safe_dynamic_cast< ReferenceType * >( dest )->get_base(), diff+1, indexer, env, func );
     102                        Cost cost = convertToReferenceCost( src, strict_dynamic_cast< ReferenceType * >( dest )->get_base(), diff+1, indexer, env, func );
    103103                        cost.incReference();
    104104                        return cost;
  • src/ResolvExpr/CurrentObject.cc

    r9f5ecf5 re3e16bc  
    286286                                for ( InitAlternative & alt : ret ) {
    287287                                        PRINT( std::cerr << "iterating and adding designators" << std::endl; )
    288                                         alt.designation->get_designators().push_front( new VariableExpr( safe_dynamic_cast< ObjectDecl * >( *curMember ) ) );
     288                                        alt.designation->get_designators().push_front( new VariableExpr( strict_dynamic_cast< ObjectDecl * >( *curMember ) ) );
    289289                                        // need to substitute for generic types, so that casts are to concrete types
    290290                                        PRINT( std::cerr << "  type is: " << alt.type; )
     
    346346                                for ( InitAlternative & alt : ret ) {
    347347                                        PRINT( std::cerr << "iterating and adding designators" << std::endl; )
    348                                         alt.designation->get_designators().push_front( new VariableExpr( safe_dynamic_cast< ObjectDecl * >( *curMember ) ) );
     348                                        alt.designation->get_designators().push_front( new VariableExpr( strict_dynamic_cast< ObjectDecl * >( *curMember ) ) );
    349349                                }
    350350                        }
  • src/ResolvExpr/Resolver.cc

    r9f5ecf5 re3e16bc  
    1515
    1616#include <stddef.h>                      // for NULL
    17 #include <cassert>                       // for safe_dynamic_cast, assert
     17#include <cassert>                       // for strict_dynamic_cast, assert
    1818#include <memory>                        // for allocator, allocator_traits<...
    1919#include <tuple>                         // for get
     
    342342                        CastExpr * castExpr = new CastExpr( caseStmt->get_condition(), initAlts.front().type->clone() );
    343343                        Expression * newExpr = findSingleExpression( castExpr, *this );
    344                         castExpr = safe_dynamic_cast< CastExpr * >( newExpr );
     344                        castExpr = strict_dynamic_cast< CastExpr * >( newExpr );
    345345                        caseStmt->set_condition( castExpr->get_arg() );
    346346                        castExpr->set_arg( nullptr );
     
    398398                Parent::enterScope();
    399399                Visitor::visit( catchStmt );
    400                
     400
    401401                if ( catchStmt->get_cond() ) {
    402402                        Expression * wrapped = new CastExpr(
     
    423423                UntypedInitExpr * untyped = new UntypedInitExpr( singleInit->get_value(), currentObject.getOptions() );
    424424                Expression * newExpr = findSingleExpression( untyped, *this );
    425                 InitExpr * initExpr = safe_dynamic_cast< InitExpr * >( newExpr );
     425                InitExpr * initExpr = strict_dynamic_cast< InitExpr * >( newExpr );
    426426
    427427                // move cursor to the object that is actually initialized
     
    445445                                        if ( isCharType( pt->get_base() ) ) {
    446446                                                // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
    447                                                 CastExpr *ce = safe_dynamic_cast< CastExpr * >( newExpr );
     447                                                CastExpr *ce = strict_dynamic_cast< CastExpr * >( newExpr );
    448448                                                newExpr = ce->get_arg();
    449449                                                ce->set_arg( nullptr );
Note: See TracChangeset for help on using the changeset viewer.