[0dd3a2f] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // Indexer.h -- |
---|
| 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Sun May 17 21:38:55 2015 |
---|
[ae4c85a] | 11 | // Last Modified By : Rob Schluntz |
---|
| 12 | // Last Modified On : Wed Aug 05 13:51:39 2015 |
---|
| 13 | // Update Count : 4 |
---|
[0dd3a2f] | 14 | // |
---|
| 15 | |
---|
| 16 | #ifndef INDEXER_H |
---|
| 17 | #define INDEXER_H |
---|
[51b7345] | 18 | |
---|
| 19 | #include <list> |
---|
| 20 | #include <string> |
---|
| 21 | #include <map> |
---|
| 22 | |
---|
| 23 | #include "SynTree/Visitor.h" |
---|
| 24 | #include "IdTable.h" |
---|
| 25 | #include "AggregateTable.h" |
---|
| 26 | #include "TypeTable.h" |
---|
| 27 | |
---|
| 28 | namespace SymTab { |
---|
[a08ba92] | 29 | class Indexer : public Visitor { |
---|
| 30 | public: |
---|
| 31 | Indexer( bool useDebug = false ); |
---|
| 32 | virtual ~Indexer(); |
---|
[17cd4eb] | 33 | |
---|
[a08ba92] | 34 | //using Visitor::visit; |
---|
| 35 | virtual void visit( ObjectDecl *objectDecl ); |
---|
| 36 | virtual void visit( FunctionDecl *functionDecl ); |
---|
| 37 | virtual void visit( TypeDecl *typeDecl ); |
---|
| 38 | virtual void visit( TypedefDecl *typeDecl ); |
---|
| 39 | virtual void visit( StructDecl *aggregateDecl ); |
---|
| 40 | virtual void visit( UnionDecl *aggregateDecl ); |
---|
| 41 | virtual void visit( EnumDecl *aggregateDecl ); |
---|
| 42 | virtual void visit( ContextDecl *aggregateDecl ); |
---|
[17cd4eb] | 43 | |
---|
[a08ba92] | 44 | virtual void visit( CompoundStmt *compoundStmt ); |
---|
[17cd4eb] | 45 | |
---|
[ae4c85a] | 46 | virtual void visit( ApplicationExpr *applicationExpr ); |
---|
| 47 | virtual void visit( UntypedExpr *untypedExpr ); |
---|
| 48 | virtual void visit( NameExpr *nameExpr ); |
---|
| 49 | virtual void visit( CastExpr *castExpr ); |
---|
| 50 | virtual void visit( AddressExpr *addressExpr ); |
---|
| 51 | virtual void visit( LabelAddressExpr *labAddressExpr ); |
---|
| 52 | virtual void visit( UntypedMemberExpr *memberExpr ); |
---|
| 53 | virtual void visit( MemberExpr *memberExpr ); |
---|
| 54 | virtual void visit( VariableExpr *variableExpr ); |
---|
| 55 | virtual void visit( ConstantExpr *constantExpr ); |
---|
| 56 | virtual void visit( SizeofExpr *sizeofExpr ); |
---|
| 57 | virtual void visit( AttrExpr *attrExpr ); |
---|
| 58 | virtual void visit( LogicalExpr *logicalExpr ); |
---|
| 59 | virtual void visit( ConditionalExpr *conditionalExpr ); |
---|
| 60 | virtual void visit( CommaExpr *commaExpr ); |
---|
| 61 | virtual void visit( TupleExpr *tupleExpr ); |
---|
| 62 | virtual void visit( SolvedTupleExpr *tupleExpr ); |
---|
| 63 | virtual void visit( TypeExpr *typeExpr ); |
---|
| 64 | virtual void visit( AsmExpr *asmExpr ); |
---|
| 65 | virtual void visit( UntypedValofExpr *valofExpr ); |
---|
| 66 | |
---|
[a08ba92] | 67 | virtual void visit( ContextInstType *contextInst ); |
---|
| 68 | virtual void visit( StructInstType *contextInst ); |
---|
| 69 | virtual void visit( UnionInstType *contextInst ); |
---|
[d4778a6] | 70 | |
---|
[a08ba92] | 71 | virtual void visit( ForStmt *forStmt ); |
---|
[d4778a6] | 72 | |
---|
[a08ba92] | 73 | // when using an indexer manually (e.g., within a mutator traversal), it is necessary to tell the indexer |
---|
| 74 | // explicitly when scopes begin and end |
---|
| 75 | void enterScope(); |
---|
| 76 | void leaveScope(); |
---|
[17cd4eb] | 77 | |
---|
[a08ba92] | 78 | void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const; |
---|
| 79 | DeclarationWithType* lookupId( const std::string &id) const; |
---|
| 80 | NamedTypeDecl *lookupType( const std::string &id ) const; |
---|
| 81 | StructDecl *lookupStruct( const std::string &id ) const; |
---|
| 82 | EnumDecl *lookupEnum( const std::string &id ) const; |
---|
| 83 | UnionDecl *lookupUnion( const std::string &id ) const; |
---|
| 84 | ContextDecl *lookupContext( const std::string &id ) const; |
---|
[51b7345] | 85 | |
---|
[a08ba92] | 86 | void print( std::ostream &os, int indent = 0 ) const; |
---|
| 87 | private: |
---|
| 88 | IdTable idTable; |
---|
| 89 | TypeTable typeTable; |
---|
| 90 | StructTable structTable; |
---|
| 91 | EnumTable enumTable; |
---|
| 92 | UnionTable unionTable; |
---|
| 93 | ContextTable contextTable; |
---|
[51b7345] | 94 | |
---|
[a08ba92] | 95 | bool doDebug; // display debugging trace |
---|
| 96 | }; |
---|
[51b7345] | 97 | } // namespace SymTab |
---|
| 98 | |
---|
[0dd3a2f] | 99 | #endif // INDEXER_H |
---|
| 100 | |
---|
| 101 | // Local Variables: // |
---|
| 102 | // tab-width: 4 // |
---|
| 103 | // mode: c++ // |
---|
| 104 | // compile-command: "make install" // |
---|
| 105 | // End: // |
---|