Ignore:
Timestamp:
Dec 5, 2017, 2:35:03 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f9feab8
Parents:
9c35431 (diff), 65197c2 (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.
Message:

Merge branch 'master' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/InstantiateGeneric.cc

    r9c35431 rc13e8dc8  
    453453                        return false;
    454454                }
    455 
    456                 AggregateDecl * getAggr( Type * t ) {
    457                         if ( StructInstType * inst = dynamic_cast< StructInstType * >( t ) ) {
    458                                 return inst->baseStruct;
    459                         } else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( t ) ) {
    460                                 return inst->baseUnion;
    461                         }
    462                         assertf( false, "Non-aggregate type: %s", toString( t ).c_str() );
    463                 }
    464455        }
    465456
     
    469460                if ( isGenericType( memberExpr->aggregate->result ) ) {
    470461                        // find the location of the member
    471                         AggregateDecl * aggr = getAggr( memberExpr->aggregate->result );
     462                        AggregateDecl * aggr = memberExpr->aggregate->result->getAggr();
    472463                        std::list< Declaration * > & members = aggr->members;
    473464                        memberIndex = std::distance( members.begin(), std::find( members.begin(), members.end(), memberExpr->member ) );
     
    479470                if ( memberIndex != -1 ) {
    480471                        // using the location from the generic type, find the member in the instantiation and rebuild the member expression
    481                         AggregateDecl * aggr = getAggr( memberExpr->aggregate->result );
     472                        AggregateDecl * aggr = memberExpr->aggregate->result->getAggr();
    482473                        assertf( memberIndex < (int)aggr->members.size(), "Instantiation somehow has fewer members than the generic type." );
    483474                        Declaration * member = *std::next( aggr->members.begin(), memberIndex );
     
    526517                                        Expression * init = new CastExpr( new AddressExpr( memberExpr ), new PointerType( Type::Qualifiers(), concType->clone() ) );
    527518                                        ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), new ReferenceType( Type::Qualifiers(), concType ), new SingleInit( init ) );
    528                                         stmtsToAddBefore.push_back( new DeclStmt( noLabels, tmp ) );
     519                                        stmtsToAddBefore.push_back( new DeclStmt( tmp ) );
    529520                                        return new VariableExpr( tmp );
    530521                                } else {
Note: See TracChangeset for help on using the changeset viewer.