Changeset 1f44196 for src/ResolvExpr/AlternativeFinder.h
- Timestamp:
- Nov 29, 2016, 3:30:59 PM (9 years ago)
- 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:
- 8e5724e
- Parents:
- 3a2128f (diff), 9129a84 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.h
r3a2128f r1f44196 67 67 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ); 68 68 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 virtual void visit( UniqueExpr *unqExpr ); 72 /// Runs a new alternative finder on each element in [begin, end) 73 /// and writes each alternative finder to out. 70 74 template< typename InputIterator, typename OutputIterator > 71 75 void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out ); 72 76 73 private:74 77 /// 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 ); 78 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 79 /// Adds alternatives for member expressions where the left side has tuple type 80 void addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 76 81 /// Adds alternatives for offsetof expressions, given the base type and name of the member 77 82 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);83 bool instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out ); 79 84 template< typename OutputIterator > 80 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out );85 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out ); 81 86 template< typename OutputIterator > 82 87 void inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out ); … … 89 94 90 95 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ); 96 97 template< typename InputIterator, typename OutputIterator > 98 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) { 99 AltList alternatives; 100 101 // select the alternatives that have the minimum parameter cost 102 Cost minCost = Cost::infinity; 103 for ( InputIterator i = begin; i != end; ++i ) { 104 if ( i->cost < minCost ) { 105 minCost = i->cost; 106 i->cost = i->cvtCost; 107 alternatives.clear(); 108 alternatives.push_back( *i ); 109 } else if ( i->cost == minCost ) { 110 i->cost = i->cvtCost; 111 alternatives.push_back( *i ); 112 } 113 } 114 std::copy( alternatives.begin(), alternatives.end(), out ); 115 } 116 117 Cost sumCost( const AltList &in ); 118 119 template< typename InputIterator > 120 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) { 121 while ( begin != end ) { 122 result.simpleCombine( (*begin++).env ); 123 } 124 } 91 125 } // namespace ResolvExpr 92 126
Note:
See TracChangeset
for help on using the changeset viewer.