Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    rb9be079b re04ef3a  
    1919#include <functional>
    2020#include <cassert>
    21 #include <unordered_map>
    22 #include <utility>
    23 #include <vector>
    2421
    2522#include "AlternativeFinder.h"
     
    4239#include "Tuples/NameMatcher.h"
    4340#include "Common/utility.h"
    44 #include "InitTweak/InitTweak.h"
    4541
    4642extern bool resolvep;
     
    411407        }
    412408
    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
     409        static const int recursionLimit = 10;
    418410
    419411        void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) {
     
    424416                }
    425417        }
    426        
     418
    427419        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,
    429                                                  int level, const SymTab::Indexer &indexer, OutputIterator out ) {
     420        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 ) {
    430421                if ( begin == end ) {
    431422                        if ( newNeed.empty() ) {
     
    440431                                        printAssertionSet( newNeed, std::cerr, 8 );
    441432                                )
    442                                 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, needParents, level+1, indexer, out );
     433                                inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out );
    443434                                return;
    444435                        }
     
    447438                ForwardIterator cur = begin++;
    448439                if ( ! cur->second ) {
    449                         inferRecursive( begin, end, newAlt, openVars, decls, newNeed, needParents, level, indexer, out );
     440                        inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out );
    450441                }
    451442                DeclarationWithType *curDecl = cur->first;
     
    464455                                std::cerr << std::endl;
    465456                        )
    466                         AssertionParentSet newNeedParents( needParents );
    467                         // skip repeatingly-self-recursive assertion satisfaction
    468                         if ( newNeedParents[ curDecl ][ *candidate ]++ > recursionParentLimit ) return;
    469                        
    470457                        AssertionSet newHave, newerNeed( newNeed );
    471458                        TypeEnvironment newEnv( newAlt.env );
     
    504491                                // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
    505492                                appExpr->get_inferParams()[ curDecl->get_uniqueId() ] = ParamEntry( (*candidate)->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
    506                                 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, newNeedParents, level, indexer, out );
     493                                inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );
    507494                        } else {
    508495                                delete adjType;
     
    526513                addToIndexer( have, decls );
    527514                AssertionSet newNeed;
    528                 AssertionParentSet needParents;
    529                 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, needParents, 0, indexer, out );
     515                inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out );
    530516//      PRINT(
    531517//          std::cerr << "declaration 14 is ";
     
    560546
    561547                {
    562                         std::string fname = InitTweak::getFunctionName( untypedExpr );
    563                         if ( fname == "&&" ) {
     548                        NameExpr *fname = 0;;
     549                        if ( ( fname = dynamic_cast<NameExpr *>( untypedExpr->get_function()))
     550                                 && ( fname->get_name() == std::string("&&")) ) {
    564551                                VoidType v = Type::Qualifiers();                // resolve to type void *
    565552                                PointerType pt( Type::Qualifiers(), v.clone() );
Note: See TracChangeset for help on using the changeset viewer.