source: src/SymTab/Indexer.h @ ea91c42

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since ea91c42 was 6b0b624, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

change #ifndef to #pragma once

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