Changeset 5b2f5bb for src/ResolvExpr
- Timestamp:
- Mar 30, 2016, 3:48:55 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- e0323a2
- Parents:
- 4cc4286
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r4cc4286 r5b2f5bb 10 10 // Created On : Sun May 17 12:17:01 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Jan 14 16:45:32201612 // Last Modified On : Wed Mar 30 15:47:19 2016 13 13 // Update Count : 203 14 14 // … … 478 478 void Resolver::visit( ConstructorInit *ctorInit ) { 479 479 TypeEnvironment env; 480 AlternativeFinder finder( *this, env );481 480 try { 482 finder.find( ctorInit->get_ctor() ); 481 maybeAccept( ctorInit->get_ctor(), *this ); 482 maybeAccept( ctorInit->get_dtor(), *this ); 483 483 } catch ( SemanticError ) { 484 484 // no alternatives for the constructor initializer - fallback on C-style initializer … … 488 488 } 489 489 490 assert( ! finder.get_alternatives().empty() ); 491 492 if ( finder.get_alternatives().size() == 1 ) { 493 Alternative &choice = finder.get_alternatives().front(); 494 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( choice.expr ) ) { 495 if ( VariableExpr * function = dynamic_cast< VariableExpr * > ( appExpr->get_function() ) ) { 496 if ( LinkageSpec::isOverridable( function->get_var()->get_linkage() ) ) { 497 // if the constructor that was found is intrinsic or autogenerated, reset to C-style 498 // initializer so that code generation is easy to handle 499 fallbackInit( ctorInit ); 500 return; 501 } 502 } 490 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * > ( ctorInit->get_ctor() ) ) { 491 ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( exprStmt->get_expr() ); 492 assert( appExpr ); 493 VariableExpr * function = dynamic_cast< VariableExpr * > ( appExpr->get_function() ); 494 assert( function ); 495 if ( LinkageSpec::isOverridable( function->get_var()->get_linkage() ) ) { 496 // if the constructor that was found is intrinsic or autogenerated, reset to C-style 497 // initializer so that code generation is easy to handle 498 fallbackInit( ctorInit ); 499 return; 503 500 } 504 // found a constructor - can get rid of C-style initializer 505 Expression *newExpr = choice.expr->clone(); 506 finishExpr( newExpr, choice.env ); 507 ctorInit->set_ctor( newExpr ); 508 delete ctorInit->get_init(); 509 ctorInit->set_init( NULL ); 510 } else { 511 // too many constructors found 512 assert(false); 513 } 501 } 502 // found a constructor - can get rid of C-style initializer 503 delete ctorInit->get_init(); 504 ctorInit->set_init( NULL ); 514 505 } 515 506 } // namespace ResolvExpr
Note: See TracChangeset
for help on using the changeset viewer.