Ignore:
Timestamp:
Jan 14, 2019, 3:38:28 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
fd73248
Parents:
07ec1a2 (diff), 52ffa30 (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/Tuples/TupleAssignment.cc

    r07ec1a2 r276a55b2  
    6262                struct Matcher {
    6363                  public:
    64                         Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList& lhs, const
    65                                 ResolvExpr::AltList& rhs );
     64                        Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList& lhs,
     65                                const ResolvExpr::AltList& rhs );
    6666                        virtual ~Matcher() {}
     67                       
    6768                        virtual void match( std::list< Expression * > &out ) = 0;
    6869                        ObjectDecl * newObject( UniqueName & namer, Expression * expr );
     70
     71                        void combineState( const ResolvExpr::Alternative& alt ) {
     72                                compositeEnv.simpleCombine( alt.env );
     73                                ResolvExpr::mergeOpenVars( openVars, alt.openVars );
     74                                cloneAll( alt.need, need );
     75                        }
     76
     77                        void combineState( const ResolvExpr::AltList& alts ) {
     78                                for ( const ResolvExpr::Alternative& alt : alts ) { combineState( alt ); }
     79                        }
     80                       
    6981                        ResolvExpr::AltList lhs, rhs;
    7082                        TupleAssignSpotter &spotter;
     
    7284                        std::list< ObjectDecl * > tmpDecls;
    7385                        ResolvExpr::TypeEnvironment compositeEnv;
     86                        ResolvExpr::OpenVarSet openVars;
     87                        ResolvExpr::AssertionSet need;
    7488                };
    7589
     
    245259                }
    246260
    247                 // extract expressions from the assignment alternatives to produce a list of assignments that
    248                 // together form a single alternative
     261                // extract expressions from the assignment alternatives to produce a list of assignments
     262                // that together form a single alternative
    249263                std::list< Expression *> solved_assigns;
    250264                for ( ResolvExpr::Alternative & alt : current ) {
    251265                        solved_assigns.push_back( alt.expr->clone() );
    252                 }
    253                 // combine assignment environments into combined expression environment
    254                 simpleCombineEnvironments( current.begin(), current.end(), matcher->compositeEnv );
     266                        matcher->combineState( alt );
     267                }
     268               
    255269                // xxx -- was push_front
    256                 currentFinder.get_alternatives().push_back( ResolvExpr::Alternative(
    257                         new TupleAssignExpr(solved_assigns, matcher->tmpDecls), matcher->compositeEnv,
    258                         ResolvExpr::sumCost( current ) + matcher->baseCost ) );
     270                currentFinder.get_alternatives().push_back( ResolvExpr::Alternative{
     271                        new TupleAssignExpr{ solved_assigns, matcher->tmpDecls }, matcher->compositeEnv,
     272                        matcher->openVars,
     273                        ResolvExpr::AssertionList( matcher->need.begin(), matcher->need.end() ),
     274                        ResolvExpr::sumCost( current ) + matcher->baseCost } );
    259275        }
    260276
     
    263279        : lhs(lhs), rhs(rhs), spotter(spotter),
    264280          baseCost( ResolvExpr::sumCost( lhs ) + ResolvExpr::sumCost( rhs ) ) {
    265                 simpleCombineEnvironments( lhs.begin(), lhs.end(), compositeEnv );
    266                 simpleCombineEnvironments( rhs.begin(), rhs.end(), compositeEnv );
     281                combineState( lhs );
     282                combineState( rhs );
    267283        }
    268284
Note: See TracChangeset for help on using the changeset viewer.