Changes in / [66999e7:472ca32]
- Location:
- src/ResolvExpr
- Files:
-
- 3 edited
-
AlternativeFinder.cc (modified) (9 diffs)
-
RenameVars.cc (modified) (4 diffs)
-
typeops.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r66999e7 r472ca32 19 19 #include <functional> 20 20 #include <cassert> 21 #include <unordered_map>22 #include <utility>23 #include <vector>24 21 25 22 #include "AlternativeFinder.h" … … 411 408 } 412 409 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; 418 411 419 412 void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) { … … 424 417 } 425 418 } 426 419 427 420 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 ) { 430 422 if ( begin == end ) { 431 423 if ( newNeed.empty() ) { … … 440 432 printAssertionSet( newNeed, std::cerr, 8 ); 441 433 ) 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 ); 443 435 return; 444 436 } … … 447 439 ForwardIterator cur = begin++; 448 440 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 ); 450 442 } 451 443 DeclarationWithType *curDecl = cur->first; … … 464 456 std::cerr << std::endl; 465 457 ) 466 467 458 AssertionSet newHave, newerNeed( newNeed ); 468 459 TypeEnvironment newEnv( newAlt.env ); … … 487 478 newerAlt.env = newEnv; 488 479 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() ) ) ); 494 481 deleteAll( varExpr->get_results() ); 495 482 varExpr->get_results().clear(); … … 505 492 // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions 506 493 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 ); 508 495 } else { 509 496 delete adjType; … … 527 514 addToIndexer( have, decls ); 528 515 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 ); 531 517 // PRINT( 532 518 // std::cerr << "declaration 14 is "; -
src/ResolvExpr/RenameVars.cc
r66999e7 r472ca32 45 45 void RenameVars::visit( PointerType *pointerType ) { 46 46 typeBefore( pointerType ); 47 /// std::cout << "do pointer" << std::endl; 47 48 maybeAccept( pointerType->get_base(), *this ); 49 /// std::cout << "done pointer" << std::endl; 48 50 typeAfter( pointerType ); 49 51 } … … 58 60 void RenameVars::visit( FunctionType *functionType ) { 59 61 typeBefore( functionType ); 62 /// std::cout << "return vals" << std::endl; 60 63 acceptAll( functionType->get_returnVals(), *this ); 64 /// std::cout << functionType->get_parameters().size() << " parameters" << std::endl; 61 65 acceptAll( functionType->get_parameters(), *this ); 66 /// std::cout << "done function" << std::endl; 62 67 typeAfter( functionType ); 63 68 } … … 90 95 void RenameVars::visit( TypeInstType *instType ) { 91 96 typeBefore( instType ); 97 /// std::cout << "instance of type " << instType->get_name() << std::endl; 92 98 std::map< std::string, std::string >::const_iterator i = mapStack.front().find( instType->get_name() ); 93 99 if ( i != mapStack.front().end() ) { 100 /// std::cout << "found name " << i->second << std::endl; 94 101 instType->set_name( i->second ); 95 102 } else { 103 /// std::cout << "no name found" << std::endl; 96 104 } // if 97 105 acceptAll( instType->get_parameters(), *this ); … … 112 120 void RenameVars::typeBefore( Type *type ) { 113 121 if ( ! type->get_forall().empty() ) { 122 /// std::cout << "type with forall: "; 123 /// type->print( std::cout ); 124 /// std::cout << std::endl; 114 125 // copies current name mapping into new mapping 115 126 mapStack.push_front( mapStack.front() ); -
src/ResolvExpr/typeops.h
r66999e7 r472ca32 54 54 55 55 // in AdjustExprType.cc 56 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function57 56 void adjustExprType( Type *&type, const TypeEnvironment &env, const SymTab::Indexer &indexer ); 58 57
Note:
See TracChangeset
for help on using the changeset viewer.