Changes in / [e64365c:87b5bf0]
- Files:
-
- 2 edited
-
doc/working/resolver_design.md (modified) (1 diff)
-
src/ResolvExpr/AlternativeFinder.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/working/resolver_design.md
re64365c r87b5bf0 1414 1414 considered if no match was found in the previous class. 1415 1415 1416 Another source of efficiency would be to cache the best given interpretation1417 of a subexpression within an environment; this may not be incredibly useful1418 for explict parameters (though it may be useful for, e.g. `f( x, x )`, where1419 both parameters of `f` have the same type), but should pay some dividends for1420 the implicit assertion parameters, especially the otype parameters for the1421 argument of a generic type, which will generally be resolved in duplicate for1422 (at least) the assignment operator, constructor, copy constructor & destructor1423 of the generic type.1424 1425 1416 ## Appendix A: Partial and Total Orders ## 1426 1417 The `<=` relation on integers is a commonly known _total order_, and -
src/ResolvExpr/AlternativeFinder.cc
re64365c r87b5bf0 411 411 } 412 412 413 // /// Map of declaration uniqueIds (intended to be the assertions in an AssertionSet) to their parents and the number of times they've been included414 //typedef std::unordered_map< UniqueId, std::unordered_map< UniqueId, unsigned > > AssertionParentSet;413 /// Map of declaration uniqueIds (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< UniqueId, std::unordered_map< UniqueId, unsigned > > AssertionParentSet; 415 415 416 static const int recursionLimit = /*10*/ 3; ///< Limit to depth of recursion satisfaction417 //static const unsigned recursionParentLimit = 1; ///< Limit to the number of times an assertion can recursively use itself416 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 418 418 419 419 void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) { … … 426 426 427 427 template< typename ForwardIterator, typename OutputIterator > 428 void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, /*const AssertionParentSet &needParents,*/428 void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, const AssertionParentSet &needParents, 429 429 int level, const SymTab::Indexer &indexer, OutputIterator out ) { 430 430 if ( begin == end ) { … … 440 440 printAssertionSet( newNeed, std::cerr, 8 ); 441 441 ) 442 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, /*needParents,*/level+1, indexer, out );442 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, needParents, level+1, indexer, out ); 443 443 return; 444 444 } … … 447 447 ForwardIterator cur = begin++; 448 448 if ( ! cur->second ) { 449 inferRecursive( begin, end, newAlt, openVars, decls, newNeed, /*needParents,*/level, indexer, out );449 inferRecursive( begin, end, newAlt, openVars, decls, newNeed, needParents, level, indexer, out ); 450 450 } 451 451 DeclarationWithType *curDecl = cur->first; … … 488 488 assert( (*candidate)->get_uniqueId() ); 489 489 DeclarationWithType *candDecl = static_cast< DeclarationWithType* >( Declaration::declFromId( (*candidate)->get_uniqueId() ) ); 490 //AssertionParentSet newNeedParents( needParents );490 AssertionParentSet newNeedParents( needParents ); 491 491 // skip repeatingly-self-recursive assertion satisfaction 492 // DOESN'T WORK: grandchild nodes conflict with their cousins 493 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue; 492 if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue; 494 493 Expression *varExpr = new VariableExpr( candDecl ); 495 494 deleteAll( varExpr->get_results() ); … … 506 505 // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions 507 506 appExpr->get_inferParams()[ curDecl->get_uniqueId() ] = ParamEntry( (*candidate)->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr ); 508 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, /*newNeedParents,*/level, indexer, out );507 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, newNeedParents, level, indexer, out ); 509 508 } else { 510 509 delete adjType; … … 528 527 addToIndexer( have, decls ); 529 528 AssertionSet newNeed; 530 //AssertionParentSet needParents;531 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, /*needParents,*/0, indexer, out );529 AssertionParentSet needParents; 530 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, needParents, 0, indexer, out ); 532 531 // PRINT( 533 532 // std::cerr << "declaration 14 is ";
Note:
See TracChangeset
for help on using the changeset viewer.