Changeset 59cf83b


Ignore:
Timestamp:
Oct 5, 2018, 10:30:21 AM (3 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
6d6e829
Parents:
9ad2f9f
Message:

Switch resolution flags to packed struct

Location:
src/ResolvExpr
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r9ad2f9f r59cf83b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 23:52:08 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 17 11:19:39 2018
    13 // Update Count     : 33
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Fri Oct -5 10:01:00 2018
     13// Update Count     : 34
    1414//
    1515
     
    244244        }
    245245
    246         void AlternativeFinder::find( Expression *expr, bool adjust, bool prune, bool failFast ) {
     246        void AlternativeFinder::find( Expression *expr, ResolvMode mode ) {
    247247                PassVisitor<Finder> finder( *this );
    248248                expr->accept( finder );
    249                 if ( failFast && alternatives.empty() ) {
     249                if ( mode.failFast && alternatives.empty() ) {
    250250                        PRINT(
    251251                                std::cerr << "No reasonable alternatives for expression " << expr << std::endl;
     
    253253                        SemanticError( expr, "No reasonable alternatives for expression " );
    254254                }
    255                 if ( prune ) {
     255                if ( mode.prune ) {
    256256                        auto oldsize = alternatives.size();
    257257                        PRINT(
     
    261261                        AltList pruned;
    262262                        pruneAlternatives( alternatives.begin(), alternatives.end(), back_inserter( pruned ) );
    263                         if ( failFast && pruned.empty() ) {
     263                        if ( mode.failFast && pruned.empty() ) {
    264264                                std::ostringstream stream;
    265265                                AltList winners;
     
    280280                }
    281281                // adjust types after pruning so that types substituted by pruneAlternatives are correctly adjusted
    282                 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) {
    283                         if ( adjust ) {
    284                                 adjustExprType( i->expr->get_result(), i->env, indexer );
     282                if ( mode.adjust ) {
     283                        for ( Alternative& i : alternatives ) {
     284                                adjustExprType( i.expr->get_result(), i.env, indexer );
    285285                        }
    286286                }
     
    294294
    295295        void AlternativeFinder::findWithAdjustment( Expression *expr ) {
    296                 find( expr, true );
     296                find( expr, ResolvMode::withAdjustment() );
    297297        }
    298298
    299299        void AlternativeFinder::findWithoutPrune( Expression * expr ) {
    300                 find( expr, true, false );
     300                find( expr, ResolvMode::withoutPrune() );
    301301        }
    302302
    303303        void AlternativeFinder::maybeFind( Expression * expr ) {
    304                 find( expr, true, true, false );
     304                find( expr, ResolvMode::withoutFailFast() );
    305305        }
    306306
  • src/ResolvExpr/AlternativeFinder.h

    r9ad2f9f r59cf83b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 23:56:12 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 26 11:24:00 2017
    13 // Update Count     : 4
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Fri Oct -5 10:01:00 2018
     13// Update Count     : 5
    1414//
    1515
     
    2424#include "ResolvExpr/Cost.h"             // for Cost, Cost::infinity
    2525#include "ResolvExpr/TypeEnvironment.h"  // for AssertionSet, OpenVarSet
     26#include "ResolvMode.h"                  // for ResolvMode
    2627#include "SynTree/Visitor.h"             // for Visitor
    2728#include "SynTree/SynTree.h"             // for Visitor Nodes
     
    6869                }
    6970
    70                 void find( Expression *expr, bool adjust = false, bool prune = true, bool failFast = true );
     71                void find( Expression *expr, ResolvMode mode = ResolvMode{} );
    7172                /// Calls find with the adjust flag set; adjustment turns array and function types into equivalent pointer types
    7273                void findWithAdjustment( Expression *expr );
  • src/ResolvExpr/Resolver.cc

    r9ad2f9f r59cf83b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:17:01 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 17 11:19:40 2018
    13 // Update Count     : 213
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Fri Oct 05 09:43:00 2018
     13// Update Count     : 214
    1414//
    1515
     
    3131#include "ResolvExpr/TypeEnvironment.h"  // for TypeEnvironment
    3232#include "Resolver.h"
     33#include "ResolvMode.h"                  // for ResolvMode
    3334#include "SymTab/Autogen.h"              // for SizeType
    3435#include "SymTab/Indexer.h"              // for Indexer
     
    168169
    169170        namespace {
    170                 void findUnfinishedKindExpression(Expression * untyped, Alternative & alt, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, bool adjust = false, bool prune = true, bool failFast = true) {
     171                void findUnfinishedKindExpression(Expression * untyped, Alternative & alt, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, ResolvMode mode = ResolvMode{} ) {
    171172                        assertf( untyped, "expected a non-null expression." );
    172173                        TypeEnvironment env;
    173174                        AlternativeFinder finder( indexer, env );
    174                         finder.find( untyped, adjust, prune, failFast );
     175                        finder.find( untyped, mode );
    175176
    176177                        #if 0
     
    216217
    217218                /// resolve `untyped` to the expression whose alternative satisfies `pred` with the lowest cost; kindStr is used for providing better error messages
    218                 void findKindExpression(Expression *& untyped, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, bool adjust = false, bool prune = true, bool failFast = true) {
     219                void findKindExpression(Expression *& untyped, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, ResolvMode mode = ResolvMode{}) {
    219220                        if ( ! untyped ) return;
    220221                        Alternative choice;
    221                         findUnfinishedKindExpression( untyped, choice, indexer, kindStr, pred, adjust, prune, failFast );
     222                        findUnfinishedKindExpression( untyped, choice, indexer, kindStr, pred, mode );
    222223                        finishExpr( choice.expr, choice.env, untyped->env );
    223224                        delete untyped;
     
    250251                untyped.arg = expr;
    251252                Alternative choice;
    252                 findUnfinishedKindExpression( &untyped, choice, indexer, "", standardAlternativeFilter, true );
     253                findUnfinishedKindExpression( &untyped, choice, indexer, "", standardAlternativeFilter, ResolvMode::withAdjustment() );
    253254                CastExpr * castExpr = strict_dynamic_cast< CastExpr * >( choice.expr );
    254255                env = std::move( choice.env );
Note: See TracChangeset for help on using the changeset viewer.