Ignore:
Timestamp:
Sep 27, 2017, 5:31:02 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
549c006
Parents:
12914e9 (diff), fa16264 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r12914e9 rea156ae  
    174174        }
    175175
    176         void AlternativeFinder::find( Expression *expr, bool adjust, bool prune ) {
     176        void AlternativeFinder::find( Expression *expr, bool adjust, bool prune, bool failFast ) {
    177177                expr->accept( *this );
    178                 if ( alternatives.empty() ) {
     178                if ( failFast && alternatives.empty() ) {
    179179                        throw SemanticError( "No reasonable alternatives for expression ", expr );
    180180                }
     
    191191                        AltList::iterator oldBegin = alternatives.begin();
    192192                        pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ) );
    193                         if ( alternatives.begin() == oldBegin ) {
     193                        if ( failFast && alternatives.begin() == oldBegin ) {
    194194                                std::ostringstream stream;
    195195                                AltList winners;
     
    214214        }
    215215
    216         void AlternativeFinder::findWithAdjustment( Expression *expr, bool prune ) {
    217                 find( expr, true, prune );
     216        void AlternativeFinder::findWithAdjustment( Expression *expr ) {
     217                find( expr, true );
     218        }
     219
     220        void AlternativeFinder::findWithoutPrune( Expression * expr ) {
     221                find( expr, true, false );
     222        }
     223
     224        void AlternativeFinder::maybeFind( Expression * expr ) {
     225                find( expr, true, true, false );
    218226        }
    219227
     
    714722
    715723                // find function operators
     724                static NameExpr *opExpr = new NameExpr( "?()" );
    716725                AlternativeFinder funcOpFinder( indexer, env );
    717                 NameExpr *opExpr = new NameExpr( "?()" );
    718                 try {
    719                         funcOpFinder.findWithAdjustment( opExpr );
    720                 } catch( SemanticError &e ) {
    721                         // it's ok if there aren't any defined function ops
    722                 }
     726                // it's ok if there aren't any defined function ops
     727                funcOpFinder.maybeFind( opExpr);
    723728                PRINT(
    724729                        std::cerr << "known function ops:" << std::endl;
     
    928933                AlternativeFinder finder( indexer, env );
    929934                // don't prune here, since it's guaranteed all alternatives will have the same type
    930                 // (giving the alternatives different types is half of the point of ConstructorExpr nodes)
    931                 finder.findWithAdjustment( castExpr->get_arg(), false );
     935                finder.findWithoutPrune( castExpr->get_arg() );
    932936                for ( Alternative & alt : finder.alternatives ) {
    933937                        alternatives.push_back( Alternative(
     
    12261230                // don't prune here, since it's guaranteed all alternatives will have the same type
    12271231                // (giving the alternatives different types is half of the point of ConstructorExpr nodes)
    1228                 finder.findWithAdjustment( ctorExpr->get_callExpr(), false );
     1232                finder.findWithoutPrune( ctorExpr->get_callExpr() );
    12291233                for ( Alternative & alt : finder.alternatives ) {
    12301234                        alternatives.push_back( Alternative( new ConstructorExpr( alt.expr->clone() ), alt.env, alt.cost ) );
Note: See TracChangeset for help on using the changeset viewer.