Changeset 71d6bd8 for src/ResolvExpr
- Timestamp:
- Nov 28, 2019, 4:31:05 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 7030dab
- Parents:
- 9802f4c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
r9802f4c r71d6bd8 601 601 ast::ptr< ast::Type > & targetType; 602 602 603 enum Errors { 604 NotFound, 605 NoMatch, 606 ArgsToFew, 607 ArgsToMany, 608 RetsToFew, 609 RetsToMany, 610 NoReason 611 }; 612 613 struct { 614 Errors code = NotFound; 615 } reason; 616 603 617 Finder( CandidateFinder & f ) 604 618 : symtab( f.localSyms ), selfFinder( f ), candidates( f.candidates ), tenv( f.env ), … … 611 625 void addCandidate( Args &&... args ) { 612 626 candidates.emplace_back( new Candidate{ std::forward<Args>( args )... } ); 627 reason.code = NoReason; 613 628 } 614 629 … … 836 851 // short-circuit if no candidates 837 852 if ( funcFinder.candidates.empty() ) return; 853 854 reason.code = NoMatch; 838 855 839 856 std::vector< CandidateFinder > argCandidates = … … 989 1006 CandidateFinder finder{ symtab, tenv }; 990 1007 finder.find( addressExpr->arg ); 1008 1009 if( finder.candidates.empty() ) return; 1010 1011 reason.code = NoMatch; 1012 991 1013 for ( CandidateRef & r : finder.candidates ) { 992 1014 if ( ! isLvalue( r->expr ) ) continue; … … 1008 1030 CandidateFinder finder{ symtab, tenv, toType }; 1009 1031 finder.find( castExpr->arg, ResolvMode::withAdjustment() ); 1032 1033 if( !finder.candidates.empty() ) reason.code = NoMatch; 1010 1034 1011 1035 CandidateList matches; … … 1093 1117 std::vector< ast::SymbolTable::IdData > declList = symtab.lookupId( nameExpr->name ); 1094 1118 PRINT( std::cerr << "nameExpr is " << nameExpr->name << std::endl; ) 1119 if( declList.empty() ) return; 1120 1121 reason.code = NoMatch; 1122 1095 1123 for ( auto & data : declList ) { 1096 1124 Cost cost = Cost::zero; … … 1208 1236 if ( finder2.candidates.empty() ) return; 1209 1237 1238 reason.code = NoMatch; 1239 1210 1240 for ( const CandidateRef & r1 : finder1.candidates ) { 1211 1241 for ( const CandidateRef & r2 : finder2.candidates ) { … … 1241 1271 finder3.find( conditionalExpr->arg3, ResolvMode::withAdjustment() ); 1242 1272 if ( finder3.candidates.empty() ) return; 1273 1274 reason.code = NoMatch; 1243 1275 1244 1276 for ( const CandidateRef & r1 : finder1.candidates ) { … … 1319 1351 if ( finder2.candidates.empty() ) return; 1320 1352 1353 reason.code = NoMatch; 1354 1321 1355 for ( const CandidateRef & r1 : finder1.candidates ) { 1322 1356 for ( const CandidateRef & r2 : finder2.candidates ) { … … 1419 1453 finder.find( initExpr->expr, ResolvMode::withAdjustment() ); 1420 1454 for ( CandidateRef & cand : finder.candidates ) { 1455 if(reason.code == NotFound) reason.code = NoMatch; 1456 1421 1457 ast::TypeEnvironment env{ cand->env }; 1422 1458 ast::AssertionSet need( cand->need.begin(), cand->need.end() ), have; … … 1552 1588 1553 1589 if ( mode.failFast && candidates.empty() ) { 1554 SemanticError( expr, "No reasonable alternatives for expression " ); 1590 switch(finder.pass.reason.code) { 1591 case Finder::NotFound: 1592 { SemanticError( expr, "No alternatives for expression " ); break; } 1593 case Finder::NoMatch: 1594 { SemanticError( expr, "Invalid application of existing declaration(s) in expression " ); break; } 1595 case Finder::ArgsToFew: 1596 case Finder::ArgsToMany: 1597 case Finder::RetsToFew: 1598 case Finder::RetsToMany: 1599 case Finder::NoReason: 1600 default: 1601 { SemanticError( expr->location, "No reasonable alternatives for expression : reasons unkown" ); } 1602 } 1555 1603 } 1556 1604
Note: See TracChangeset
for help on using the changeset viewer.