| 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 {
|
|---|
| 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 );
|
|---|
| 34 |
|
|---|
| 35 | // when using an indexer manually (e.g., within a mutator traversal), it is necessary to tell the indexer
|
|---|
| 36 | // explicitly when scopes begin and end
|
|---|
| 37 | void enterScope();
|
|---|
| 38 | void leaveScope();
|
|---|
| 39 |
|
|---|
| 40 | void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
|
|---|
| 41 | NamedTypeDecl *lookupType( const std::string &id ) const;
|
|---|
| 42 | StructDecl *lookupStruct( const std::string &id ) const;
|
|---|
| 43 | EnumDecl *lookupEnum( const std::string &id ) const;
|
|---|
| 44 | UnionDecl *lookupUnion( const std::string &id ) const;
|
|---|
| 45 | ContextDecl *lookupContext( const std::string &id ) const;
|
|---|
| 46 |
|
|---|
| 47 | void print( std::ostream &os, int indent = 0 ) const;
|
|---|
| 48 | private:
|
|---|
| 49 | IdTable idTable;
|
|---|
| 50 | TypeTable typeTable;
|
|---|
| 51 | StructTable structTable;
|
|---|
| 52 | EnumTable enumTable;
|
|---|
| 53 | UnionTable unionTable;
|
|---|
| 54 | ContextTable contextTable;
|
|---|
| 55 |
|
|---|
| 56 | bool doDebug; // display debugging trace
|
|---|
| 57 | };
|
|---|
| 58 | } // namespace SymTab
|
|---|
| 59 |
|
|---|
| 60 | #endif /* #ifndef SYMTAB_INDEXER_H */
|
|---|