Changes in src/GenPoly/Specialize.cc [b3b2077:62e5546]
- File:
-
- 1 edited
-
src/GenPoly/Specialize.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Specialize.cc
rb3b2077 r62e5546 36 36 const std::list<Label> noLabels; 37 37 38 class Specialize : public PolyMutator {38 class Specialize final : public PolyMutator { 39 39 public: 40 40 Specialize( std::string paramPrefix = "_p" ); 41 41 42 virtual Expression * mutate( ApplicationExpr *applicationExpr ); 43 virtual Expression * mutate( AddressExpr *castExpr ); 44 virtual Expression * mutate( CastExpr *castExpr ); 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; 45 46 // virtual Expression * mutate( LogicalExpr *logicalExpr ); 46 47 // virtual Expression * mutate( ConditionalExpr *conditionalExpr ); … … 147 148 148 149 Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) { 149 assert f( actual->has_result(), "attempting to specialize an untyped expression" );150 if ( needsSpecialization( formalType, actual->get_result (), env ) ) {150 assert( ! actual->get_results().empty() ); // using front, should have this assert 151 if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) { 151 152 FunctionType *funType; 152 153 if ( ( funType = getFunctionType( formalType ) ) ) { … … 171 172 void Specialize::handleExplicitParams( ApplicationExpr *appExpr ) { 172 173 // create thunks for the explicit parameters 173 assert( appExpr->get_function()->has_result() );174 FunctionType *function = getFunctionType( appExpr->get_function()->get_result () );174 assert( ! appExpr->get_function()->get_results().empty() ); 175 FunctionType *function = getFunctionType( appExpr->get_function()->get_results().front() ); 175 176 assert( function ); 176 177 std::list< DeclarationWithType* >::iterator formal; … … 200 201 Expression * Specialize::mutate( AddressExpr *addrExpr ) { 201 202 addrExpr->get_arg()->acceptMutator( *this ); 202 assert( addrExpr->has_result() );203 addrExpr->set_arg( doSpecialization( addrExpr->get_result (), addrExpr->get_arg() ) );203 assert( ! addrExpr->get_results().empty() ); 204 addrExpr->set_arg( doSpecialization( addrExpr->get_results().front(), addrExpr->get_arg() ) ); 204 205 return addrExpr; 205 206 } … … 207 208 Expression * Specialize::mutate( CastExpr *castExpr ) { 208 209 castExpr->get_arg()->acceptMutator( *this ); 209 if ( castExpr->get_result ()->isVoid() ) {210 if ( castExpr->get_results().empty() ) { 210 211 // can't specialize if we don't have a return value 211 212 return castExpr; 212 213 } 213 Expression *specialized = doSpecialization( castExpr->get_result (), castExpr->get_arg() );214 Expression *specialized = doSpecialization( castExpr->get_results().front(), castExpr->get_arg() ); 214 215 if ( specialized != castExpr->get_arg() ) { 215 216 // assume here that the specialization incorporates the cast
Note:
See TracChangeset
for help on using the changeset viewer.