Changeset 7f6a7c9 for src/Validate/LinkReferenceToTypes.cpp
- Timestamp:
- Sep 21, 2022, 11:02:15 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- 95dab9e
- Parents:
- 428adbc (diff), 0bd46fd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/LinkReferenceToTypes.cpp
r428adbc r7f6a7c9 10 10 // Created On : Thr Apr 21 11:41:00 2022 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jun 28 14:58:00 202213 // Update Count : 112 // Last Modified On : Tue Sep 20 16:17:00 2022 13 // Update Count : 2 14 14 // 15 15 … … 26 26 27 27 struct LinkTypesCore : public WithNoIdSymbolTable, 28 public ast::WithCodeLocation, 28 29 public ast::WithGuards, 29 public ast::WithVisitorRef<LinkTypesCore>, 30 public ast::WithShortCircuiting { 31 30 public ast::WithShortCircuiting, 31 public ast::WithVisitorRef<LinkTypesCore> { 32 32 ast::TypeInstType const * postvisit( ast::TypeInstType const * type ); 33 33 ast::EnumInstType const * postvisit( ast::EnumInstType const * type ); … … 38 38 void postvisit( ast::QualifiedType const * type ); 39 39 40 void previsit( ast::ParseNode const * node );41 42 40 ast::EnumDecl const * postvisit( ast::EnumDecl const * decl ); 43 41 ast::StructDecl const * previsit( ast::StructDecl const * decl ); … … 46 44 void postvisit( ast::UnionDecl const * decl ); 47 45 ast::TraitDecl const * postvisit( ast::TraitDecl const * decl ); 46 ast::QualifiedNameExpr const * previsit( ast::QualifiedNameExpr const * decl); 48 47 49 48 private: … … 59 58 ForwardEnumsType forwardEnums; 60 59 61 const CodeLocation * location = nullptr;62 60 /// true if currently in a generic type body, 63 61 /// so that type parameter instances can be renamed appropriately … … 176 174 // Linking only makes sense for the 'oldest ancestor' of the qualified type. 177 175 type->parent->accept( *visitor ); 178 }179 180 void LinkTypesCore::previsit( ast::ParseNode const * node ) {181 GuardValue( location ) = &node->location;182 176 } 183 177 … … 224 218 GuardValue( inGeneric ) = !decl->params.empty(); 225 219 if ( !inGeneric ) { 226 GuardValue( location ) = &decl->location;227 220 return decl; 228 221 } 229 222 auto mut = ast::mutate( decl ); 230 GuardValue( location ) = &mut->location;231 223 for ( ast::ptr<ast::TypeDecl> & typeDecl : mut->params ) { 232 224 typeDecl.get_and_mutate()->name = "__" + typeDecl->name + "_generic_"; … … 292 284 } 293 285 286 ast::QualifiedNameExpr const * LinkTypesCore::previsit( ast::QualifiedNameExpr const * decl ) { 287 // Try to lookup type 288 if ( auto objDecl = decl->type_decl.as<ast::ObjectDecl>() ) { 289 if ( auto inst = objDecl->type.as<ast::TypeInstType>()) { 290 if ( auto enumDecl = symtab.lookupEnum ( inst->name ) ) { 291 auto mut = ast::mutate( decl ); 292 mut->type_decl = enumDecl; 293 auto enumInst = new ast::EnumInstType( enumDecl ); 294 enumInst->name = decl->name; 295 // Adding result; addCandidate() use result 296 mut->result = enumInst; 297 decl = mut; 298 } 299 } 300 } else if ( auto enumDecl = decl->type_decl.as<ast::EnumDecl>() ) { 301 auto mut = ast::mutate( decl ); 302 auto enumInst = new ast::EnumInstType( enumDecl ); 303 enumInst->name = decl->name; 304 // Adding result; addCandidate() use result 305 mut->result = enumInst; 306 decl = mut; 307 } 308 // ast::EnumDecl const * decl = symtab.lookupEnum( type->name ); 309 // // It's not a semantic error if the enum is not found, just an implicit forward declaration. 310 // if ( decl ) { 311 // // Just linking in the node. 312 // auto mut = ast::mutate( type ); 313 // mut->base = const_cast<ast::EnumDecl *>( decl ); 314 // type = mut; 315 // } 316 return decl; 317 } 318 294 319 } // namespace 295 320
Note:
See TracChangeset
for help on using the changeset viewer.