- File:
-
- 1 edited
-
src/ResolvExpr/CandidateFinder.cpp (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
rb0d9ff7 r09f34a84 269 269 unsigned nextArg, unsigned tupleStart = 0, Cost cost = Cost::zero, 270 270 unsigned nextExpl = 0, unsigned explAlt = 0 ) 271 : parent(parent), expr( expr ), cost( cost ), env( move( env ) ), need(move( need ) ),272 have( move( have ) ), open(move( open ) ), nextArg( nextArg ), tupleStart( tupleStart ),271 : parent(parent), expr( expr ), cost( cost ), env( std::move( env ) ), need( std::move( need ) ), 272 have( std::move( have ) ), open( std::move( open ) ), nextArg( nextArg ), tupleStart( tupleStart ), 273 273 nextExpl( nextExpl ), explAlt( explAlt ) {} 274 274 … … 276 276 const ArgPack & o, ast::TypeEnvironment && env, ast::AssertionSet && need, 277 277 ast::AssertionSet && have, ast::OpenVarSet && open, unsigned nextArg, Cost added ) 278 : parent( o.parent ), expr( o.expr ), cost( o.cost + added ), env( move( env ) ),279 need( move( need ) ), have( move( have ) ), open(move( open ) ), nextArg( nextArg ),278 : parent( o.parent ), expr( o.expr ), cost( o.cost + added ), env( std::move( env ) ), 279 need( std::move( need ) ), have( std::move( have ) ), open( std::move( open ) ), nextArg( nextArg ), 280 280 tupleStart( o.tupleStart ), nextExpl( 0 ), explAlt( 0 ) {} 281 281 … … 301 301 // reset pack to appropriate tuple 302 302 std::vector< ast::ptr< ast::Expr > > exprv( exprs.begin(), exprs.end() ); 303 expr = new ast::TupleExpr{ expr->location, move( exprv ) };303 expr = new ast::TupleExpr{ expr->location, std::move( exprv ) }; 304 304 tupleStart = pack->tupleStart - 1; 305 305 parent = pack->parent; … … 404 404 newResult.open, symtab ) 405 405 ) { 406 finalResults.emplace_back( move( newResult ) );406 finalResults.emplace_back( std::move( newResult ) ); 407 407 } 408 408 … … 423 423 if ( expl.exprs.empty() ) { 424 424 results.emplace_back( 425 results[i], move( env ), copy( results[i].need ),426 copy( results[i].have ), move( open ), nextArg + 1, expl.cost );425 results[i], std::move( env ), copy( results[i].need ), 426 copy( results[i].have ), std::move( open ), nextArg + 1, expl.cost ); 427 427 428 428 continue; … … 431 431 // add new result 432 432 results.emplace_back( 433 i, expl.exprs.front(), move( env ), copy( results[i].need ),434 copy( results[i].have ), move( open ), nextArg + 1, nTuples,433 i, expl.exprs.front(), std::move( env ), copy( results[i].need ), 434 copy( results[i].have ), std::move( open ), nextArg + 1, nTuples, 435 435 expl.cost, expl.exprs.size() == 1 ? 0 : 1, j ); 436 436 } … … 444 444 // splice final results onto results 445 445 for ( std::size_t i = 0; i < finalResults.size(); ++i ) { 446 results.emplace_back( move( finalResults[i] ) );446 results.emplace_back( std::move( finalResults[i] ) ); 447 447 } 448 448 return ! finalResults.empty(); … … 478 478 479 479 results.emplace_back( 480 i, expr, move( env ), move( need ), move( have ),move( open ), nextArg,480 i, expr, std::move( env ), std::move( need ), std::move( have ), std::move( open ), nextArg, 481 481 nTuples, Cost::zero, nextExpl, results[i].explAlt ); 482 482 } … … 494 494 if ( unify( paramType, cnst->result, env, need, have, open, symtab ) ) { 495 495 results.emplace_back( 496 i, new ast::DefaultArgExpr{ cnst->location, cnst }, move( env ),497 move( need ), move( have ),move( open ), nextArg, nTuples );496 i, new ast::DefaultArgExpr{ cnst->location, cnst }, std::move( env ), 497 std::move( need ), std::move( have ), std::move( open ), nextArg, nTuples ); 498 498 } 499 499 } … … 516 516 if ( expl.exprs.empty() ) { 517 517 results.emplace_back( 518 results[i], move( env ), move( need ), move( have ),move( open ),518 results[i], std::move( env ), std::move( need ), std::move( have ), std::move( open ), 519 519 nextArg + 1, expl.cost ); 520 520 … … 538 538 // add new result 539 539 results.emplace_back( 540 i, expr, move( env ), move( need ), move( have ),move( open ),540 i, expr, std::move( env ), std::move( need ), std::move( have ), std::move( open ), 541 541 nextArg + 1, nTuples, expl.cost, expl.exprs.size() == 1 ? 0 : 1, j ); 542 542 } … … 576 576 restructureCast( idx, toType->getComponent( i ), isGenerated ) ); 577 577 } 578 return new ast::TupleExpr{ arg->location, move( components ) };578 return new ast::TupleExpr{ arg->location, std::move( components ) }; 579 579 } else { 580 580 // handle normally … … 672 672 } 673 673 std::vector< ast::ptr< ast::Expr > > vargs( args.begin(), args.end() ); 674 appExpr->args = move( vargs );674 appExpr->args = std::move( vargs ); 675 675 // build and validate new candidate 676 676 auto newCand = … … 783 783 if ( expl.exprs.empty() ) { 784 784 results.emplace_back( 785 results[i], move( env ), copy( results[i].need ),786 copy( results[i].have ), move( open ), nextArg + 1,785 results[i], std::move( env ), copy( results[i].need ), 786 copy( results[i].have ), std::move( open ), nextArg + 1, 787 787 expl.cost ); 788 788 … … 792 792 // add new result 793 793 results.emplace_back( 794 i, expl.exprs.front(), move( env ), copy( results[i].need ),795 copy( results[i].have ), move( open ), nextArg + 1, 0, expl.cost,794 i, expl.exprs.front(), std::move( env ), copy( results[i].need ), 795 copy( results[i].have ), std::move( open ), nextArg + 1, 0, expl.cost, 796 796 expl.exprs.size() == 1 ? 0 : 1, j ); 797 797 } … … 843 843 // as a member expression 844 844 addAnonConversions( newCand ); 845 candidates.emplace_back( move( newCand ) );845 candidates.emplace_back( std::move( newCand ) ); 846 846 } 847 847 } … … 864 864 } 865 865 866 void postvisit( const ast::QualifiedNameExpr * qualifiedNameExpr ) {867 auto mangleName = Mangle::mangle(qualifiedNameExpr->var);868 addCandidate( qualifiedNameExpr, tenv );869 }870 871 866 void postvisit( const ast::UntypedExpr * untypedExpr ) { 872 867 std::vector< CandidateFinder > argCandidates = … … 902 897 } 903 898 904 if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer); 905 //else if (const ast::EnumInstType * enumInst = argType.as<ast::EnumInstType>()) {906 // const ast::EnumDecl * enumDecl = enumInst->base; // Here907 //if ( const ast::Type* enumType = enumDecl->base ) {908 // // instance of enum (T) is a instance of type (T)909 //funcFinder.otypeKeys.insert(Mangle::mangle(enumType, Mangle::NoGenericParams | Mangle::Type));910 //} else {911 //// instance of an untyped enum is techically int912 //funcFinder.otypeKeys.insert(Mangle::mangle(enumDecl, Mangle::NoGenericParams | Mangle::Type));913 //}914 //}899 if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer); 900 else if (const ast::EnumInstType * enumInst = argType.as<ast::EnumInstType>()) { 901 const ast::EnumDecl * enumDecl = enumInst->base; 902 if ( const ast::Type* enumType = enumDecl->base ) { 903 // instance of enum (T) is a instance of type (T) 904 funcFinder.otypeKeys.insert(Mangle::mangle(enumType, Mangle::NoGenericParams | Mangle::Type)); 905 } else { 906 // instance of an untyped enum is techically int 907 funcFinder.otypeKeys.insert(Mangle::mangle(enumDecl, Mangle::NoGenericParams | Mangle::Type)); 908 } 909 } 915 910 else funcFinder.otypeKeys.insert(Mangle::mangle(argType, Mangle::NoGenericParams | Mangle::Type)); 916 911 } … … 991 986 funcE.emplace_back( *func, symtab ); 992 987 } 993 argExpansions.emplace_front( move( funcE ) );988 argExpansions.emplace_front( std::move( funcE ) ); 994 989 995 990 for ( const CandidateRef & op : opFinder ) { … … 1035 1030 if ( cvtCost != Cost::infinity ) { 1036 1031 withFunc->cvtCost = cvtCost; 1037 candidates.emplace_back( move( withFunc ) );1038 } 1039 } 1040 found = move( candidates );1032 candidates.emplace_back( std::move( withFunc ) ); 1033 } 1034 } 1035 found = std::move( candidates ); 1041 1036 1042 1037 // use a new list so that candidates are not examined by addAnonConversions twice … … 1136 1131 CandidateRef newCand = std::make_shared<Candidate>( 1137 1132 restructureCast( cand->expr, toType, castExpr->isGenerated ), 1138 copy( cand->env ), move( open ),move( need ), cand->cost,1133 copy( cand->env ), std::move( open ), std::move( need ), cand->cost, 1139 1134 cand->cost + thisCost ); 1140 1135 inferParameters( newCand, matches ); … … 1290 1285 // as a name expression 1291 1286 addAnonConversions( newCand ); 1292 candidates.emplace_back( move( newCand ) );1287 candidates.emplace_back( std::move( newCand ) ); 1293 1288 } 1294 1289 } … … 1399 1394 new ast::LogicalExpr{ 1400 1395 logicalExpr->location, r1->expr, r2->expr, logicalExpr->isAnd }, 1401 move( env ), move( open ),move( need ), r1->cost + r2->cost );1396 std::move( env ), std::move( open ), std::move( need ), r1->cost + r2->cost ); 1402 1397 } 1403 1398 } … … 1457 1452 // output candidate 1458 1453 CandidateRef newCand = std::make_shared<Candidate>( 1459 newExpr, move( env ), move( open ),move( need ), cost );1454 newExpr, std::move( env ), std::move( open ), std::move( need ), cost ); 1460 1455 inferParameters( newCand, candidates ); 1461 1456 } … … 1524 1519 // add candidate 1525 1520 CandidateRef newCand = std::make_shared<Candidate>( 1526 newExpr, move( env ), move( open ),move( need ),1521 newExpr, std::move( env ), std::move( open ), std::move( need ), 1527 1522 r1->cost + r2->cost ); 1528 1523 inferParameters( newCand, candidates ); … … 1553 1548 1554 1549 addCandidate( 1555 new ast::TupleExpr{ tupleExpr->location, move( exprs ) },1556 move( env ), move( open ),move( need ), sumCost( subs ) );1550 new ast::TupleExpr{ tupleExpr->location, std::move( exprs ) }, 1551 std::move( env ), std::move( open ), std::move( need ), sumCost( subs ) ); 1557 1552 } 1558 1553 } … … 1640 1635 initExpr->location, restructureCast( cand->expr, toType ), 1641 1636 initAlt.designation }, 1642 move(env), move( open ),move( need ), cand->cost, thisCost );1637 std::move(env), std::move( open ), std::move( need ), cand->cost, thisCost ); 1643 1638 inferParameters( newCand, matches ); 1644 1639 } … … 1773 1768 cand->env.applyFree( newResult ); 1774 1769 cand->expr = ast::mutate_field( 1775 cand->expr.get(), &ast::Expr::result, move( newResult ) );1770 cand->expr.get(), &ast::Expr::result, std::move( newResult ) ); 1776 1771 1777 1772 out.emplace_back( cand ); … … 1859 1854 1860 1855 auto oldsize = candidates.size(); 1861 candidates = move( pruned );1856 candidates = std::move( pruned ); 1862 1857 1863 1858 PRINT(
Note:
See TracChangeset
for help on using the changeset viewer.