Changes in / [66999e7:472ca32]


Ignore:
Location:
src/ResolvExpr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r66999e7 r472ca32  
    1919#include <functional>
    2020#include <cassert>
    21 #include <unordered_map>
    22 #include <utility>
    23 #include <vector>
    2421
    2522#include "AlternativeFinder.h"
     
    411408        }
    412409
    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        
    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
     410        static const int recursionLimit = 10;
    418411
    419412        void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) {
     
    424417                }
    425418        }
    426        
     419
    427420        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 ) {
     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 ) {
    430422                if ( begin == end ) {
    431423                        if ( newNeed.empty() ) {
     
    440432                                        printAssertionSet( newNeed, std::cerr, 8 );
    441433                                )
    442                                 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, needParents, level+1, indexer, out );
     434                                inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out );
    443435                                return;
    444436                        }
     
    447439                ForwardIterator cur = begin++;
    448440                if ( ! cur->second ) {
    449                         inferRecursive( begin, end, newAlt, openVars, decls, newNeed, needParents, level, indexer, out );
     441                        inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out );
    450442                }
    451443                DeclarationWithType *curDecl = cur->first;
     
    464456                                std::cerr << std::endl;
    465457                        )
    466                        
    467458                        AssertionSet newHave, newerNeed( newNeed );
    468459                        TypeEnvironment newEnv( newAlt.env );
     
    487478                                newerAlt.env = newEnv;
    488479                                assert( (*candidate)->get_uniqueId() );
    489                                 DeclarationWithType *candDecl = static_cast< DeclarationWithType* >( Declaration::declFromId( (*candidate)->get_uniqueId() ) );
    490                                 AssertionParentSet newNeedParents( needParents );
    491                                 // skip repeatingly-self-recursive assertion satisfaction
    492                                 if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue;
    493                                 Expression *varExpr = new VariableExpr( candDecl );
     480                                Expression *varExpr = new VariableExpr( static_cast< DeclarationWithType* >( Declaration::declFromId( (*candidate)->get_uniqueId() ) ) );
    494481                                deleteAll( varExpr->get_results() );
    495482                                varExpr->get_results().clear();
     
    505492                                // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
    506493                                appExpr->get_inferParams()[ curDecl->get_uniqueId() ] = ParamEntry( (*candidate)->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
    507                                 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, newNeedParents, level, indexer, out );
     494                                inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );
    508495                        } else {
    509496                                delete adjType;
     
    527514                addToIndexer( have, decls );
    528515                AssertionSet newNeed;
    529                 AssertionParentSet needParents;
    530                 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, needParents, 0, indexer, out );
     516                inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out );
    531517//      PRINT(
    532518//          std::cerr << "declaration 14 is ";
  • src/ResolvExpr/RenameVars.cc

    r66999e7 r472ca32  
    4545        void RenameVars::visit( PointerType *pointerType ) {
    4646                typeBefore( pointerType );
     47///   std::cout << "do pointer" << std::endl;
    4748                maybeAccept( pointerType->get_base(), *this );
     49///   std::cout << "done pointer" << std::endl;
    4850                typeAfter( pointerType );
    4951        }
     
    5860        void RenameVars::visit( FunctionType *functionType ) {
    5961                typeBefore( functionType );
     62///   std::cout << "return vals" << std::endl;
    6063                acceptAll( functionType->get_returnVals(), *this );
     64///   std::cout << functionType->get_parameters().size() << " parameters" << std::endl;
    6165                acceptAll( functionType->get_parameters(), *this );
     66///   std::cout << "done function" << std::endl;
    6267                typeAfter( functionType );
    6368        }
     
    9095        void RenameVars::visit( TypeInstType *instType ) {
    9196                typeBefore( instType );
     97///   std::cout << "instance of type " << instType->get_name() << std::endl;
    9298                std::map< std::string, std::string >::const_iterator i = mapStack.front().find( instType->get_name() );
    9399                if ( i != mapStack.front().end() ) {
     100///     std::cout << "found name " << i->second << std::endl;
    94101                        instType->set_name( i->second );
    95102                } else {
     103///     std::cout << "no name found" << std::endl;
    96104                } // if
    97105                acceptAll( instType->get_parameters(), *this );
     
    112120        void RenameVars::typeBefore( Type *type ) {
    113121                if ( ! type->get_forall().empty() ) {
     122///     std::cout << "type with forall: ";
     123///     type->print( std::cout );
     124///     std::cout << std::endl;
    114125                        // copies current name mapping into new mapping
    115126                        mapStack.push_front( mapStack.front() );
  • src/ResolvExpr/typeops.h

    r66999e7 r472ca32  
    5454 
    5555        // in AdjustExprType.cc
    56         /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function
    5756        void adjustExprType( Type *&type, const TypeEnvironment &env, const SymTab::Indexer &indexer );
    5857
Note: See TracChangeset for help on using the changeset viewer.