Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/InstantiateGeneric.cc

    r1c1395d r02fdb8e  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu Aug 04 18:33:00 2016
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 16 10:17:00 2020
    13 // Update Count     : 2
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Thu Aug 04 18:33:00 2016
     13// Update Count     : 1
    1414//
    1515#include "InstantiateGeneric.h"
     
    172172                InstantiationMap< AggregateDecl, AggregateDecl > instantiations;
    173173                /// Set of types which are dtype-only generic (and therefore have static layout)
    174                 std::set<AggregateDecl *> dtypeStatics;
     174                ScopedSet< AggregateDecl* > dtypeStatics;
    175175                /// Namer for concrete types
    176176                UniqueName typeNamer;
     
    297297        }
    298298
    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 
    311299        void GenericInstantiator::stripDtypeParams( AggregateDecl *base, std::list< TypeDecl* >& baseParams, const std::list< TypeExpr* >& typeSubs ) {
    312300                substituteMembers( base->get_members(), baseParams, typeSubs );
     
    385373                                concDecl->set_body( inst->get_baseStruct()->has_body() );
    386374                                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
    392376                                concDecl->acceptMutator( *visitor ); // recursively instantiate members
    393377                                declsToAddBefore.push_back( concDecl ); // must occur before declaration is added so that member instantiations appear first
     
    439423                                concDecl->set_body( inst->get_baseUnion()->has_body() );
    440424                                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
    446426                                concDecl->acceptMutator( *visitor ); // recursively instantiate members
    447427                                declsToAddBefore.push_back( concDecl ); // must occur before declaration is added so that member instantiations appear first
     
    505485        void GenericInstantiator::beginScope() {
    506486                instantiations.beginScope();
     487                dtypeStatics.beginScope();
    507488        }
    508489
    509490        void GenericInstantiator::endScope() {
    510491                instantiations.endScope();
     492                dtypeStatics.endScope();
    511493        }
    512494
Note: See TracChangeset for help on using the changeset viewer.