Changeset 4a89b52 for src/ResolvExpr/CandidateFinder.cpp
- Timestamp:
- Nov 30, 2023, 2:41:11 PM (7 months ago)
- Branches:
- master
- Children:
- d787828d
- Parents:
- 83fd57d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
r83fd57d r4a89b52 105 105 106 106 // CandidateFinder finder{ symtab, env }; 107 // finder.find( arg, Resolv Mode::withAdjustment() );107 // finder.find( arg, ResolveMode::withAdjustment() ); 108 108 // assertf( finder.candidates.size() > 0, 109 109 // "Somehow castable expression failed to find alternatives." ); … … 974 974 // xxx - is it possible that handleTupleAssignment and main finder both produce candidates? 975 975 // this means there exists ctor/assign functions with a tuple as first parameter. 976 Resolv Mode mode = {976 ResolveMode mode = { 977 977 true, // adjust 978 978 !untypedExpr->func.as<ast::NameExpr>(), // prune if not calling by name … … 989 989 CandidateFinder opFinder( context, tenv ); 990 990 // okay if there aren't any function operations 991 opFinder.find( opExpr, Resolv Mode::withoutFailFast() );991 opFinder.find( opExpr, ResolveMode::withoutFailFast() ); 992 992 PRINT( 993 993 std::cerr << "known function ops:" << std::endl; … … 1175 1175 if ( castExpr->kind == ast::CastExpr::Return ) { 1176 1176 finder.strictMode = true; 1177 finder.find( castExpr->arg, Resolv Mode::withAdjustment() );1177 finder.find( castExpr->arg, ResolveMode::withAdjustment() ); 1178 1178 1179 1179 // return casts are eliminated (merely selecting an overload, no actual operation) 1180 1180 candidates = std::move(finder.candidates); 1181 1181 } 1182 finder.find( castExpr->arg, Resolv Mode::withAdjustment() );1182 finder.find( castExpr->arg, ResolveMode::withAdjustment() ); 1183 1183 1184 1184 if ( !finder.candidates.empty() ) reason.code = NoMatch; … … 1251 1251 CandidateFinder finder( context, tenv ); 1252 1252 // don't prune here, all alternatives guaranteed to have same type 1253 finder.find( castExpr->arg, Resolv Mode::withoutPrune() );1253 finder.find( castExpr->arg, ResolveMode::withoutPrune() ); 1254 1254 for ( CandidateRef & r : finder.candidates ) { 1255 1255 addCandidate( … … 1298 1298 1299 1299 // don't prune here, since it's guaranteed all alternatives will have the same type 1300 finder.find( tech1.get(), Resolv Mode::withoutPrune() );1300 finder.find( tech1.get(), ResolveMode::withoutPrune() ); 1301 1301 pick_alternatives(finder.candidates, false); 1302 1302 … … 1307 1307 std::unique_ptr<const ast::Expr> fallback { ast::UntypedExpr::createDeref(loc, new ast::UntypedExpr(loc, new ast::NameExpr(loc, castExpr->concrete_target.getter), { castExpr->arg })) }; 1308 1308 // don't prune here, since it's guaranteed all alternatives will have the same type 1309 finder.find( fallback.get(), Resolv Mode::withoutPrune() );1309 finder.find( fallback.get(), ResolveMode::withoutPrune() ); 1310 1310 1311 1311 pick_alternatives(finder.candidates, true); … … 1316 1316 void Finder::postvisit( const ast::UntypedMemberExpr * memberExpr ) { 1317 1317 CandidateFinder aggFinder( context, tenv ); 1318 aggFinder.find( memberExpr->aggregate, Resolv Mode::withAdjustment() );1318 aggFinder.find( memberExpr->aggregate, ResolveMode::withAdjustment() ); 1319 1319 for ( CandidateRef & agg : aggFinder.candidates ) { 1320 1320 // it's okay for the aggregate expression to have reference type -- cast it to the … … 1475 1475 void Finder::postvisit( const ast::LogicalExpr * logicalExpr ) { 1476 1476 CandidateFinder finder1( context, tenv ); 1477 finder1.find( logicalExpr->arg1, Resolv Mode::withAdjustment() );1477 finder1.find( logicalExpr->arg1, ResolveMode::withAdjustment() ); 1478 1478 if ( finder1.candidates.empty() ) return; 1479 1479 1480 1480 CandidateFinder finder2( context, tenv ); 1481 finder2.find( logicalExpr->arg2, Resolv Mode::withAdjustment() );1481 finder2.find( logicalExpr->arg2, ResolveMode::withAdjustment() ); 1482 1482 if ( finder2.candidates.empty() ) return; 1483 1483 … … 1505 1505 // candidates for condition 1506 1506 CandidateFinder finder1( context, tenv ); 1507 finder1.find( conditionalExpr->arg1, Resolv Mode::withAdjustment() );1507 finder1.find( conditionalExpr->arg1, ResolveMode::withAdjustment() ); 1508 1508 if ( finder1.candidates.empty() ) return; 1509 1509 … … 1511 1511 CandidateFinder finder2( context, tenv ); 1512 1512 finder2.allowVoid = true; 1513 finder2.find( conditionalExpr->arg2, Resolv Mode::withAdjustment() );1513 finder2.find( conditionalExpr->arg2, ResolveMode::withAdjustment() ); 1514 1514 if ( finder2.candidates.empty() ) return; 1515 1515 … … 1517 1517 CandidateFinder finder3( context, tenv ); 1518 1518 finder3.allowVoid = true; 1519 finder3.find( conditionalExpr->arg3, Resolv Mode::withAdjustment() );1519 finder3.find( conditionalExpr->arg3, ResolveMode::withAdjustment() ); 1520 1520 if ( finder3.candidates.empty() ) return; 1521 1521 … … 1570 1570 1571 1571 CandidateFinder finder2( context, env ); 1572 finder2.find( commaExpr->arg2, Resolv Mode::withAdjustment() );1572 finder2.find( commaExpr->arg2, ResolveMode::withAdjustment() ); 1573 1573 1574 1574 for ( const CandidateRef & r2 : finder2.candidates ) { … … 1584 1584 CandidateFinder finder( context, tenv ); 1585 1585 finder.allowVoid = true; 1586 finder.find( ctorExpr->callExpr, Resolv Mode::withoutPrune() );1586 finder.find( ctorExpr->callExpr, ResolveMode::withoutPrune() ); 1587 1587 for ( CandidateRef & r : finder.candidates ) { 1588 1588 addCandidate( *r, new ast::ConstructorExpr{ ctorExpr->location, r->expr } ); … … 1593 1593 // resolve low and high, accept candidates where low and high types unify 1594 1594 CandidateFinder finder1( context, tenv ); 1595 finder1.find( rangeExpr->low, Resolv Mode::withAdjustment() );1595 finder1.find( rangeExpr->low, ResolveMode::withAdjustment() ); 1596 1596 if ( finder1.candidates.empty() ) return; 1597 1597 1598 1598 CandidateFinder finder2( context, tenv ); 1599 finder2.find( rangeExpr->high, Resolv Mode::withAdjustment() );1599 finder2.find( rangeExpr->high, ResolveMode::withAdjustment() ); 1600 1600 if ( finder2.candidates.empty() ) return; 1601 1601 … … 1673 1673 void Finder::postvisit( const ast::UniqueExpr * unqExpr ) { 1674 1674 CandidateFinder finder( context, tenv ); 1675 finder.find( unqExpr->expr, Resolv Mode::withAdjustment() );1675 finder.find( unqExpr->expr, ResolveMode::withAdjustment() ); 1676 1676 for ( CandidateRef & r : finder.candidates ) { 1677 1677 // ensure that the the id is passed on so that the expressions are "linked" … … 1699 1699 // only open for the duration of resolving the UntypedExpr. 1700 1700 CandidateFinder finder( context, tenv, toType ); 1701 finder.find( initExpr->expr, Resolv Mode::withAdjustment() );1701 finder.find( initExpr->expr, ResolveMode::withAdjustment() ); 1702 1702 1703 1703 Cost minExprCost = Cost::infinity; … … 1889 1889 } 1890 1890 1891 void CandidateFinder::find( const ast::Expr * expr, Resolv Mode mode ) {1891 void CandidateFinder::find( const ast::Expr * expr, ResolveMode mode ) { 1892 1892 // Find alternatives for expression 1893 1893 ast::Pass<Finder> finder{ *this }; … … 2004 2004 for ( const auto & x : xs ) { 2005 2005 out.emplace_back( context, env ); 2006 out.back().find( x, Resolv Mode::withAdjustment() );2006 out.back().find( x, ResolveMode::withAdjustment() ); 2007 2007 2008 2008 PRINT(
Note: See TracChangeset
for help on using the changeset viewer.