Changeset 624b722


Ignore:
Timestamp:
Feb 1, 2018, 4:33:17 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
33c0ce8
Parents:
0992849
Message:

Minor code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r0992849 r624b722  
    15631563                // find alternatives for condition
    15641564                AlternativeFinder firstFinder( indexer, env );
    1565                 firstFinder.findWithAdjustment( conditionalExpr->get_arg1() );
     1565                firstFinder.findWithAdjustment( conditionalExpr->arg1 );
    15661566                if ( firstFinder.alternatives.empty() ) return;
    15671567                // find alternatives for true expression
    15681568                AlternativeFinder secondFinder( indexer, env );
    1569                 secondFinder.findWithAdjustment( conditionalExpr->get_arg2() );
     1569                secondFinder.findWithAdjustment( conditionalExpr->arg2 );
    15701570                if ( secondFinder.alternatives.empty() ) return;
    15711571                // find alterantives for false expression
    15721572                AlternativeFinder thirdFinder( indexer, env );
    1573                 thirdFinder.findWithAdjustment( conditionalExpr->get_arg3() );
     1573                thirdFinder.findWithAdjustment( conditionalExpr->arg3 );
    15741574                if ( thirdFinder.alternatives.empty() ) return;
    1575                 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) {
    1576                         for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) {
    1577                                 for ( AltList::const_iterator third = thirdFinder.alternatives.begin(); third != thirdFinder.alternatives.end(); ++third ) {
     1575                for ( const Alternative & first : firstFinder.alternatives ) {
     1576                        for ( const Alternative & second : secondFinder.alternatives ) {
     1577                                for ( const Alternative & third : thirdFinder.alternatives ) {
    15781578                                        TypeEnvironment compositeEnv;
    1579                                         compositeEnv.simpleCombine( first->env );
    1580                                         compositeEnv.simpleCombine( second->env );
    1581                                         compositeEnv.simpleCombine( third->env );
     1579                                        compositeEnv.simpleCombine( first.env );
     1580                                        compositeEnv.simpleCombine( second.env );
     1581                                        compositeEnv.simpleCombine( third.env );
    15821582
    15831583                                        // unify true and false types, then infer parameters to produce new alternatives
    15841584                                        OpenVarSet openVars;
    15851585                                        AssertionSet needAssertions, haveAssertions;
    1586                                         Alternative newAlt( 0, compositeEnv, first->cost + second->cost + third->cost );
     1586                                        Alternative newAlt( 0, compositeEnv, first.cost + second.cost + third.cost );
    15871587                                        Type* commonType = nullptr;
    1588                                         if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
    1589                                                 ConditionalExpr *newExpr = new ConditionalExpr( first->expr->clone(), second->expr->clone(), third->expr->clone() );
    1590                                                 newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() );
     1588                                        if ( unify( second.expr->result, third.expr->result, newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
     1589                                                ConditionalExpr *newExpr = new ConditionalExpr( first.expr->clone(), second.expr->clone(), third.expr->clone() );
     1590                                                newExpr->result = commonType ? commonType : second.expr->result->clone();
    15911591                                                // convert both options to the conditional result type
    15921592                                                newAlt.cost += computeExpressionConversionCost( newExpr->arg2, newExpr->result, indexer, newAlt.env );
Note: See TracChangeset for help on using the changeset viewer.