Changeset 1ed958c3 for src/ResolvExpr/AlternativeFinder.cc
- Timestamp:
- May 30, 2018, 2:04:51 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- 6b8643d
- Parents:
- cdc4d43
- git-author:
- Aaron Moss <a3moss@…> (05/30/18 13:45:51)
- git-committer:
- Aaron Moss <a3moss@…> (05/30/18 14:04:51)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
rcdc4d43 r1ed958c3 462 462 } 463 463 464 // /// Map of declaration uniqueIds (intended to be the assertions in an AssertionSet) to their parents and the number of times they've been included465 //typedef std::unordered_map< UniqueId, std::unordered_map< UniqueId, unsigned > > AssertionParentSet;466 467 464 static const int recursionLimit = /*10*/ 4; ///< Limit to depth of recursion satisfaction 468 //static const unsigned recursionParentLimit = 1; ///< Limit to the number of times an assertion can recursively use itself469 465 470 466 void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) { … … 477 473 478 474 template< typename ForwardIterator, typename OutputIterator > 479 void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, /*const AssertionParentSet &needParents,*/ 480 int level, const SymTab::Indexer &indexer, OutputIterator out ) { 475 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 ) { 481 476 if ( begin == end ) { 482 477 if ( newNeed.empty() ) { … … 496 491 printAssertionSet( newNeed, std::cerr, 8 ); 497 492 ) 498 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, /*needParents,*/level+1, indexer, out );493 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out ); 499 494 return; 500 495 } … … 503 498 ForwardIterator cur = begin++; 504 499 if ( ! cur->second.isUsed ) { 505 inferRecursive( begin, end, newAlt, openVars, decls, newNeed, /*needParents,*/level, indexer, out );500 inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out ); 506 501 return; // xxx - should this continue? previously this wasn't here, and it looks like it should be 507 502 } … … 556 551 } 557 552 558 //AssertionParentSet newNeedParents( needParents );559 // skip repeatingly-self-recursive assertion satisfaction560 // DOESN'T WORK: grandchild nodes conflict with their cousins561 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue;562 563 553 Expression *varExpr = data.combine( newerAlt.cvtCost ); 564 554 varExpr->set_result( adjType->clone() ); … … 575 565 inferParameters = (*inferParameters)[ id ].inferParams.get(); 576 566 } 577 // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions567 578 568 (*inferParameters)[ curDecl->get_uniqueId() ] = ParamEntry( candidate->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr ); 579 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, /*newNeedParents,*/level, indexer, out );569 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out ); 580 570 } 581 571 } … … 597 587 addToIndexer( have, decls ); 598 588 AssertionSet newNeed; 599 //AssertionParentSet needParents;600 589 PRINT( 601 590 std::cerr << "env is: " << std::endl; … … 604 593 ) 605 594 606 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, /*needParents,*/0, indexer, out );595 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out ); 607 596 // PRINT( 608 597 // std::cerr << "declaration 14 is "; … … 637 626 638 627 ArgPack() 639 : parent(0), expr( ), cost(Cost::zero), env(), need(), have(), openVars(), nextArg(0),640 tupleStart(0), nextExpl(0), explAlt(0) {}628 : parent(0), expr(nullptr), cost(Cost::zero), env(), need(), have(), openVars(), 629 nextArg(0), tupleStart(0), nextExpl(0), explAlt(0) {} 641 630 642 631 ArgPack(const TypeEnvironment& env, const AssertionSet& need, const AssertionSet& have, 643 632 const OpenVarSet& openVars) 644 : parent(0), expr( ), cost(Cost::zero), env(env), need(need), have(have),633 : parent(0), expr(nullptr), cost(Cost::zero), env(env), need(need), have(have), 645 634 openVars(openVars), nextArg(0), tupleStart(0), nextExpl(0), explAlt(0) {} 646 635 … … 649 638 unsigned tupleStart = 0, Cost cost = Cost::zero, unsigned nextExpl = 0, 650 639 unsigned explAlt = 0 ) 651 : parent(parent), expr(expr ->clone()), cost(cost), env(move(env)), need(move(need)),640 : parent(parent), expr(expr), cost(cost), env(move(env)), need(move(need)), 652 641 have(move(have)), openVars(move(openVars)), nextArg(nextArg), tupleStart(tupleStart), 653 642 nextExpl(nextExpl), explAlt(explAlt) {} … … 655 644 ArgPack(const ArgPack& o, TypeEnvironment&& env, AssertionSet&& need, AssertionSet&& have, 656 645 OpenVarSet&& openVars, unsigned nextArg, Cost added ) 657 : parent(o.parent), expr(o.expr ? o.expr->clone() : nullptr), cost(o.cost + added),658 env(move(env)), need(move(need)), have(move(have)), openVars(move(openVars)),659 nextArg(nextArg),tupleStart(o.tupleStart), nextExpl(0), explAlt(0) {}646 : parent(o.parent), expr(o.expr), cost(o.cost + added), env(move(env)), 647 need(move(need)), have(move(have)), openVars(move(openVars)), nextArg(nextArg), 648 tupleStart(o.tupleStart), nextExpl(0), explAlt(0) {} 660 649 661 650 /// true iff this pack is in the middle of an exploded argument
Note: See TracChangeset
for help on using the changeset viewer.