Changeset 994028dc for src/GenPoly
- Timestamp:
- Oct 31, 2022, 2:17:21 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- f2ff0a6
- Parents:
- e3bf4cf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
re3bf4cf r994028dc 622 622 623 623 void Pass1::replaceParametersWithConcrete( ApplicationExpr *appExpr, std::list< Expression* >& params ) { 624 for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param) {625 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param );624 for ( Expression * const param : params ) { 625 TypeExpr *paramType = dynamic_cast< TypeExpr* >( param ); 626 626 assertf(paramType, "Aggregate parameters should be type expressions"); 627 627 paramType->set_type( replaceWithConcrete( appExpr, paramType->get_type(), false ) ); … … 742 742 743 743 void Pass1::boxParams( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) { 744 for ( std::list< DeclarationWithType *>::const_iterator param = function->get_parameters().begin(); param != function->parameters.end(); ++param, ++arg ) { 745 assertf( arg != appExpr->args.end(), "boxParams: missing argument for param %s to %s in %s", toString( *param ).c_str(), toString( function ).c_str(), toString( appExpr ).c_str() ); 746 addCast( *arg, (*param)->get_type(), exprTyVars ); 747 boxParam( (*param)->get_type(), *arg, exprTyVars ); 744 for ( DeclarationWithType * param : function->parameters ) { 745 assertf( arg != appExpr->args.end(), "boxParams: missing argument for param %s to %s in %s", toString( param ).c_str(), toString( function ).c_str(), toString( appExpr ).c_str() ); 746 addCast( *arg, param->get_type(), exprTyVars ); 747 boxParam( param->get_type(), *arg, exprTyVars ); 748 ++arg; 748 749 } // for 749 750 } … … 751 752 void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) { 752 753 std::list< Expression *>::iterator cur = arg; 753 for ( Type ::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar) {754 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->assertions.begin(); assert != (*tyVar)->assertions.end(); ++assert) {755 InferredParams::const_iterator inferParam = appExpr->inferParams.find( (*assert)->get_uniqueId() );756 assertf( inferParam != appExpr->inferParams.end(), "addInferredParams missing inferred parameter: %s in: %s", toString( *assert ).c_str(), toString( appExpr ).c_str() );754 for ( TypeDecl * const tyVar : functionType->forall ) { 755 for ( DeclarationWithType * const assert : tyVar->assertions ) { 756 InferredParams::const_iterator inferParam = appExpr->inferParams.find( assert->get_uniqueId() ); 757 assertf( inferParam != appExpr->inferParams.end(), "addInferredParams missing inferred parameter: %s in: %s", toString( assert ).c_str(), toString( appExpr ).c_str() ); 757 758 Expression *newExpr = inferParam->second.expr->clone(); 758 addCast( newExpr, (*assert)->get_type(), tyVars );759 boxParam( (*assert)->get_type(), newExpr, tyVars );759 addCast( newExpr, assert->get_type(), tyVars ); 760 boxParam( assert->get_type(), newExpr, tyVars ); 760 761 appExpr->get_args().insert( cur, newExpr ); 761 762 } // for … … 1210 1211 std::list< DeclarationWithType *> ¶mList = functionType->parameters; 1211 1212 std::list< FunctionType *> functions; 1212 for ( 1213 for ( DeclarationWithType * const arg : functionType->parameters ) { 1213 1214 Type *orig = arg->get_type(); 1214 1215 findAndReplaceFunction( orig, functions, scopeTyVars, needsAdapter );
Note: See TracChangeset
for help on using the changeset viewer.