Changeset 8a1289f
- Timestamp:
- May 30, 2018, 3:28:10 PM (7 years ago)
- Branches:
- new-env, with_gc
- Children:
- 75308bcc
- Parents:
- 80a7d48
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r80a7d48 r8a1289f 338 338 if ( ss >> val && ! (ss >> tmp) ) { 339 339 if ( val >= 0 && (unsigned int)val < tupleType->size() ) { 340 alternatives.push_back( Alternative( new TupleIndexExpr( expr ->clone(), val ), env, newCost ) );340 alternatives.push_back( Alternative( new TupleIndexExpr( expr, val ), env, newCost ) ); 341 341 } // if 342 342 } // if … … 347 347 int val; 348 348 ss >> val; 349 alternatives.push_back( Alternative( new TupleIndexExpr( expr ->clone(), val ), env, newCost ) );349 alternatives.push_back( Alternative( new TupleIndexExpr( expr, val ), env, newCost ) ); 350 350 } 351 351 } // if … … 353 353 354 354 void AlternativeFinder::Finder::postvisit( ApplicationExpr *applicationExpr ) { 355 alternatives.push_back( Alternative( applicationExpr ->clone(), env, Cost::zero ) );355 alternatives.push_back( Alternative( applicationExpr, env, Cost::zero ) ); 356 356 } 357 357 … … 664 664 while ( pack->tupleStart == 0 ) { 665 665 pack = &packs[pack->parent]; 666 exprs.push_front( pack->expr ->clone());666 exprs.push_front( pack->expr ); 667 667 cost += pack->cost; 668 668 } … … 749 749 newResult.cost = results[i].cost; 750 750 newResult.tupleStart = results[i].tupleStart; 751 newResult.expr = results[i].expr ->clone();751 newResult.expr = results[i].expr; 752 752 argType = newResult.expr->get_result(); 753 753 … … 1219 1219 if ( isLvalue( alt.expr ) ) { 1220 1220 alternatives.push_back( 1221 Alternative{ new AddressExpr( alt.expr ->clone()), alt.env, alt.cost } );1221 Alternative{ new AddressExpr( alt.expr ), alt.env, alt.cost } ); 1222 1222 } // if 1223 1223 } // for … … 1225 1225 1226 1226 void AlternativeFinder::Finder::postvisit( LabelAddressExpr * expr ) { 1227 alternatives.push_back( Alternative{ expr ->clone(), env, Cost::zero } );1227 alternatives.push_back( Alternative{ expr, env, Cost::zero } ); 1228 1228 } 1229 1229 … … 1320 1320 for ( Alternative & alt : finder.alternatives ) { 1321 1321 alternatives.push_back( Alternative( 1322 new VirtualCastExpr( alt.expr ->clone(), castExpr->get_result()->clone() ),1322 new VirtualCastExpr( alt.expr, castExpr->get_result()->clone() ), 1323 1323 alt.env, alt.cost ) ); 1324 1324 } … … 1355 1355 1356 1356 void AlternativeFinder::Finder::postvisit( MemberExpr *memberExpr ) { 1357 alternatives.push_back( Alternative( memberExpr ->clone(), env, Cost::zero ) );1357 alternatives.push_back( Alternative( memberExpr, env, Cost::zero ) ); 1358 1358 } 1359 1359 … … 1386 1386 1387 1387 void AlternativeFinder::Finder::postvisit( ConstantExpr *constantExpr ) { 1388 alternatives.push_back( Alternative( constantExpr ->clone(), env, Cost::zero ) );1388 alternatives.push_back( Alternative( constantExpr, env, Cost::zero ) ); 1389 1389 } 1390 1390 … … 1406 1406 Alternative &choice = winners.front(); 1407 1407 referenceToRvalueConversion( choice.expr, choice.cost ); 1408 alternatives.push_back( Alternative( new SizeofExpr( choice.expr ->clone()), choice.env, Cost::zero ) );1408 alternatives.push_back( Alternative( new SizeofExpr( choice.expr ), choice.env, Cost::zero ) ); 1409 1409 } // if 1410 1410 } … … 1427 1427 Alternative &choice = winners.front(); 1428 1428 referenceToRvalueConversion( choice.expr, choice.cost ); 1429 alternatives.push_back( Alternative( new AlignofExpr( choice.expr ->clone()), choice.env, Cost::zero ) );1429 alternatives.push_back( Alternative( new AlignofExpr( choice.expr ), choice.env, Cost::zero ) ); 1430 1430 } // if 1431 1431 } … … 1456 1456 1457 1457 void AlternativeFinder::Finder::postvisit( OffsetofExpr *offsetofExpr ) { 1458 alternatives.push_back( Alternative( offsetofExpr ->clone(), env, Cost::zero ) );1458 alternatives.push_back( Alternative( offsetofExpr, env, Cost::zero ) ); 1459 1459 } 1460 1460 1461 1461 void AlternativeFinder::Finder::postvisit( OffsetPackExpr *offsetPackExpr ) { 1462 alternatives.push_back( Alternative( offsetPackExpr ->clone(), env, Cost::zero ) );1462 alternatives.push_back( Alternative( offsetPackExpr, env, Cost::zero ) ); 1463 1463 } 1464 1464 … … 1538 1538 compositeEnv.simpleCombine( second.env ); 1539 1539 1540 LogicalExpr *newExpr = new LogicalExpr( first.expr ->clone(), second.expr->clone(), logicalExpr->get_isAnd() );1540 LogicalExpr *newExpr = new LogicalExpr( first.expr, second.expr, logicalExpr->get_isAnd() ); 1541 1541 alternatives.push_back( Alternative( newExpr, compositeEnv, first.cost + second.cost ) ); 1542 1542 } … … 1571 1571 Type* commonType = nullptr; 1572 1572 if ( unify( second.expr->result, third.expr->result, newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 1573 ConditionalExpr *newExpr = new ConditionalExpr( first.expr ->clone(), second.expr->clone(), third.expr->clone());1573 ConditionalExpr *newExpr = new ConditionalExpr( first.expr, second.expr, third.expr ); 1574 1574 newExpr->result = commonType ? commonType : second.expr->result->clone(); 1575 1575 // convert both options to the conditional result type … … 1590 1590 secondFinder.findWithAdjustment( commaExpr->get_arg2() ); 1591 1591 for ( const Alternative & alt : secondFinder.alternatives ) { 1592 alternatives.push_back( Alternative( new CommaExpr( newFirstArg ->clone(), alt.expr->clone()), alt.env, alt.cost ) );1592 alternatives.push_back( Alternative( new CommaExpr( newFirstArg, alt.expr ), alt.env, alt.cost ) ); 1593 1593 } // for 1594 1594 } … … 1612 1612 Type* commonType = nullptr; 1613 1613 if ( unify( first.expr->result, second.expr->result, newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 1614 RangeExpr * newExpr = new RangeExpr( first.expr ->clone(), second.expr->clone());1614 RangeExpr * newExpr = new RangeExpr( first.expr, second.expr ); 1615 1615 newExpr->result = commonType ? commonType : first.expr->result->clone(); 1616 1616 newAlt.expr = newExpr; … … 1640 1640 1641 1641 void AlternativeFinder::Finder::postvisit( TupleExpr *tupleExpr ) { 1642 alternatives.push_back( Alternative( tupleExpr ->clone(), env, Cost::zero ) );1642 alternatives.push_back( Alternative( tupleExpr, env, Cost::zero ) ); 1643 1643 } 1644 1644 1645 1645 void AlternativeFinder::Finder::postvisit( ImplicitCopyCtorExpr * impCpCtorExpr ) { 1646 alternatives.push_back( Alternative( impCpCtorExpr ->clone(), env, Cost::zero ) );1646 alternatives.push_back( Alternative( impCpCtorExpr, env, Cost::zero ) ); 1647 1647 } 1648 1648 … … 1653 1653 finder.findWithoutPrune( ctorExpr->get_callExpr() ); 1654 1654 for ( Alternative & alt : finder.alternatives ) { 1655 alternatives.push_back( Alternative( new ConstructorExpr( alt.expr ->clone()), alt.env, alt.cost ) );1655 alternatives.push_back( Alternative( new ConstructorExpr( alt.expr ), alt.env, alt.cost ) ); 1656 1656 } 1657 1657 } 1658 1658 1659 1659 void AlternativeFinder::Finder::postvisit( TupleIndexExpr *tupleExpr ) { 1660 alternatives.push_back( Alternative( tupleExpr ->clone(), env, Cost::zero ) );1660 alternatives.push_back( Alternative( tupleExpr, env, Cost::zero ) ); 1661 1661 } 1662 1662 1663 1663 void AlternativeFinder::Finder::postvisit( TupleAssignExpr *tupleAssignExpr ) { 1664 alternatives.push_back( Alternative( tupleAssignExpr ->clone(), env, Cost::zero ) );1664 alternatives.push_back( Alternative( tupleAssignExpr, env, Cost::zero ) ); 1665 1665 } 1666 1666 … … 1670 1670 for ( Alternative & alt : finder.alternatives ) { 1671 1671 // ensure that the id is passed on to the UniqueExpr alternative so that the expressions are "linked" 1672 UniqueExpr * newUnqExpr = new UniqueExpr( alt.expr ->clone(), unqExpr->get_id() );1672 UniqueExpr * newUnqExpr = new UniqueExpr( alt.expr, unqExpr->get_id() ); 1673 1673 alternatives.push_back( Alternative( newUnqExpr, alt.env, alt.cost ) ); 1674 1674 } … … 1721 1721 // count one safe conversion for each value that is thrown away 1722 1722 thisCost.incSafe( discardedValues ); 1723 Alternative newAlt( new InitExpr( restructureCast( alt.expr ->clone(), toType, true ), initAlt.designation->clone()), newEnv, alt.cost, thisCost );1723 Alternative newAlt( new InitExpr( restructureCast( alt.expr, toType, true ), initAlt.designation ), newEnv, alt.cost, thisCost ); 1724 1724 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) ); 1725 1725 }
Note: See TracChangeset
for help on using the changeset viewer.