source: src/SymTab/Indexer.h@ e0a653d

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since e0a653d was 30f9072, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

More cleanup on the headers

  • Property mode set to 100644
File size: 6.5 KB
RevLine 
[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//
[1e1e15b]7// Indexer.h --
[0dd3a2f]8//
9// Author : Richard C. Bilson
10// Created On : Sun May 17 21:38:55 2015
[4040425]11// Last Modified By : Peter A. Buhr
12// Last Modified On : Wed Mar 2 17:34:14 2016
13// Update Count : 6
[0dd3a2f]14//
15
16#ifndef INDEXER_H
17#define INDEXER_H
[51b73452]18
[30f9072]19#include <iosfwd> // for ostream
20#include <list> // for list
21#include <string> // for string
[51b73452]22
[30f9072]23#include "SynTree/Visitor.h" // for Visitor
24#include "SynTree/SynTree.h" // for AST nodes
[51b73452]25
26namespace SymTab {
[a08ba92]27 class Indexer : public Visitor {
28 public:
[fc638d2]29 explicit Indexer( bool useDebug = false );
[e8032b0]30
31 Indexer( const Indexer &that );
32 Indexer( Indexer &&that );
[a08ba92]33 virtual ~Indexer();
[e8032b0]34 Indexer& operator= ( const Indexer &that );
35 Indexer& operator= ( Indexer &&that );
[17cd4eb]36
[1e1e15b]37 using Visitor::visit;
[a08ba92]38 virtual void visit( ObjectDecl *objectDecl );
39 virtual void visit( FunctionDecl *functionDecl );
40 virtual void visit( TypeDecl *typeDecl );
41 virtual void visit( TypedefDecl *typeDecl );
42 virtual void visit( StructDecl *aggregateDecl );
43 virtual void visit( UnionDecl *aggregateDecl );
44 virtual void visit( EnumDecl *aggregateDecl );
[4040425]45 virtual void visit( TraitDecl *aggregateDecl );
[17cd4eb]46
[a08ba92]47 virtual void visit( CompoundStmt *compoundStmt );
[17cd4eb]48
[ae4c85a]49 virtual void visit( ApplicationExpr *applicationExpr );
50 virtual void visit( UntypedExpr *untypedExpr );
51 virtual void visit( NameExpr *nameExpr );
52 virtual void visit( CastExpr *castExpr );
53 virtual void visit( AddressExpr *addressExpr );
54 virtual void visit( LabelAddressExpr *labAddressExpr );
55 virtual void visit( UntypedMemberExpr *memberExpr );
56 virtual void visit( MemberExpr *memberExpr );
57 virtual void visit( VariableExpr *variableExpr );
[1e1e15b]58 virtual void visit( ConstantExpr *constantExpr );
[ae4c85a]59 virtual void visit( SizeofExpr *sizeofExpr );
[47534159]60 virtual void visit( AlignofExpr *alignofExpr );
[2a4b088]61 virtual void visit( UntypedOffsetofExpr *offsetofExpr );
[25a054f]62 virtual void visit( OffsetofExpr *offsetofExpr );
[afc1045]63 virtual void visit( OffsetPackExpr *offsetPackExpr );
[ae4c85a]64 virtual void visit( AttrExpr *attrExpr );
65 virtual void visit( LogicalExpr *logicalExpr );
66 virtual void visit( ConditionalExpr *conditionalExpr );
67 virtual void visit( CommaExpr *commaExpr );
68 virtual void visit( TypeExpr *typeExpr );
69 virtual void visit( AsmExpr *asmExpr );
[907eccb]70 virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr );
71 virtual void visit( ConstructorExpr * ctorExpr );
72 virtual void visit( CompoundLiteralExpr *compLitExpr );
73 virtual void visit( RangeExpr *rangeExpr );
74 virtual void visit( UntypedTupleExpr *tupleExpr );
[6eb8948]75 virtual void visit( TupleExpr *tupleExpr );
[907eccb]76 virtual void visit( TupleIndexExpr *tupleExpr );
[6eb8948]77 virtual void visit( TupleAssignExpr *tupleExpr );
[907eccb]78 virtual void visit( StmtExpr * stmtExpr );
79 virtual void visit( UniqueExpr * uniqueExpr );
[ae4c85a]80
[4040425]81 virtual void visit( TraitInstType *contextInst );
[a08ba92]82 virtual void visit( StructInstType *contextInst );
83 virtual void visit( UnionInstType *contextInst );
[d4778a6]84
[a08ba92]85 virtual void visit( ForStmt *forStmt );
[d4778a6]86
[a08ba92]87 // when using an indexer manually (e.g., within a mutator traversal), it is necessary to tell the indexer
88 // explicitly when scopes begin and end
89 void enterScope();
90 void leaveScope();
[17cd4eb]91
[bed4c63e]92 /// Gets all declarations with the given ID
[e8032b0]93 void lookupId( const std::string &id, std::list< DeclarationWithType* > &out ) const;
[bed4c63e]94 /// Gets the top-most type declaration with the given ID
[a08ba92]95 NamedTypeDecl *lookupType( const std::string &id ) const;
[bed4c63e]96 /// Gets the top-most struct declaration with the given ID
[a08ba92]97 StructDecl *lookupStruct( const std::string &id ) const;
[bed4c63e]98 /// Gets the top-most enum declaration with the given ID
[a08ba92]99 EnumDecl *lookupEnum( const std::string &id ) const;
[bed4c63e]100 /// Gets the top-most union declaration with the given ID
[a08ba92]101 UnionDecl *lookupUnion( const std::string &id ) const;
[bed4c63e]102 /// Gets the top-most trait declaration with the given ID
[4040425]103 TraitDecl *lookupTrait( const std::string &id ) const;
[1e1e15b]104
[a08ba92]105 void print( std::ostream &os, int indent = 0 ) const;
106 private:
[bed4c63e]107 /// looks up a specific mangled ID at the given scope
108 DeclarationWithType *lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
[5447e09]109 /// returns true if there exists a declaration with C linkage and the given name with a different mangled name
[09d1ad0]110 bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
[8884112]111 /// returns true if there exists a declaration with C linkage and the given name with the same mangled name
112 bool hasCompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
[52c2a72]113 // equivalents to lookup functions that only look at tables at scope `scope` (which should be >= tables->scope)
114 NamedTypeDecl *lookupTypeAtScope( const std::string &id, unsigned long scope ) const;
115 StructDecl *lookupStructAtScope( const std::string &id, unsigned long scope ) const;
116 EnumDecl *lookupEnumAtScope( const std::string &id, unsigned long scope ) const;
117 UnionDecl *lookupUnionAtScope( const std::string &id, unsigned long scope ) const;
118 TraitDecl *lookupTraitAtScope( const std::string &id, unsigned long scope ) const;
[1e1e15b]119
[e8032b0]120 void addId( DeclarationWithType *decl );
121 void addType( NamedTypeDecl *decl );
122 void addStruct( const std::string &id );
123 void addStruct( StructDecl *decl );
124 void addEnum( EnumDecl *decl );
125 void addUnion( const std::string &id );
126 void addUnion( UnionDecl *decl );
127 void addTrait( TraitDecl *decl );
[1e1e15b]128
[e8032b0]129 struct Impl;
[30f9072]130
[52c2a72]131 Impl *tables; ///< Copy-on-write instance of table data structure
132 unsigned long scope; ///< Scope index of this pointer
133 bool doDebug; ///< Display debugging trace?
[e8032b0]134
135 /// Takes a new ref to a table (returns null if null)
136 static Impl *newRef( Impl *toClone );
137 /// Clears a ref to a table (does nothing if null)
138 static void deleteRef( Impl *toFree );
139
[1ba88a0]140 // Removes matching autogenerated constructors and destructors
141 // so that they will not be selected
142 // void removeSpecialOverrides( FunctionDecl *decl );
143 void removeSpecialOverrides( const std::string &id, std::list< DeclarationWithType * > & out ) const;
144
[52c2a72]145 /// Ensures that tables variable is writable (i.e. allocated, uniquely owned by this Indexer, and at the current scope)
[e8032b0]146 void makeWritable();
[a08ba92]147 };
[51b73452]148} // namespace SymTab
149
[0dd3a2f]150#endif // INDEXER_H
151
152// Local Variables: //
153// tab-width: 4 //
154// mode: c++ //
155// compile-command: "make install" //
156// End: //
Note: See TracBrowser for help on using the repository browser.