Changeset 994028dc


Ignore:
Timestamp:
Oct 31, 2022, 2:17:21 PM (18 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
f2ff0a6
Parents:
e3bf4cf
Message:

Cleaning old box pass for easier translation. Clean-up more loops.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    re3bf4cf r994028dc  
    622622
    623623                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 );
    626626                                assertf(paramType, "Aggregate parameters should be type expressions");
    627627                                paramType->set_type( replaceWithConcrete( appExpr, paramType->get_type(), false ) );
     
    742742
    743743                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;
    748749                        } // for
    749750                }
     
    751752                void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) {
    752753                        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() );
    757758                                        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 );
    760761                                        appExpr->get_args().insert( cur, newExpr );
    761762                                } // for
     
    12101211                        std::list< DeclarationWithType *> &paramList = functionType->parameters;
    12111212                        std::list< FunctionType *> functions;
    1212                         for (  DeclarationWithType * const arg : functionType->parameters ) {
     1213                        for ( DeclarationWithType * const arg : functionType->parameters ) {
    12131214                                Type *orig = arg->get_type();
    12141215                                findAndReplaceFunction( orig, functions, scopeTyVars, needsAdapter );
Note: See TracChangeset for help on using the changeset viewer.