source: src/SymTab/Indexer.h@ b6fd751

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 b6fd751 was 6eb8948, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

make TupleAssignment generate temporaries, add StmtExpr for GCC statement expressions, expand tuple assignment expressions, collapse SolvedTupleExpr, MassAssignExpr, and MultipleAssignExpr into TupleAssignExpr

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