Changeset 0c840fc for src/ResolvExpr
- Timestamp:
- May 2, 2023, 3:45:08 AM (2 years ago)
- Branches:
- ast-experimental, master
- Children:
- 34b4268
- Parents:
- 46da46b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ResolvExpr/SatisfyAssertions.cpp ¶
r46da46b r0c840fc 143 143 }; 144 144 145 145 enum AssertionResult {Fail, Skip, Success} ; 146 146 147 147 /// Binds a single assertion, updating satisfaction state … … 164 164 165 165 /// Satisfy a single assertion 166 boolsatisfyAssertion( ast::AssertionList::value_type & assn, SatState & sat, bool skipUnbound = false) {166 AssertionResult satisfyAssertion( ast::AssertionList::value_type & assn, SatState & sat, bool skipUnbound = false) { 167 167 // skip unused assertions 168 168 static unsigned int cnt = 0; 169 if ( ! assn.second.isUsed ) return true;169 if ( ! assn.second.isUsed ) return AssertionResult::Success; 170 170 171 171 if (assn.first->var->name[1] == '|') std::cerr << ++cnt << std::endl; … … 186 186 if (thisArgType.as<ast::PointerType>()) otypeKey = Mangle::Encoding::pointer; 187 187 else if (!isUnboundType(thisArgType)) otypeKey = Mangle::mangle(thisArgType, Mangle::Type | Mangle::NoGenericParams); 188 else if (skipUnbound) return false;188 else if (skipUnbound) return AssertionResult::Skip; 189 189 190 190 candidates = sat.symtab.specialLookupId(kind, otypeKey); … … 251 251 // break if no satisfying match 252 252 if ( matches.empty() ) matches = std::move(inexactMatches); 253 if ( matches.empty() ) return false;253 if ( matches.empty() ) return AssertionResult::Fail; 254 254 255 255 // defer if too many satisfying matches 256 256 if ( matches.size() > 1 ) { 257 257 sat.deferred.emplace_back( assn.first, assn.second, std::move( matches ) ); 258 return true;258 return AssertionResult::Success; 259 259 } 260 260 … … 267 267 268 268 bindAssertion( assn.first, assn.second, sat.cand, match, sat.inferred ); 269 return true;269 return AssertionResult::Success; 270 270 } 271 271 … … 456 456 for ( auto & assn : sat.need ) { 457 457 // fail early if any assertion is not satisfiable 458 if ( ! satisfyAssertion( assn, sat, !next.empty() ) ) { 459 next.emplace_back(assn); 460 // goto nextSat; 461 } 462 } 463 // success 464 if (next.empty()) break; 465 // fail if nothing resolves 466 else if (next.size() == sat.need.size()) { 467 // if (allowConversion) { 458 auto result = satisfyAssertion( assn, sat, !next.empty() ); 459 if ( result == AssertionResult::Fail ) { 468 460 Indenter tabs{ 3 }; 469 461 std::ostringstream ss; … … 471 463 print( ss, *sat.cand, ++tabs ); 472 464 ss << (tabs-1) << "Could not satisfy assertion:\n"; 473 ast::print( ss, next[0].first, tabs );465 ast::print( ss, assn.first, tabs ); 474 466 475 467 errors.emplace_back( ss.str() ); 476 468 goto nextSat; 477 // } 478 479 // else { 480 // allowConversion = true; 481 // continue; 482 // } 483 } 469 } 470 else if ( result == AssertionResult::Skip ) { 471 next.emplace_back(assn); 472 // goto nextSat; 473 } 474 } 475 // success 476 if (next.empty()) break; 477 484 478 sat.need = std::move(next); 485 479 }
Note: See TracChangeset
for help on using the changeset viewer.