Changeset c7a3081


Ignore:
Timestamp:
May 18, 2017, 4:58:08 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
8905f56
Parents:
02153feb
Message:

only bind generic parameters in TypeSubstitution? in freeOnly mode, fix generic instantiation order [fixes #6]

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/InstantiateGeneric.cc

    r02153feb rc7a3081  
    367367                                concDecl->set_body( inst->get_baseStruct()->has_body() );
    368368                                substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );
    369                                 DeclMutator::addDeclaration( concDecl );
    370                                 insert( inst, typeSubs, concDecl );
     369                                insert( inst, typeSubs, concDecl ); // must insert before recursion
    371370                                concDecl->acceptMutator( *this ); // recursively instantiate members
     371                                DeclMutator::addDeclaration( concDecl ); // must occur before declaration is added so that member instantiations appear first
    372372                        }
    373373                        StructInstType *newInst = new StructInstType( inst->get_qualifiers(), concDecl->get_name() );
     
    422422                                concDecl->set_body( inst->get_baseUnion()->has_body() );
    423423                                substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );
    424                                 DeclMutator::addDeclaration( concDecl );
    425                                 insert( inst, typeSubs, concDecl );
     424                                insert( inst, typeSubs, concDecl ); // must insert before recursion
    426425                                concDecl->acceptMutator( *this ); // recursively instantiate members
     426                                DeclMutator::addDeclaration( concDecl ); // must occur before declaration is added so that member instantiations appear first
    427427                        }
    428428                        UnionInstType *newInst = new UnionInstType( inst->get_qualifiers(), concDecl->get_name() );
  • src/SynTree/TypeSubstitution.cc

    r02153feb rc7a3081  
    166166                        boundVars.insert( (*tyvar )->get_name() );
    167167                } // for
    168         } // if
    169         // bind type variables from generic type instantiations
    170         std::list< TypeDecl* > *baseParameters = type->get_baseParameters();
    171         if ( baseParameters && ! type->get_parameters().empty() ) {
    172                 for ( std::list< TypeDecl* >::const_iterator tyvar = baseParameters->begin(); tyvar != baseParameters->end(); ++tyvar ) {
    173                         boundVars.insert( (*tyvar)->get_name() );
    174                 } // for
     168                // bind type variables from generic type instantiations
     169                std::list< TypeDecl* > *baseParameters = type->get_baseParameters();
     170                if ( baseParameters && ! type->get_parameters().empty() ) {
     171                        for ( std::list< TypeDecl* >::const_iterator tyvar = baseParameters->begin(); tyvar != baseParameters->end(); ++tyvar ) {
     172                                boundVars.insert( (*tyvar)->get_name() );
     173                        } // for
     174                } // if
    175175        } // if
    176176        Type *ret = Mutator::mutate( type );
Note: See TracChangeset for help on using the changeset viewer.