Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r5de1e2c rd807ca28  
    299299                // it's okay for the aggregate expression to have reference type -- cast it to the base type to treat the aggregate as the referenced value
    300300                std::unique_ptr<Expression> aggrExpr( alt.expr->clone() );
    301                 alt.env.apply( aggrExpr->result );
    302                 Type * aggrType = aggrExpr->result;
     301                alt.env.apply( aggrExpr->get_result() );
     302                Type * aggrType = aggrExpr->get_result();
    303303                if ( dynamic_cast< ReferenceType * >( aggrType ) ) {
    304304                        aggrType = aggrType->stripReferences();
     
    306306                }
    307307
    308                 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->result ) ) {
     308                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->get_result() ) ) {
    309309                        NameExpr nameExpr( "" );
    310310                        addAggMembers( structInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
    311                 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->result ) ) {
     311                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->get_result() ) ) {
    312312                        NameExpr nameExpr( "" );
    313313                        addAggMembers( unionInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
     
    320320                NameExpr * nameExpr = dynamic_cast< NameExpr * >( member );
    321321                if ( ! nameExpr ) return;
    322                 const std::string & name = nameExpr->name;
     322                const std::string & name = nameExpr->get_name();
    323323                std::list< Declaration* > members;
    324324                aggInst->lookup( name, members );
    325325
    326                 for ( Declaration * decl : members ) {
    327                         if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( decl ) ) {
    328                                 // addAnonAlternatives uses vector::push_back, which invalidates references to existing elements, so
    329                                 // can't construct in place and use vector::back
    330                                 Alternative newAlt( new MemberExpr( dwt, expr->clone() ), env, newCost );
    331                                 renameTypes( newAlt.expr );
    332                                 addAnonConversions( newAlt ); // add anonymous member interpretations whenever an aggregate value type is seen as a member expression.
    333                                 alternatives.push_back( std::move(newAlt) );
     326                for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) {
     327                        if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( *i ) ) {
     328                                alternatives.push_back( Alternative( new MemberExpr( dwt, expr->clone() ), env, newCost ) );
     329                                renameTypes( alternatives.back().expr );
     330                                addAnonConversions( alternatives.back() ); // add anonymous member interpretations whenever an aggregate value type is seen as a member expression.
    334331                        } else {
    335332                                assert( false );
     
    13821379                        Cost cost = Cost::zero;
    13831380                        Expression * newExpr = data.combine( cost );
    1384 
    1385                         // addAnonAlternatives uses vector::push_back, which invalidates references to existing elements, so
    1386                         // can't construct in place and use vector::back
    1387                         Alternative newAlt( newExpr, env, Cost::zero, cost );
     1381                        alternatives.push_back( Alternative( newExpr, env, Cost::zero, cost ) );
    13881382                        PRINT(
    13891383                                std::cerr << "decl is ";
     
    13941388                                std::cerr << std::endl;
    13951389                        )
    1396                         renameTypes( newAlt.expr );
    1397                         addAnonConversions( newAlt ); // add anonymous member interpretations whenever an aggregate value type is seen as a name expression.
    1398                         alternatives.push_back( std::move(newAlt) );
     1390                        renameTypes( alternatives.back().expr );
     1391                        addAnonConversions( alternatives.back() ); // add anonymous member interpretations whenever an aggregate value type is seen as a name expression.
    13991392                } // for
    14001393        }
Note: See TracChangeset for help on using the changeset viewer.