- File:
-
- 1 edited
-
src/GenPoly/InstantiateGeneric.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/InstantiateGeneric.cc
r1c1395d r02fdb8e 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu Aug 04 18:33:00 2016 11 // Last Modified By : A ndrew Beach12 // Last Modified On : Wed Jul 16 10:17:00 202013 // Update Count : 211 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Thu Aug 04 18:33:00 2016 13 // Update Count : 1 14 14 // 15 15 #include "InstantiateGeneric.h" … … 172 172 InstantiationMap< AggregateDecl, AggregateDecl > instantiations; 173 173 /// Set of types which are dtype-only generic (and therefore have static layout) 174 std::set<AggregateDecl *> dtypeStatics;174 ScopedSet< AggregateDecl* > dtypeStatics; 175 175 /// Namer for concrete types 176 176 UniqueName typeNamer; … … 297 297 } 298 298 299 template< typename AggrInst >300 static AggrInst * asForward( AggrInst * decl ) {301 if ( !decl->body ) {302 return nullptr;303 }304 decl = decl->clone();305 decl->body = false;306 deleteAll( decl->members );307 decl->members.clear();308 return decl;309 }310 311 299 void GenericInstantiator::stripDtypeParams( AggregateDecl *base, std::list< TypeDecl* >& baseParams, const std::list< TypeExpr* >& typeSubs ) { 312 300 substituteMembers( base->get_members(), baseParams, typeSubs ); … … 385 373 concDecl->set_body( inst->get_baseStruct()->has_body() ); 386 374 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 387 // Forward declare before recursion. (TODO: Only when needed, #199.) 388 insert( inst, typeSubs, concDecl ); 389 if ( StructDecl *forwardDecl = asForward( concDecl ) ) { 390 declsToAddBefore.push_back( forwardDecl ); 391 } 375 insert( inst, typeSubs, concDecl ); // must insert before recursion 392 376 concDecl->acceptMutator( *visitor ); // recursively instantiate members 393 377 declsToAddBefore.push_back( concDecl ); // must occur before declaration is added so that member instantiations appear first … … 439 423 concDecl->set_body( inst->get_baseUnion()->has_body() ); 440 424 substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 441 // Forward declare before recursion. (TODO: Only when needed, #199.) 442 insert( inst, typeSubs, concDecl ); 443 if ( UnionDecl *forwardDecl = asForward( concDecl ) ) { 444 declsToAddBefore.push_back( forwardDecl ); 445 } 425 insert( inst, typeSubs, concDecl ); // must insert before recursion 446 426 concDecl->acceptMutator( *visitor ); // recursively instantiate members 447 427 declsToAddBefore.push_back( concDecl ); // must occur before declaration is added so that member instantiations appear first … … 505 485 void GenericInstantiator::beginScope() { 506 486 instantiations.beginScope(); 487 dtypeStatics.beginScope(); 507 488 } 508 489 509 490 void GenericInstantiator::endScope() { 510 491 instantiations.endScope(); 492 dtypeStatics.endScope(); 511 493 } 512 494
Note:
See TracChangeset
for help on using the changeset viewer.