[51b7345] | 1 | #ifndef SYMTAB_INDEXER_H |
---|
| 2 | #define SYMTAB_INDEXER_H |
---|
| 3 | |
---|
| 4 | #include <list> |
---|
| 5 | #include <string> |
---|
| 6 | #include <map> |
---|
| 7 | |
---|
| 8 | #include "SynTree/Visitor.h" |
---|
| 9 | #include "IdTable.h" |
---|
| 10 | #include "AggregateTable.h" |
---|
| 11 | #include "TypeTable.h" |
---|
| 12 | |
---|
| 13 | namespace SymTab { |
---|
[17cd4eb] | 14 | class Indexer : public Visitor { |
---|
| 15 | public: |
---|
| 16 | Indexer( bool useDebug = false ); |
---|
| 17 | virtual ~Indexer(); |
---|
| 18 | |
---|
| 19 | //using Visitor::visit; |
---|
| 20 | virtual void visit( ObjectDecl *objectDecl ); |
---|
| 21 | virtual void visit( FunctionDecl *functionDecl ); |
---|
| 22 | virtual void visit( TypeDecl *typeDecl ); |
---|
| 23 | virtual void visit( TypedefDecl *typeDecl ); |
---|
| 24 | virtual void visit( StructDecl *aggregateDecl ); |
---|
| 25 | virtual void visit( UnionDecl *aggregateDecl ); |
---|
| 26 | virtual void visit( EnumDecl *aggregateDecl ); |
---|
| 27 | virtual void visit( ContextDecl *aggregateDecl ); |
---|
| 28 | |
---|
| 29 | virtual void visit( CompoundStmt *compoundStmt ); |
---|
| 30 | |
---|
| 31 | virtual void visit( ContextInstType *contextInst ); |
---|
| 32 | virtual void visit( StructInstType *contextInst ); |
---|
| 33 | virtual void visit( UnionInstType *contextInst ); |
---|
[d4778a6] | 34 | |
---|
| 35 | virtual void visit( ForStmt *forStmt ); |
---|
| 36 | |
---|
[17cd4eb] | 37 | // when using an indexer manually (e.g., within a mutator traversal), it is necessary to tell the indexer |
---|
| 38 | // explicitly when scopes begin and end |
---|
| 39 | void enterScope(); |
---|
| 40 | void leaveScope(); |
---|
| 41 | |
---|
| 42 | void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const; |
---|
[bdd516a] | 43 | DeclarationWithType* lookupId( const std::string &id) const; |
---|
[17cd4eb] | 44 | NamedTypeDecl *lookupType( const std::string &id ) const; |
---|
| 45 | StructDecl *lookupStruct( const std::string &id ) const; |
---|
| 46 | EnumDecl *lookupEnum( const std::string &id ) const; |
---|
| 47 | UnionDecl *lookupUnion( const std::string &id ) const; |
---|
| 48 | ContextDecl *lookupContext( const std::string &id ) const; |
---|
[51b7345] | 49 | |
---|
[17cd4eb] | 50 | void print( std::ostream &os, int indent = 0 ) const; |
---|
| 51 | private: |
---|
| 52 | IdTable idTable; |
---|
| 53 | TypeTable typeTable; |
---|
| 54 | StructTable structTable; |
---|
| 55 | EnumTable enumTable; |
---|
| 56 | UnionTable unionTable; |
---|
| 57 | ContextTable contextTable; |
---|
[51b7345] | 58 | |
---|
[17cd4eb] | 59 | bool doDebug; // display debugging trace |
---|
| 60 | }; |
---|
[51b7345] | 61 | } // namespace SymTab |
---|
| 62 | |
---|
[bdd516a] | 63 | #endif // SYMTAB_INDEXER_H |
---|