Ignore:
Timestamp:
Jun 11, 2018, 2:50:06 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env
Children:
6d53e779, 982f95d
Parents:
8e18b8e
Message:

Move AlternativeFinder? find flags to ResolvMode? struct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r8e18b8e r1d7b0a8  
    233233        }
    234234
    235         void AlternativeFinder::find( Expression *expr, bool adjust, bool prune, bool failFast ) {
     235        void AlternativeFinder::find( Expression *expr, ResolvMode mode ) {
    236236                PassVisitor<Finder> finder( *this );
    237237                expr->accept( finder );
    238                 if ( failFast && alternatives.empty() ) {
     238                if ( mode.failFast && alternatives.empty() ) {
    239239                        PRINT(
    240240                                std::cerr << "No reasonable alternatives for expression " << expr << std::endl;
     
    242242                        SemanticError( expr, "No reasonable alternatives for expression " );
    243243                }
    244                 if ( prune ) {
     244                if ( mode.prune ) {
    245245                        auto oldsize = alternatives.size();
    246246                        PRINT(
     
    250250                        AltList pruned;
    251251                        pruneAlternatives( alternatives.begin(), alternatives.end(), back_inserter( pruned ) );
    252                         if ( failFast && pruned.empty() ) {
     252                        if ( mode.failFast && pruned.empty() ) {
    253253                                std::ostringstream stream;
    254254                                AltList winners;
     
    269269                }
    270270                // adjust types after pruning so that types substituted by pruneAlternatives are correctly adjusted
    271                 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
    272                         if ( adjust ) {
    273                                 adjustExprType( i->expr->get_result(), i->env, indexer );
     271                if ( mode.adjust ) {
     272                        for ( Alternative& i : alternatives ) {
     273                                adjustExprType( i.expr->result, i.env, indexer );
    274274                        }
    275275                }
     
    283283
    284284        void AlternativeFinder::findWithAdjustment( Expression *expr ) {
    285                 find( expr, true );
     285                find( expr, ResolvMode::withAdjustment() );
    286286        }
    287287
    288288        void AlternativeFinder::findWithoutPrune( Expression * expr ) {
    289                 find( expr, true, false );
     289                find( expr, ResolvMode::withoutPrune() );
    290290        }
    291291
    292292        void AlternativeFinder::maybeFind( Expression * expr ) {
    293                 find( expr, true, true, false );
     293                find( expr, ResolvMode::withoutFailFast() );
    294294        }
    295295
Note: See TracChangeset for help on using the changeset viewer.