Changeset 490ff5c3 for src/ResolvExpr


Ignore:
Timestamp:
Feb 14, 2018, 1:54:14 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
44b4114
Parents:
54c9000
git-author:
Rob Schluntz <rschlunt@…> (02/14/18 12:00:25)
git-committer:
Rob Schluntz <rschlunt@…> (02/14/18 13:54:14)
Message:

Minor code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r54c9000 r490ff5c3  
    13801380        void AlternativeFinder::Finder::postvisit( NameExpr *nameExpr ) {
    13811381                std::list< SymTab::Indexer::IdData > declList;
    1382                 indexer.lookupId( nameExpr->get_name(), declList );
    1383                 PRINT( std::cerr << "nameExpr is " << nameExpr->get_name() << std::endl; )
     1382                indexer.lookupId( nameExpr->name, declList );
     1383                PRINT( std::cerr << "nameExpr is " << nameExpr->name << std::endl; )
    13841384                for ( auto & data : declList ) {
    13851385                        Expression * newExpr = data.combine();
     
    14021402                // not sufficient to clone here, because variable's type may have changed
    14031403                // since the VariableExpr was originally created.
    1404                 alternatives.push_back( Alternative( new VariableExpr( variableExpr->get_var() ), env, Cost::zero ) );
     1404                alternatives.push_back( Alternative( new VariableExpr( variableExpr->var ), env, Cost::zero ) );
    14051405        }
    14061406
     
    14691469                // xxx - resolveTypeof?
    14701470                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( offsetofExpr->get_type() ) ) {
    1471                         addOffsetof( structInst, offsetofExpr->get_member() );
     1471                        addOffsetof( structInst, offsetofExpr->member );
    14721472                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( offsetofExpr->get_type() ) ) {
    1473                         addOffsetof( unionInst, offsetofExpr->get_member() );
     1473                        addOffsetof( unionInst, offsetofExpr->member );
    14741474                }
    14751475        }
     
    15481548                secondFinder.findWithAdjustment( logicalExpr->get_arg2() );
    15491549                if ( secondFinder.alternatives.empty() ) return;
    1550                 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) {
    1551                         for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) {
     1550                for ( const Alternative & first : firstFinder.alternatives ) {
     1551                        for ( const Alternative & second : secondFinder.alternatives ) {
    15521552                                TypeEnvironment compositeEnv;
    1553                                 compositeEnv.simpleCombine( first->env );
    1554                                 compositeEnv.simpleCombine( second->env );
    1555 
    1556                                 LogicalExpr *newExpr = new LogicalExpr( first->expr->clone(), second->expr->clone(), logicalExpr->get_isAnd() );
    1557                                 alternatives.push_back( Alternative( newExpr, compositeEnv, first->cost + second->cost ) );
     1553                                compositeEnv.simpleCombine( first.env );
     1554                                compositeEnv.simpleCombine( second.env );
     1555
     1556                                LogicalExpr *newExpr = new LogicalExpr( first.expr->clone(), second.expr->clone(), logicalExpr->get_isAnd() );
     1557                                alternatives.push_back( Alternative( newExpr, compositeEnv, first.cost + second.cost ) );
    15581558                        }
    15591559                }
     
    16051605                AlternativeFinder secondFinder( indexer, newEnv );
    16061606                secondFinder.findWithAdjustment( commaExpr->get_arg2() );
    1607                 for ( AltList::const_iterator alt = secondFinder.alternatives.begin(); alt != secondFinder.alternatives.end(); ++alt ) {
    1608                         alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt->expr->clone() ), alt->env, alt->cost ) );
     1607                for ( const Alternative & alt : secondFinder.alternatives ) {
     1608                        alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt.expr->clone() ), alt.env, alt.cost ) );
    16091609                } // for
    16101610                delete newFirstArg;
     
    16141614                // resolve low and high, accept alternatives whose low and high types unify
    16151615                AlternativeFinder firstFinder( indexer, env );
    1616                 firstFinder.findWithAdjustment( rangeExpr->get_low() );
     1616                firstFinder.findWithAdjustment( rangeExpr->low );
    16171617                if ( firstFinder.alternatives.empty() ) return;
    16181618                AlternativeFinder secondFinder( indexer, env );
    1619                 secondFinder.findWithAdjustment( rangeExpr->get_high() );
     1619                secondFinder.findWithAdjustment( rangeExpr->high );
    16201620                if ( secondFinder.alternatives.empty() ) return;
    1621                 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) {
    1622                         for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) {
     1621                for ( const Alternative & first : firstFinder.alternatives ) {
     1622                        for ( const Alternative & second : secondFinder.alternatives ) {
    16231623                                TypeEnvironment compositeEnv;
    1624                                 compositeEnv.simpleCombine( first->env );
    1625                                 compositeEnv.simpleCombine( second->env );
     1624                                compositeEnv.simpleCombine( first.env );
     1625                                compositeEnv.simpleCombine( second.env );
    16261626                                OpenVarSet openVars;
    16271627                                AssertionSet needAssertions, haveAssertions;
    1628                                 Alternative newAlt( 0, compositeEnv, first->cost + second->cost );
     1628                                Alternative newAlt( 0, compositeEnv, first.cost + second.cost );
    16291629                                Type* commonType = nullptr;
    1630                                 if ( unify( first->expr->get_result(), second->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
    1631                                         RangeExpr *newExpr = new RangeExpr( first->expr->clone(), second->expr->clone() );
    1632                                         newExpr->set_result( commonType ? commonType : first->expr->get_result()->clone() );
     1630                                if ( unify( first.expr->result, second.expr->result, newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
     1631                                        RangeExpr * newExpr = new RangeExpr( first.expr->clone(), second.expr->clone() );
     1632                                        newExpr->result = commonType ? commonType : first.expr->result->clone();
    16331633                                        newAlt.expr = newExpr;
    16341634                                        inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) );
Note: See TracChangeset for help on using the changeset viewer.