Changeset ef5b828 for src/SymTab/Indexer.h
- Timestamp:
- Jul 12, 2019, 1:35:58 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- fce4e31
- Parents:
- 7870799
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Indexer.h
r7870799 ref5b828 34 34 virtual ~Indexer(); 35 35 36 // when using an indexer manually (e.g., within a mutator traversal), it is necessary to 36 // when using an indexer manually (e.g., within a mutator traversal), it is necessary to 37 37 // tell the indexer explicitly when scopes begin and end 38 38 void enterScope(); … … 50 50 // NOTE: shouldn't need either of these constructors, but gcc-4 does not properly support initializer lists with default members. 51 51 IdData() = default; 52 IdData( 52 IdData( 53 53 DeclarationWithType * id, Expression * baseExpr, BaseSyntaxNode * deleteStmt, 54 unsigned long scope ) 54 unsigned long scope ) 55 55 : id( id ), baseExpr( baseExpr ), deleteStmt( deleteStmt ), scope( scope ) {} 56 56 IdData( const IdData& o, BaseSyntaxNode * deleteStmt ) … … 61 61 62 62 /// Gets all declarations with the given ID 63 void lookupId( const std::string & id, std::list< IdData > &out ) const;63 void lookupId( const std::string & id, std::list< IdData > &out ) const; 64 64 /// Gets the top-most type declaration with the given ID 65 NamedTypeDecl *lookupType( const std::string &id ) const; 65 const NamedTypeDecl * lookupType( const std::string & id ) const; 66 NamedTypeDecl * lookupMutableType( const std::string & id ) const; 66 67 /// Gets the top-most struct declaration with the given ID 67 StructDecl *lookupStruct( const std::string &id ) const; 68 const StructDecl * lookupStruct( const std::string & id ) const; 69 StructDecl * lookupMutableStruct( const std::string & id ) const; 68 70 /// Gets the top-most enum declaration with the given ID 69 EnumDecl *lookupEnum( const std::string &id ) const; 71 const EnumDecl * lookupEnum( const std::string & id ) const; 72 EnumDecl * lookupMutableEnum( const std::string & id ) const; 70 73 /// Gets the top-most union declaration with the given ID 71 UnionDecl *lookupUnion( const std::string &id ) const; 74 const UnionDecl * lookupUnion( const std::string & id ) const; 75 UnionDecl * lookupMutableUnion( const std::string & id ) const; 72 76 /// Gets the top-most trait declaration with the given ID 73 TraitDecl *lookupTrait( const std::string &id ) const; 77 const TraitDecl * lookupTrait( const std::string & id ) const; 78 TraitDecl * lookupMutableTrait( const std::string & id ) const; 74 79 75 80 /// Gets the type declaration with the given ID at global scope 76 NamedTypeDecl *globalLookupType( const std::string &id ) const;81 const NamedTypeDecl * globalLookupType( const std::string & id ) const; 77 82 /// Gets the struct declaration with the given ID at global scope 78 StructDecl *globalLookupStruct( const std::string &id ) const;83 const StructDecl * globalLookupStruct( const std::string & id ) const; 79 84 /// Gets the union declaration with the given ID at global scope 80 UnionDecl *globalLookupUnion( const std::string &id ) const;85 const UnionDecl * globalLookupUnion( const std::string & id ) const; 81 86 /// Gets the enum declaration with the given ID at global scope 82 EnumDecl *globalLookupEnum( const std::string &id ) const;87 const EnumDecl * globalLookupEnum( const std::string & id ) const; 83 88 84 89 void addId( DeclarationWithType * decl, Expression * baseExpr = nullptr ); 85 90 void addDeletedId( DeclarationWithType * decl, BaseSyntaxNode * deleteStmt ); 86 91 87 void addType( NamedTypeDecl * decl );88 void addStruct( const std::string & id );89 void addStruct( StructDecl * decl );90 void addEnum( EnumDecl * decl );91 void addUnion( const std::string & id );92 void addUnion( UnionDecl * decl );93 void addTrait( TraitDecl * decl );92 void addType( NamedTypeDecl * decl ); 93 void addStruct( const std::string & id ); 94 void addStruct( StructDecl * decl ); 95 void addEnum( EnumDecl * decl ); 96 void addUnion( const std::string & id ); 97 void addUnion( UnionDecl * decl ); 98 void addTrait( TraitDecl * decl ); 94 99 95 100 /// adds all of the IDs from WithStmt exprs … … 106 111 107 112 private: 108 /// Wraps a Decl * with a scope113 /// Wraps a Decl * with a scope 109 114 template<typename Decl> 110 115 struct Scoped { 111 Decl * decl; ///< declaration116 Decl * decl; ///< declaration 112 117 unsigned long scope; ///< scope of this declaration 113 118 114 Scoped(Decl * d, unsigned long s) : decl(d), scope(s) {}119 Scoped(Decl * d, unsigned long s) : decl(d), scope(s) {} 115 120 }; 116 121 … … 140 145 141 146 /// Gets the indexer at the given scope 142 const Indexer * atScope( unsigned long scope ) const;147 const Indexer * atScope( unsigned long scope ) const; 143 148 144 /// Removes matching autogenerated constructors and destructors so that they will not be 149 /// Removes matching autogenerated constructors and destructors so that they will not be 145 150 /// selected. If returns false, passed decl should not be added. 146 151 bool removeSpecialOverrides( IdData& decl, MangleTable::Ptr& mangleTable ); … … 166 171 /// true if the existing identifier conflicts with the added identifier 167 172 bool addedIdConflicts( 168 const IdData& existing, DeclarationWithType * added, OnConflict handleConflicts, 173 const IdData& existing, DeclarationWithType * added, OnConflict handleConflicts, 169 174 BaseSyntaxNode * deleteStmt ); 170 175 171 176 /// common code for addId, addDeletedId, etc. 172 void addId( 173 DeclarationWithType * decl, OnConflict handleConflicts, 177 void addId( 178 DeclarationWithType * decl, OnConflict handleConflicts, 174 179 Expression * baseExpr = nullptr, BaseSyntaxNode * deleteStmt = nullptr ); 175 180 … … 178 183 179 184 /// returns true if there exists a declaration with C linkage and the given name with the same mangled name 180 bool hasCompatibleCDecl( const std::string & id, const std::string &mangleName ) const;185 bool hasCompatibleCDecl( const std::string & id, const std::string &mangleName ) const; 181 186 /// returns true if there exists a declaration with C linkage and the given name with a different mangled name 182 bool hasIncompatibleCDecl( const std::string & id, const std::string &mangleName ) const;187 bool hasIncompatibleCDecl( const std::string & id, const std::string &mangleName ) const; 183 188 }; 184 189 } // namespace SymTab
Note: See TracChangeset
for help on using the changeset viewer.