Changeset d9a0e76 for translator/ResolvExpr/AlternativeFinder.h
- Timestamp:
- Dec 16, 2014, 9:41:50 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 17cd4eb
- Parents:
- 3848e0e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/ResolvExpr/AlternativeFinder.h
r3848e0e rd9a0e76 1 /* 2 * This file is part of the Cforall project 3 * 4 * $Id: AlternativeFinder.h,v 1.19 2005/08/29 20:14:15 rcbilson Exp $ 5 * 6 */ 7 8 #ifndef RESOLVEXPR_ALTERNATIVEFINDER_H 9 #define RESOLVEXPR_ALTERNATIVEFINDER_H 1 #ifndef ALTERNATIVEFINDER_H 2 #define ALTERNATIVEFINDER_H 10 3 11 4 #include <set> … … 18 11 19 12 namespace ResolvExpr { 13 class AlternativeFinder : public Visitor { 14 public: 15 AlternativeFinder( const SymTab::Indexer &indexer, const TypeEnvironment &env ); 16 void find( Expression *expr, bool adjust = false ); 17 void findWithAdjustment( Expression *expr ); 18 AltList &get_alternatives() { return alternatives; } 19 20 // make this look like an STL container so that we can apply generic algorithms 21 typedef Alternative value_type; 22 typedef AltList::iterator iterator; 23 typedef AltList::const_iterator const_iterator; 24 AltList::iterator begin() { return alternatives.begin(); } 25 AltList::iterator end() { return alternatives.end(); } 26 AltList::const_iterator begin() const { return alternatives.begin(); } 27 AltList::const_iterator end() const { return alternatives.end(); } 28 29 const SymTab::Indexer &get_indexer() const { return indexer; } 30 const TypeEnvironment &get_environ() const { return env; } 31 private: 32 virtual void visit( ApplicationExpr *applicationExpr ); 33 virtual void visit( UntypedExpr *untypedExpr ); 34 virtual void visit( AddressExpr *addressExpr ); 35 virtual void visit( CastExpr *castExpr ); 36 virtual void visit( UntypedMemberExpr *memberExpr ); 37 virtual void visit( MemberExpr *memberExpr ); 38 virtual void visit( NameExpr *variableExpr ); 39 virtual void visit( VariableExpr *variableExpr ); 40 virtual void visit( ConstantExpr *constantExpr ); 41 virtual void visit( SizeofExpr *sizeofExpr ); 42 virtual void visit( AttrExpr *attrExpr ); 43 virtual void visit( LogicalExpr *logicalExpr ); 44 virtual void visit( ConditionalExpr *conditionalExpr ); 45 virtual void visit( CommaExpr *commaExpr ); 46 virtual void visit( TupleExpr *tupleExpr ); 47 public: // xxx - temporary hack - should make Tuples::TupleAssignment a friend 48 template< typename InputIterator, typename OutputIterator > 49 void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out ); 20 50 21 class AlternativeFinder : public Visitor 22 { 23 public: 24 AlternativeFinder( const SymTab::Indexer &indexer, const TypeEnvironment &env ); 25 void find( Expression *expr, bool adjust = false ); 26 void findWithAdjustment( Expression *expr ); 27 AltList &get_alternatives() { return alternatives; } 28 29 // make this look like an STL container so that we can apply generic algorithms 30 typedef Alternative value_type; 31 typedef AltList::iterator iterator; 32 typedef AltList::const_iterator const_iterator; 33 AltList::iterator begin() { return alternatives.begin(); } 34 AltList::iterator end() { return alternatives.end(); } 35 AltList::const_iterator begin() const { return alternatives.begin(); } 36 AltList::const_iterator end() const { return alternatives.end(); } 37 38 const SymTab::Indexer &get_indexer() const { return indexer; } 39 const TypeEnvironment &get_environ() const { return env; } 40 private: 41 virtual void visit(ApplicationExpr *applicationExpr); 42 virtual void visit(UntypedExpr *untypedExpr); 43 virtual void visit(AddressExpr *addressExpr); 44 virtual void visit(CastExpr *castExpr); 45 virtual void visit(UntypedMemberExpr *memberExpr); 46 virtual void visit(MemberExpr *memberExpr); 47 virtual void visit(NameExpr *variableExpr); 48 virtual void visit(VariableExpr *variableExpr); 49 virtual void visit(ConstantExpr *constantExpr); 50 virtual void visit(SizeofExpr *sizeofExpr); 51 virtual void visit(AttrExpr *attrExpr); 52 virtual void visit(LogicalExpr *logicalExpr); 53 virtual void visit(ConditionalExpr *conditionalExpr); 54 virtual void visit(CommaExpr *commaExpr); 55 virtual void visit(TupleExpr *tupleExpr); 56 public: // xxx - temporary hack - should make Tuples::TupleAssignment a friend 57 template< typename InputIterator, typename OutputIterator > 58 void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out ); 51 private: 52 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const std::string &name ); 53 bool instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave ); 54 template< typename OutputIterator > 55 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out ); 56 template< typename OutputIterator > 57 void inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out ); 58 void resolveAttr( DeclarationWithType *funcDecl, FunctionType *function, Type *argType, const TypeEnvironment &env ); 59 59 60 private: 61 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const std::string &name ); 62 bool instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave ); 63 template< typename OutputIterator > 64 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out ); 65 template< typename OutputIterator > 66 void inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out ); 67 void resolveAttr( DeclarationWithType *funcDecl, FunctionType *function, Type *argType, const TypeEnvironment &env ); 60 const SymTab::Indexer &indexer; 61 AltList alternatives; 62 const TypeEnvironment &env; 63 }; // AlternativeFinder 68 64 69 const SymTab::Indexer &indexer; 70 AltList alternatives; 71 const TypeEnvironment &env; 72 }; 73 74 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ) 75 ; 76 65 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ); 77 66 } // namespace ResolvExpr 78 67 79 #endif / * #ifndef RESOLVEXPR_ALTERNATIVEFINDER_H */68 #endif // ALTERNATIVEFINDER_H
Note: See TracChangeset
for help on using the changeset viewer.