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