Ignore:
Timestamp:
Jan 11, 2017, 4:11:02 PM (9 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
075734f
Parents:
bb82c03 (diff), d3a85240 (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

    rbb82c03 r2162c2c  
    7373        };
    7474
    75         /// true if expr is an expression of tuple type, i.e. a tuple expression, tuple variable, or MRV (multiple-return-value) function
     75        /// true if expr is an expression of tuple type
    7676        bool isTuple( Expression *expr ) {
    7777                if ( ! expr ) return false;
    7878                assert( expr->has_result() );
    79                 return dynamic_cast<TupleExpr *>(expr) || expr->get_result()->size() > 1;
     79                return dynamic_cast< TupleType * >( expr->get_result() );
    8080        }
    8181
     
    142142                matcher->match( new_assigns );
    143143
    144                 if ( new_assigns.empty() ) return;
     144                if ( ! matcher->lhs.empty() || ! matcher->rhs.empty() ) {
     145                        // if both lhs and rhs are empty then this is the empty tuple case, wherein it's okay for new_assigns to be empty.
     146                        // if not the empty tuple case, return early so that no new alternatives are generated.
     147                        if ( new_assigns.empty() ) return;
     148                }
    145149                ResolvExpr::AltList current;
    146150                // now resolve new assignments
     
    186190
    187191                // explode the lhs so that each field of the tuple-valued-expr is assigned.
    188                 explode( lhsAlt, spotter.currentFinder.get_indexer(), back_inserter(lhs) );
     192                explode( lhsAlt, spotter.currentFinder.get_indexer(), back_inserter(lhs), true );
    189193
    190194                // and finally, re-add the cast to each lhs expr, so that qualified tuple fields can be constructed
     
    211215        TupleAssignSpotter::MultipleAssignMatcher::MultipleAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) {
    212216                // explode the rhs so that each field of the tuple-valued-expr is assigned.
    213                 explode( std::next(alts.begin(), 1), alts.end(), spotter.currentFinder.get_indexer(), back_inserter(rhs) );
     217                explode( std::next(alts.begin(), 1), alts.end(), spotter.currentFinder.get_indexer(), back_inserter(rhs), true );
    214218        }
    215219
     
    248252                static UniqueName lhsNamer( "__massassign_L" );
    249253                static UniqueName rhsNamer( "__massassign_R" );
    250                 assert ( ! lhs.empty() && rhs.size() <= 1);
     254                // empty tuple case falls into this matcher, hence the second part of the assert
     255                assert( (! lhs.empty() && rhs.size() <= 1) || (lhs.empty() && rhs.empty()) );
    251256
    252257                ObjectDecl * rtmp = rhs.size() == 1 ? newObject( rhsNamer, rhs.front().expr ) : nullptr;
    253258                for ( ResolvExpr::Alternative & lhsAlt : lhs ) {
     259                        // create a temporary object for each value in the lhs and create a call involving the rhs
    254260                        ObjectDecl * ltmp = newObject( lhsNamer, lhsAlt.expr );
    255261                        out.push_back( createFunc( spotter.fname, ltmp, rtmp ) );
     
    263269                static UniqueName rhsNamer( "__multassign_R" );
    264270
    265                 // xxx - need more complicated matching?
    266271                if ( lhs.size() == rhs.size() ) {
     272                        // produce a new temporary object for each value in the lhs and rhs and pairwise create the calls
    267273                        std::list< ObjectDecl * > ltmp;
    268274                        std::list< ObjectDecl * > rtmp;
Note: See TracChangeset for help on using the changeset viewer.