Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.h

    rb6fe7e6 rac9ca96  
    6767                virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
    6868                virtual void visit( ConstructorExpr * ctorExpr );
    69           public:  // xxx - temporary hack - should make Tuples::TupleAssignment a friend
     69                virtual void visit( TupleIndexExpr *tupleExpr );
     70                virtual void visit( TupleAssignExpr *tupleExpr );
     71                /// Runs a new alternative finder on each element in [begin, end)
     72                /// and writes each alternative finder to out.
    7073                template< typename InputIterator, typename OutputIterator >
    7174                void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out );
    7275
    73           private:
    7476                /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member
    75                 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name );
     77                template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
    7678                /// Adds alternatives for offsetof expressions, given the base type and name of the member
    7779                template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name );
    78                 bool instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave );
     80                bool instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out );
    7981                template< typename OutputIterator >
    80                 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out );
     82                void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out );
    8183                template< typename OutputIterator >
    8284                void inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out );
     
    8991
    9092        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env );
     93
     94        template< typename InputIterator, typename OutputIterator >
     95        void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {
     96                AltList alternatives;
     97
     98                // select the alternatives that have the minimum parameter cost
     99                Cost minCost = Cost::infinity;
     100                for ( InputIterator i = begin; i != end; ++i ) {
     101                        if ( i->cost < minCost ) {
     102                                minCost = i->cost;
     103                                i->cost = i->cvtCost;
     104                                alternatives.clear();
     105                                alternatives.push_back( *i );
     106                        } else if ( i->cost == minCost ) {
     107                                i->cost = i->cvtCost;
     108                                alternatives.push_back( *i );
     109                        }
     110                }
     111                std::copy( alternatives.begin(), alternatives.end(), out );
     112        }
     113
     114        Cost sumCost( const AltList &in );
     115
     116        template< typename InputIterator >
     117        void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {
     118                while ( begin != end ) {
     119                        result.simpleCombine( (*begin++).env );
     120                }
     121        }
    91122} // namespace ResolvExpr
    92123
Note: See TracChangeset for help on using the changeset viewer.