Changeset bb666f64 for src/GenPoly
- Timestamp:
- Oct 25, 2017, 4:25:20 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 13a6154
- Parents:
- 68195a6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Specialize.cc
r68195a6 rbb666f64 45 45 struct Specialize final : public WithTypeSubstitution, public WithStmtsToAdd, public WithVisitorRef<Specialize> { 46 46 Expression * postmutate( ApplicationExpr *applicationExpr ); 47 Expression * postmutate( AddressExpr *castExpr );48 47 Expression * postmutate( CastExpr *castExpr ); 49 48 50 49 void handleExplicitParams( ApplicationExpr *appExpr ); 51 50 Expression * createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ); 52 Expression * doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams = nullptr);51 Expression * doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ); 53 52 54 53 std::string paramPrefix = "_p"; … … 131 130 if ( functionParameterSize( fftype ) != functionParameterSize( aftype ) ) return false; 132 131 // tuple-parameter sizes are the same, but actual parameter sizes differ - must tuple specialize 133 if ( fftype-> get_parameters().size() != aftype->get_parameters().size() ) return true;132 if ( fftype->parameters.size() != aftype->parameters.size() ) return true; 134 133 // total parameter size can be the same, while individual parameters can have different structure 135 for ( auto params : group_iterate( fftype-> get_parameters(), aftype->get_parameters()) ) {134 for ( auto params : group_iterate( fftype->parameters, aftype->parameters ) ) { 136 135 DeclarationWithType * formal = std::get<0>(params); 137 136 DeclarationWithType * actual = std::get<1>(params); … … 150 149 if ( needsSpecialization( formalType, actual->get_result(), env ) ) { 151 150 if ( FunctionType *funType = getFunctionType( formalType ) ) { 152 ApplicationExpr *appExpr; 153 VariableExpr *varExpr; 154 if ( ( appExpr = dynamic_cast<ApplicationExpr*>( actual ) ) ) { 151 if ( ApplicationExpr * appExpr = dynamic_cast<ApplicationExpr*>( actual ) ) { 155 152 return createThunkFunction( funType, appExpr->get_function(), inferParams ); 156 } else if ( ( varExpr = dynamic_cast<VariableExpr*>( actual )) ) {153 } else if ( VariableExpr * varExpr = dynamic_cast<VariableExpr*>( actual ) ) { 157 154 return createThunkFunction( funType, varExpr, inferParams ); 158 155 } else { … … 323 320 } 324 321 325 Expression * Specialize::postmutate( AddressExpr *addrExpr ) {326 assert( addrExpr->result );327 addrExpr->set_arg( doSpecialization( addrExpr->result, addrExpr->arg ) );328 return addrExpr;329 }330 331 322 Expression * Specialize::postmutate( CastExpr *castExpr ) { 332 323 if ( castExpr->result->isVoid() ) { … … 334 325 return castExpr; 335 326 } 336 Expression *specialized = doSpecialization( castExpr->result, castExpr->arg );327 Expression *specialized = doSpecialization( castExpr->result, castExpr->arg, &castExpr->inferParams ); 337 328 if ( specialized != castExpr->arg ) { 338 329 // assume here that the specialization incorporates the cast
Note: See TracChangeset
for help on using the changeset viewer.