Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Specialize.cc

    r62e5546 rb3b2077  
    3636        const std::list<Label> noLabels;
    3737
    38         class Specialize final : public PolyMutator {
     38        class Specialize : public PolyMutator {
    3939          public:
    4040                Specialize( std::string paramPrefix = "_p" );
    4141
    42                 using PolyMutator::mutate;
    43                 virtual Expression * mutate( ApplicationExpr *applicationExpr ) override;
    44                 virtual Expression * mutate( AddressExpr *castExpr ) override;
    45                 virtual Expression * mutate( CastExpr *castExpr ) override;
     42                virtual Expression * mutate( ApplicationExpr *applicationExpr );
     43                virtual Expression * mutate( AddressExpr *castExpr );
     44                virtual Expression * mutate( CastExpr *castExpr );
    4645                // virtual Expression * mutate( LogicalExpr *logicalExpr );
    4746                // virtual Expression * mutate( ConditionalExpr *conditionalExpr );
     
    148147
    149148        Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) {
    150                 assert( ! actual->get_results().empty() ); // using front, should have this assert
    151                 if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) {
     149                assertf( actual->has_result(), "attempting to specialize an untyped expression" );
     150                if ( needsSpecialization( formalType, actual->get_result(), env ) ) {
    152151                        FunctionType *funType;
    153152                        if ( ( funType = getFunctionType( formalType ) ) ) {
     
    172171        void Specialize::handleExplicitParams( ApplicationExpr *appExpr ) {
    173172                // create thunks for the explicit parameters
    174                 assert( ! appExpr->get_function()->get_results().empty() );
    175                 FunctionType *function = getFunctionType( appExpr->get_function()->get_results().front() );
     173                assert( appExpr->get_function()->has_result() );
     174                FunctionType *function = getFunctionType( appExpr->get_function()->get_result() );
    176175                assert( function );
    177176                std::list< DeclarationWithType* >::iterator formal;
     
    201200        Expression * Specialize::mutate( AddressExpr *addrExpr ) {
    202201                addrExpr->get_arg()->acceptMutator( *this );
    203                 assert( ! addrExpr->get_results().empty() );
    204                 addrExpr->set_arg( doSpecialization( addrExpr->get_results().front(), addrExpr->get_arg() ) );
     202                assert( addrExpr->has_result() );
     203                addrExpr->set_arg( doSpecialization( addrExpr->get_result(), addrExpr->get_arg() ) );
    205204                return addrExpr;
    206205        }
     
    208207        Expression * Specialize::mutate( CastExpr *castExpr ) {
    209208                castExpr->get_arg()->acceptMutator( *this );
    210                 if ( castExpr->get_results().empty() ) {
     209                if ( castExpr->get_result()->isVoid() ) {
    211210                        // can't specialize if we don't have a return value
    212211                        return castExpr;
    213212                }
    214                 Expression *specialized = doSpecialization( castExpr->get_results().front(), castExpr->get_arg() );
     213                Expression *specialized = doSpecialization( castExpr->get_result(), castExpr->get_arg() );
    215214                if ( specialized != castExpr->get_arg() ) {
    216215                        // assume here that the specialization incorporates the cast
Note: See TracChangeset for help on using the changeset viewer.