Changes in / [e64365c:87b5bf0]


Ignore:
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • doc/working/resolver_design.md

    re64365c r87b5bf0  
    14141414considered if no match was found in the previous class.
    14151415
    1416 Another source of efficiency would be to cache the best given interpretation
    1417 of a subexpression within an environment; this may not be incredibly useful
    1418 for explict parameters (though it may be useful for, e.g. `f( x, x )`, where
    1419 both parameters of `f` have the same type), but should pay some dividends for
    1420 the implicit assertion parameters, especially the otype parameters for the
    1421 argument of a generic type, which will generally be resolved in duplicate for
    1422 (at least) the assignment operator, constructor, copy constructor & destructor
    1423 of the generic type.
    1424 
    14251416## Appendix A: Partial and Total Orders ##
    14261417The `<=` relation on integers is a commonly known _total order_, and
  • src/ResolvExpr/AlternativeFinder.cc

    re64365c r87b5bf0  
    411411        }
    412412
    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;
     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;
    415415       
    416         static const int recursionLimit = /*10*/ 3;  ///< Limit to depth of recursion satisfaction
    417         //static const unsigned recursionParentLimit = 1;  ///< Limit to the number of times an assertion can recursively use itself
     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
    418418
    419419        void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) {
     
    426426       
    427427        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,
    429429                                                 int level, const SymTab::Indexer &indexer, OutputIterator out ) {
    430430                if ( begin == end ) {
     
    440440                                        printAssertionSet( newNeed, std::cerr, 8 );
    441441                                )
    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 );
    443443                                return;
    444444                        }
     
    447447                ForwardIterator cur = begin++;
    448448                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 );
    450450                }
    451451                DeclarationWithType *curDecl = cur->first;
     
    488488                                assert( (*candidate)->get_uniqueId() );
    489489                                DeclarationWithType *candDecl = static_cast< DeclarationWithType* >( Declaration::declFromId( (*candidate)->get_uniqueId() ) );
    490                                 //AssertionParentSet newNeedParents( needParents );
     490                                AssertionParentSet newNeedParents( needParents );
    491491                                // 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;
    494493                                Expression *varExpr = new VariableExpr( candDecl );
    495494                                deleteAll( varExpr->get_results() );
     
    506505                                // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
    507506                                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 );
    509508                        } else {
    510509                                delete adjType;
     
    528527                addToIndexer( have, decls );
    529528                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 );
    532531//      PRINT(
    533532//          std::cerr << "declaration 14 is ";
Note: See TracChangeset for help on using the changeset viewer.