source: translator/ResolvExpr/AlternativeFinder.h @ f7f6785

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since f7f6785 was d9a0e76, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

remove Parser.old, add -XCFA to driver, copy ptrdiff_t from stddef.h in preclude, remove casts from initialization constants, adjust formatting

  • Property mode set to 100644
File size: 3.2 KB
Line 
1#ifndef ALTERNATIVEFINDER_H
2#define ALTERNATIVEFINDER_H
3
4#include <set>
5
6#include "Alternative.h"
7#include "Unify.h"
8#include "SynTree/SynTree.h"
9#include "SymTab/Indexer.h"
10#include "SynTree/TypeSubstitution.h"
11
12namespace 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 );
50
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
60        const SymTab::Indexer &indexer;
61        AltList alternatives;
62        const TypeEnvironment &env;
63    }; // AlternativeFinder
64
65    Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env );
66} // namespace ResolvExpr
67
68#endif // ALTERNATIVEFINDER_H
Note: See TracBrowser for help on using the repository browser.