Changeset 490ff5c3 for src/ResolvExpr
- Timestamp:
- Feb 14, 2018, 1:54:14 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:
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r54c9000 r490ff5c3 1380 1380 void AlternativeFinder::Finder::postvisit( NameExpr *nameExpr ) { 1381 1381 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; ) 1384 1384 for ( auto & data : declList ) { 1385 1385 Expression * newExpr = data.combine(); … … 1402 1402 // not sufficient to clone here, because variable's type may have changed 1403 1403 // 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 ) ); 1405 1405 } 1406 1406 … … 1469 1469 // xxx - resolveTypeof? 1470 1470 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( offsetofExpr->get_type() ) ) { 1471 addOffsetof( structInst, offsetofExpr-> get_member());1471 addOffsetof( structInst, offsetofExpr->member ); 1472 1472 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( offsetofExpr->get_type() ) ) { 1473 addOffsetof( unionInst, offsetofExpr-> get_member());1473 addOffsetof( unionInst, offsetofExpr->member ); 1474 1474 } 1475 1475 } … … 1548 1548 secondFinder.findWithAdjustment( logicalExpr->get_arg2() ); 1549 1549 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 ) { 1552 1552 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 ) ); 1558 1558 } 1559 1559 } … … 1605 1605 AlternativeFinder secondFinder( indexer, newEnv ); 1606 1606 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 ) ); 1609 1609 } // for 1610 1610 delete newFirstArg; … … 1614 1614 // resolve low and high, accept alternatives whose low and high types unify 1615 1615 AlternativeFinder firstFinder( indexer, env ); 1616 firstFinder.findWithAdjustment( rangeExpr-> get_low());1616 firstFinder.findWithAdjustment( rangeExpr->low ); 1617 1617 if ( firstFinder.alternatives.empty() ) return; 1618 1618 AlternativeFinder secondFinder( indexer, env ); 1619 secondFinder.findWithAdjustment( rangeExpr-> get_high());1619 secondFinder.findWithAdjustment( rangeExpr->high ); 1620 1620 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 ) { 1623 1623 TypeEnvironment compositeEnv; 1624 compositeEnv.simpleCombine( first ->env );1625 compositeEnv.simpleCombine( second ->env );1624 compositeEnv.simpleCombine( first.env ); 1625 compositeEnv.simpleCombine( second.env ); 1626 1626 OpenVarSet openVars; 1627 1627 AssertionSet needAssertions, haveAssertions; 1628 Alternative newAlt( 0, compositeEnv, first ->cost + second->cost );1628 Alternative newAlt( 0, compositeEnv, first.cost + second.cost ); 1629 1629 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(); 1633 1633 newAlt.expr = newExpr; 1634 1634 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) );
Note: See TracChangeset
for help on using the changeset viewer.