Changeset 5af62f1 for src/ResolvExpr


Ignore:
Timestamp:
Sep 10, 2016, 12:53:36 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
908cc83
Parents:
add7117
Message:

major refactoring of Rodolfo's tuple assignment code

Location:
src/ResolvExpr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/ResolvExpr/AlternativeFinder.cc

    radd7117 r5af62f1  
    142142                }
    143143
    144                 template< typename InputIterator, typename OutputIterator >
    145                 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
    146                         AltList alternatives;
    147 
    148                         // select the alternatives that have the minimum parameter cost
    149                         Cost minCost = Cost::infinity;
    150                         for ( AltList::iterator i = begin; i != end; ++i ) {
    151                                 if ( i->cost < minCost ) {
    152                                         minCost = i->cost;
    153                                         i->cost = i->cvtCost;
    154                                         alternatives.clear();
    155                                         alternatives.push_back( *i );
    156                                 } else if ( i->cost == minCost ) {
    157                                         i->cost = i->cvtCost;
    158                                         alternatives.push_back( *i );
    159                                 }
    160                         }
    161                         std::copy( alternatives.begin(), alternatives.end(), out );
    162                 }
    163 
    164144                template< typename InputIterator >
    165145                void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {
     
    254234        template< typename StructOrUnionType >
    255235        void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) {
     236
     237                // // member must be either a tuple expression or a name expr
     238                // if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( memberExpr->get_member() ) ) {
     239                //  addAggMembers( structInst, agg->expr, agg->cost, nameExpr->get_name() );
     240                // } else {
     241                //  TupleExpr * tupleExpr = safe_dynamic_cast< TupleExpr * >( memberExpr->get_member() );
     242                //  // xxx - ...
     243                //  assert( false );
     244                // }
     245                // if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( memberExpr->get_member() ) ) {
     246
     247                // }
    256248                NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member );
    257249                const std::string & name = nameExpr->get_name();
     
    639631                combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) );
    640632
    641                 Tuples::TupleAssignSpotter tassign( this );
    642                 if ( tassign.isTupleAssignment( untypedExpr, possibilities ) ) {
    643                         // take care of possible tuple assignments, or discard expression
    644                         return;
    645                 } // else ...
     633                // take care of possible tuple assignments
     634                // if not tuple assignment, assignment is taken care of as a normal function call
     635                Tuples::handleTupleAssignment( *this, untypedExpr, possibilities );
    646636
    647637                AltList candidates;
  • TabularUnified src/ResolvExpr/AlternativeFinder.h

    radd7117 r5af62f1  
    6767                virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
    6868                virtual void visit( ConstructorExpr * ctorExpr );
    69           public:  // xxx - temporary hack - should make Tuples::TupleAssignment a friend
    70           /// Runs a new alternative finder on each element in [begin, end)
    71           /// and writes each alternative finder to out.
     69                /// Runs a new alternative finder on each element in [begin, end)
     70                /// and writes each alternative finder to out.
    7271                template< typename InputIterator, typename OutputIterator >
    7372                void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out );
    7473
    75           private:
    7674                /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member
    7775                template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
     
    9189
    9290        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env );
     91
     92        template< typename InputIterator, typename OutputIterator >
     93        void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
     94                AltList alternatives;
     95
     96                // select the alternatives that have the minimum parameter cost
     97                Cost minCost = Cost::infinity;
     98                for ( InputIterator i = begin; i != end; ++i ) {
     99                        if ( i->cost < minCost ) {
     100                                minCost = i->cost;
     101                                i->cost = i->cvtCost;
     102                                alternatives.clear();
     103                                alternatives.push_back( *i );
     104                        } else if ( i->cost == minCost ) {
     105                                i->cost = i->cvtCost;
     106                                alternatives.push_back( *i );
     107                        }
     108                }
     109                std::copy( alternatives.begin(), alternatives.end(), out );
     110        }
    93111} // namespace ResolvExpr
    94112
Note: See TracChangeset for help on using the changeset viewer.