Changeset 6f096d2 for src/SymTab/Indexer.h
- Timestamp:
- Jul 12, 2019, 4:34:56 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:
- e3d7f9f
- Parents:
- 8fd52e90
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Indexer.h
r8fd52e90 r6f096d2 40 40 41 41 struct IdData { 42 DeclarationWithType * id = nullptr;43 Expression * baseExpr = nullptr; // WithExpr42 const DeclarationWithType * id = nullptr; 43 const Expression * baseExpr = nullptr; // WithExpr 44 44 45 45 /// non-null if this declaration is deleted 46 BaseSyntaxNode * deleteStmt = nullptr;46 const BaseSyntaxNode * deleteStmt = nullptr; 47 47 /// scope of identifier 48 48 unsigned long scope = 0; … … 51 51 IdData() = default; 52 52 IdData( 53 DeclarationWithType * id, Expression * baseExpr,BaseSyntaxNode * deleteStmt,53 const DeclarationWithType * id, const Expression * baseExpr, const BaseSyntaxNode * deleteStmt, 54 54 unsigned long scope ) 55 55 : id( id ), baseExpr( baseExpr ), deleteStmt( deleteStmt ), scope( scope ) {} 56 IdData( const IdData& o, BaseSyntaxNode * deleteStmt )56 IdData( const IdData& o, const BaseSyntaxNode * deleteStmt ) 57 57 : id( o.id ), baseExpr( o.baseExpr ), deleteStmt( deleteStmt ), scope( o.scope ) {} 58 58 … … 82 82 const EnumDecl * globalLookupEnum( const std::string & id ) const; 83 83 84 void addId( DeclarationWithType * decl,Expression * baseExpr = nullptr );85 void addDeletedId( DeclarationWithType * decl,BaseSyntaxNode * deleteStmt );84 void addId( const DeclarationWithType * decl, const Expression * baseExpr = nullptr ); 85 void addDeletedId( const DeclarationWithType * decl, const BaseSyntaxNode * deleteStmt ); 86 86 87 void addType( NamedTypeDecl * decl );87 void addType( const NamedTypeDecl * decl ); 88 88 void addStruct( const std::string & id ); 89 void addStruct( StructDecl * decl );90 void addEnum( EnumDecl * decl );89 void addStruct( const StructDecl * decl ); 90 void addEnum( const EnumDecl * decl ); 91 91 void addUnion( const std::string & id ); 92 void addUnion( UnionDecl * decl );93 void addTrait( TraitDecl * decl );92 void addUnion( const UnionDecl * decl ); 93 void addTrait( const TraitDecl * decl ); 94 94 95 95 /// adds all of the IDs from WithStmt exprs 96 void addWith( std::list< Expression * > & withExprs,BaseSyntaxNode * withStmt );96 void addWith( const std::list< Expression * > & withExprs, const BaseSyntaxNode * withStmt ); 97 97 98 98 /// convenience function for adding a list of Ids to the indexer … … 103 103 104 104 /// convenience function for adding all of the declarations in a function type to the indexer 105 void addFunctionType( FunctionType * ftype );105 void addFunctionType( const FunctionType * ftype ); 106 106 107 107 private: … … 109 109 template<typename Decl> 110 110 struct Scoped { 111 Decl * decl; ///< declaration111 const Decl * decl; ///< declaration 112 112 unsigned long scope; ///< scope of this declaration 113 113 114 Scoped( Decl * d, unsigned long s) : decl(d), scope(s) {}114 Scoped(const Decl * d, unsigned long s) : decl(d), scope(s) {} 115 115 }; 116 116 … … 144 144 /// Removes matching autogenerated constructors and destructors so that they will not be 145 145 /// selected. If returns false, passed decl should not be added. 146 bool removeSpecialOverrides( IdData & decl, MangleTable::Ptr& mangleTable );146 bool removeSpecialOverrides( IdData & decl, MangleTable::Ptr & mangleTable ); 147 147 148 148 /// Options for handling identifier conflicts … … 152 152 Delete ///< Delete the earlier version with the delete statement 153 153 } mode; 154 BaseSyntaxNode * deleteStmt; ///< Statement that deletes this expression154 const BaseSyntaxNode * deleteStmt; ///< Statement that deletes this expression 155 155 156 156 private: 157 157 OnConflict() : mode(Error), deleteStmt(nullptr) {} 158 OnConflict( BaseSyntaxNode * d ) : mode(Delete), deleteStmt(d) {}158 OnConflict( const BaseSyntaxNode * d ) : mode(Delete), deleteStmt(d) {} 159 159 public: 160 160 OnConflict( const OnConflict& ) = default; 161 161 162 162 static OnConflict error() { return {}; } 163 static OnConflict deleteWith( BaseSyntaxNode * d ) { return { d }; }163 static OnConflict deleteWith( const BaseSyntaxNode * d ) { return { d }; } 164 164 }; 165 165 166 166 /// true if the existing identifier conflicts with the added identifier 167 167 bool addedIdConflicts( 168 const IdData & existing,DeclarationWithType * added, OnConflict handleConflicts,169 BaseSyntaxNode * deleteStmt );168 const IdData & existing, const DeclarationWithType * added, OnConflict handleConflicts, 169 const BaseSyntaxNode * deleteStmt ); 170 170 171 171 /// common code for addId, addDeletedId, etc. 172 void addId( 173 DeclarationWithType * decl, OnConflict handleConflicts, 174 Expression * baseExpr = nullptr, BaseSyntaxNode * deleteStmt = nullptr ); 172 void addId(const DeclarationWithType * decl, OnConflict handleConflicts, 173 const Expression * baseExpr = nullptr, const BaseSyntaxNode * deleteStmt = nullptr ); 175 174 176 175 /// adds all of the members of the Aggregate (addWith helper) 177 void addMembers( AggregateDecl * aggr,Expression * expr, OnConflict handleConflicts );176 void addMembers( const AggregateDecl * aggr, const Expression * expr, OnConflict handleConflicts ); 178 177 179 178 /// 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;179 bool hasCompatibleCDecl( const std::string & id, const std::string & mangleName ) const; 181 180 /// 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;181 bool hasIncompatibleCDecl( const std::string & id, const std::string & mangleName ) const; 183 182 }; 184 183 } // namespace SymTab
Note: See TracChangeset
for help on using the changeset viewer.