Changeset ebf5689 for src/ResolvExpr
- Timestamp:
- Jun 27, 2016, 4:15:44 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 52e2e3f
- Parents:
- 2de162da
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r2de162da rebf5689 19 19 #include <functional> 20 20 #include <cassert> 21 #include <unordered_map> 22 #include <utility> 23 #include <vector> 21 24 22 25 #include "AlternativeFinder.h" … … 408 411 } 409 412 410 static const int recursionLimit = 10; 413 /// Map of declarations (intended to be the assertions in an AssertionSet) to their parents and the number of times they've been included 414 typedef std::unordered_map< DeclarationWithType*, std::unordered_map< DeclarationWithType*, unsigned > > AssertionParentSet; 415 416 static const int recursionLimit = 10; ///< Limit to depth of recursion satisfaction 417 static const unsigned recursionParentLimit = 1; ///< Limit to the number of times an assertion can recursively use itself 411 418 412 419 void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) { … … 417 424 } 418 425 } 419 426 420 427 template< typename ForwardIterator, typename OutputIterator > 421 void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, int level, const SymTab::Indexer &indexer, OutputIterator out ) { 428 void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, const AssertionParentSet &needParents, 429 int level, const SymTab::Indexer &indexer, OutputIterator out ) { 422 430 if ( begin == end ) { 423 431 if ( newNeed.empty() ) { … … 432 440 printAssertionSet( newNeed, std::cerr, 8 ); 433 441 ) 434 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out );442 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, needParents, level+1, indexer, out ); 435 443 return; 436 444 } … … 439 447 ForwardIterator cur = begin++; 440 448 if ( ! cur->second ) { 441 inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out );449 inferRecursive( begin, end, newAlt, openVars, decls, newNeed, needParents, level, indexer, out ); 442 450 } 443 451 DeclarationWithType *curDecl = cur->first; … … 456 464 std::cerr << std::endl; 457 465 ) 466 AssertionParentSet newNeedParents( needParents ); 467 // skip repeatingly-self-recursive assertion satisfaction 468 if ( needParents[ curDecl ][ *candidate ]++ > recursionParentLimit ) return; 469 458 470 AssertionSet newHave, newerNeed( newNeed ); 459 471 TypeEnvironment newEnv( newAlt.env ); … … 492 504 // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions 493 505 appExpr->get_inferParams()[ curDecl->get_uniqueId() ] = ParamEntry( (*candidate)->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr ); 494 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );506 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, newNeedParents, level, indexer, out ); 495 507 } else { 496 508 delete adjType; … … 514 526 addToIndexer( have, decls ); 515 527 AssertionSet newNeed; 516 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out ); 528 AssertionParentSet needParents; 529 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, needParents, 0, indexer, out ); 517 530 // PRINT( 518 531 // std::cerr << "declaration 14 is ";
Note: See TracChangeset
for help on using the changeset viewer.