| 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
 | 
|---|
| 12 | // Last Modified On : Tue May 19 16:51:21 2015
 | 
|---|
| 13 | // Update Count     : 3
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #ifndef INDEXER_H
 | 
|---|
| 17 | #define INDEXER_H
 | 
|---|
| 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 {
 | 
|---|
| 29 |         class Indexer : public Visitor {
 | 
|---|
| 30 |           public:
 | 
|---|
| 31 |                 Indexer( bool useDebug = false );
 | 
|---|
| 32 |                 virtual ~Indexer();
 | 
|---|
| 33 | 
 | 
|---|
| 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 );
 | 
|---|
| 43 | 
 | 
|---|
| 44 |                 virtual void visit( CompoundStmt *compoundStmt );
 | 
|---|
| 45 | 
 | 
|---|
| 46 |                 virtual void visit( ContextInstType *contextInst );
 | 
|---|
| 47 |                 virtual void visit( StructInstType *contextInst );
 | 
|---|
| 48 |                 virtual void visit( UnionInstType *contextInst );
 | 
|---|
| 49 | 
 | 
|---|
| 50 |                 virtual void visit( ForStmt *forStmt );
 | 
|---|
| 51 | 
 | 
|---|
| 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();
 | 
|---|
| 56 | 
 | 
|---|
| 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;
 | 
|---|
| 64 |   
 | 
|---|
| 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;
 | 
|---|
| 73 |   
 | 
|---|
| 74 |                 bool doDebug;                                   // display debugging trace
 | 
|---|
| 75 |         };
 | 
|---|
| 76 | } // namespace SymTab
 | 
|---|
| 77 | 
 | 
|---|
| 78 | #endif // INDEXER_H
 | 
|---|
| 79 | 
 | 
|---|
| 80 | // Local Variables: //
 | 
|---|
| 81 | // tab-width: 4 //
 | 
|---|
| 82 | // mode: c++ //
 | 
|---|
| 83 | // compile-command: "make install" //
 | 
|---|
| 84 | // End: //
 | 
|---|