Changeset e3e16bc for src/ResolvExpr
- Timestamp:
- Sep 13, 2017, 2:34:55 PM (8 years ago)
- 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
- Location:
- src/ResolvExpr
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r9f5ecf5 re3e16bc 15 15 16 16 #include <algorithm> // for copy 17 #include <cassert> // for s afe_dynamic_cast, assert, assertf17 #include <cassert> // for strict_dynamic_cast, assert, assertf 18 18 #include <iostream> // for operator<<, cerr, ostream, endl 19 19 #include <iterator> // for back_insert_iterator, back_inserter … … 336 336 337 337 Cost computeApplicationConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) { 338 ApplicationExpr *appExpr = s afe_dynamic_cast< ApplicationExpr* >( alt.expr );339 PointerType *pointer = s afe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );340 FunctionType *function = s afe_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() ); 341 341 342 342 Cost convCost = Cost::zero; … … 494 494 Cost cost = Cost::zero; 495 495 std::list< Expression * > newExprs; 496 ObjectDecl * obj = s afe_dynamic_cast< ObjectDecl * >( formal );496 ObjectDecl * obj = strict_dynamic_cast< ObjectDecl * >( formal ); 497 497 if ( ! instantiateArgument( obj->get_type(), obj->get_init(), actualExpr, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( newExprs ) ) ) { 498 498 deleteAll( newExprs ); … … 787 787 788 788 PRINT( 789 ApplicationExpr *appExpr = s afe_dynamic_cast< ApplicationExpr* >( withFunc->expr );790 PointerType *pointer = s afe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );791 FunctionType *function = s afe_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() ); 792 792 std::cerr << "Case +++++++++++++ " << appExpr->get_function() << std::endl; 793 793 std::cerr << "formals are:" << std::endl; -
src/ResolvExpr/CommonType.cc
r9f5ecf5 re3e16bc 14 14 // 15 15 16 #include <cassert> // for s afe_dynamic_cast16 #include <cassert> // for strict_dynamic_cast 17 17 #include <map> // for _Rb_tree_const_iterator 18 18 #include <utility> // for pair … … 100 100 // special case where one type has a reference depth of 1 larger than the other 101 101 if ( diff > 0 ) { 102 return handleReference( s afe_dynamic_cast<ReferenceType *>( type1 ), type2, widenFirst, widenSecond, indexer, env, openVars );102 return handleReference( strict_dynamic_cast<ReferenceType *>( type1 ), type2, widenFirst, widenSecond, indexer, env, openVars ); 103 103 } else if ( diff < 0 ) { 104 return handleReference( s afe_dynamic_cast<ReferenceType *>( type2 ), type1, widenSecond, widenFirst, indexer, env, openVars );104 return handleReference( strict_dynamic_cast<ReferenceType *>( type2 ), type1, widenSecond, widenFirst, indexer, env, openVars ); 105 105 } 106 106 // otherwise, both are reference types of the same depth and this is handled by the CommonType visitor. … … 114 114 if ( TypeInstType *inst = dynamic_cast< TypeInstType* >( type2 ) ) { 115 115 if ( NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ) ) { 116 TypeDecl *type = s afe_dynamic_cast< TypeDecl* >( nt );116 TypeDecl *type = strict_dynamic_cast< TypeDecl* >( nt ); 117 117 if ( type->get_base() ) { 118 118 Type::Qualifiers tq1 = type1->get_qualifiers(), tq2 = type2->get_qualifiers(); … … 301 301 NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ); 302 302 if ( nt ) { 303 TypeDecl *type = s afe_dynamic_cast< TypeDecl* >( nt );303 TypeDecl *type = strict_dynamic_cast< TypeDecl* >( nt ); 304 304 if ( type->get_base() ) { 305 305 Type::Qualifiers tq1 = inst->get_qualifiers(), tq2 = type2->get_qualifiers(); -
src/ResolvExpr/ConversionCost.cc
r9f5ecf5 re3e16bc 95 95 if ( diff > 0 ) { 96 96 // TODO: document this 97 Cost cost = convertToReferenceCost( s afe_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 ); 98 98 cost.incReference(); 99 99 return cost; 100 100 } else if ( diff < -1 ) { 101 101 // TODO: document this 102 Cost cost = convertToReferenceCost( src, s afe_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 ); 103 103 cost.incReference(); 104 104 return cost; -
src/ResolvExpr/CurrentObject.cc
r9f5ecf5 re3e16bc 286 286 for ( InitAlternative & alt : ret ) { 287 287 PRINT( std::cerr << "iterating and adding designators" << std::endl; ) 288 alt.designation->get_designators().push_front( new VariableExpr( s afe_dynamic_cast< ObjectDecl * >( *curMember ) ) );288 alt.designation->get_designators().push_front( new VariableExpr( strict_dynamic_cast< ObjectDecl * >( *curMember ) ) ); 289 289 // need to substitute for generic types, so that casts are to concrete types 290 290 PRINT( std::cerr << " type is: " << alt.type; ) … … 346 346 for ( InitAlternative & alt : ret ) { 347 347 PRINT( std::cerr << "iterating and adding designators" << std::endl; ) 348 alt.designation->get_designators().push_front( new VariableExpr( s afe_dynamic_cast< ObjectDecl * >( *curMember ) ) );348 alt.designation->get_designators().push_front( new VariableExpr( strict_dynamic_cast< ObjectDecl * >( *curMember ) ) ); 349 349 } 350 350 } -
src/ResolvExpr/Resolver.cc
r9f5ecf5 re3e16bc 15 15 16 16 #include <stddef.h> // for NULL 17 #include <cassert> // for s afe_dynamic_cast, assert17 #include <cassert> // for strict_dynamic_cast, assert 18 18 #include <memory> // for allocator, allocator_traits<... 19 19 #include <tuple> // for get … … 342 342 CastExpr * castExpr = new CastExpr( caseStmt->get_condition(), initAlts.front().type->clone() ); 343 343 Expression * newExpr = findSingleExpression( castExpr, *this ); 344 castExpr = s afe_dynamic_cast< CastExpr * >( newExpr );344 castExpr = strict_dynamic_cast< CastExpr * >( newExpr ); 345 345 caseStmt->set_condition( castExpr->get_arg() ); 346 346 castExpr->set_arg( nullptr ); … … 398 398 Parent::enterScope(); 399 399 Visitor::visit( catchStmt ); 400 400 401 401 if ( catchStmt->get_cond() ) { 402 402 Expression * wrapped = new CastExpr( … … 423 423 UntypedInitExpr * untyped = new UntypedInitExpr( singleInit->get_value(), currentObject.getOptions() ); 424 424 Expression * newExpr = findSingleExpression( untyped, *this ); 425 InitExpr * initExpr = s afe_dynamic_cast< InitExpr * >( newExpr );425 InitExpr * initExpr = strict_dynamic_cast< InitExpr * >( newExpr ); 426 426 427 427 // move cursor to the object that is actually initialized … … 445 445 if ( isCharType( pt->get_base() ) ) { 446 446 // strip cast if we're initializing a char[] with a char *, e.g. char x[] = "hello"; 447 CastExpr *ce = s afe_dynamic_cast< CastExpr * >( newExpr );447 CastExpr *ce = strict_dynamic_cast< CastExpr * >( newExpr ); 448 448 newExpr = ce->get_arg(); 449 449 ce->set_arg( nullptr );
Note: See TracChangeset
for help on using the changeset viewer.