Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/InstantiateGeneric.cc

    r373d0b5 r4e7a4e6  
    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                }
    455464        }
    456465
     
    460469                if ( isGenericType( memberExpr->aggregate->result ) ) {
    461470                        // find the location of the member
    462                         AggregateDecl * aggr = memberExpr->aggregate->result->getAggr();
     471                        AggregateDecl * aggr = getAggr( memberExpr->aggregate->result );
    463472                        std::list< Declaration * > & members = aggr->members;
    464473                        memberIndex = std::distance( members.begin(), std::find( members.begin(), members.end(), memberExpr->member ) );
     
    470479                if ( memberIndex != -1 ) {
    471480                        // using the location from the generic type, find the member in the instantiation and rebuild the member expression
    472                         AggregateDecl * aggr = memberExpr->aggregate->result->getAggr();
     481                        AggregateDecl * aggr = getAggr( memberExpr->aggregate->result );
    473482                        assertf( memberIndex < (int)aggr->members.size(), "Instantiation somehow has fewer members than the generic type." );
    474483                        Declaration * member = *std::next( aggr->members.begin(), memberIndex );
Note: See TracChangeset for help on using the changeset viewer.