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