[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
|
---|
| 11 | // Last Modified By : Peter A. Buhr
|
---|
[a08ba92] | 12 | // Last Modified On : Tue May 19 16:51:21 2015
|
---|
| 13 | // Update Count : 3
|
---|
[0dd3a2f] | 14 | //
|
---|
| 15 |
|
---|
| 16 | #ifndef INDEXER_H
|
---|
| 17 | #define INDEXER_H
|
---|
[51b73452] | 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 |
|
---|
[a08ba92] | 46 | virtual void visit( ContextInstType *contextInst );
|
---|
| 47 | virtual void visit( StructInstType *contextInst );
|
---|
| 48 | virtual void visit( UnionInstType *contextInst );
|
---|
[d4778a6] | 49 |
|
---|
[a08ba92] | 50 | virtual void visit( ForStmt *forStmt );
|
---|
[d4778a6] | 51 |
|
---|
[a08ba92] | 52 | // when using an indexer manually (e.g., within a mutator traversal), it is necessary to tell the indexer
|
---|
| 53 | // explicitly when scopes begin and end
|
---|
| 54 | void enterScope();
|
---|
| 55 | void leaveScope();
|
---|
[17cd4eb] | 56 |
|
---|
[a08ba92] | 57 | void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
|
---|
| 58 | DeclarationWithType* lookupId( const std::string &id) const;
|
---|
| 59 | NamedTypeDecl *lookupType( const std::string &id ) const;
|
---|
| 60 | StructDecl *lookupStruct( const std::string &id ) const;
|
---|
| 61 | EnumDecl *lookupEnum( const std::string &id ) const;
|
---|
| 62 | UnionDecl *lookupUnion( const std::string &id ) const;
|
---|
| 63 | ContextDecl *lookupContext( const std::string &id ) const;
|
---|
[51b73452] | 64 |
|
---|
[a08ba92] | 65 | void print( std::ostream &os, int indent = 0 ) const;
|
---|
| 66 | private:
|
---|
| 67 | IdTable idTable;
|
---|
| 68 | TypeTable typeTable;
|
---|
| 69 | StructTable structTable;
|
---|
| 70 | EnumTable enumTable;
|
---|
| 71 | UnionTable unionTable;
|
---|
| 72 | ContextTable contextTable;
|
---|
[51b73452] | 73 |
|
---|
[a08ba92] | 74 | bool doDebug; // display debugging trace
|
---|
| 75 | };
|
---|
[51b73452] | 76 | } // namespace SymTab
|
---|
| 77 |
|
---|
[0dd3a2f] | 78 | #endif // INDEXER_H
|
---|
| 79 |
|
---|
| 80 | // Local Variables: //
|
---|
| 81 | // tab-width: 4 //
|
---|
| 82 | // mode: c++ //
|
---|
| 83 | // compile-command: "make install" //
|
---|
| 84 | // End: //
|
---|