Changeset d06010a for src/ResolvExpr
- Timestamp:
- Jun 29, 2016, 1:57:32 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 2fb2ad5
- Parents:
- 85f0713 (diff), 66999e7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/ResolvExpr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ResolvExpr/AlternativeFinder.cc ¶
r85f0713 rd06010a 19 19 #include <functional> 20 20 #include <cassert> 21 #include <unordered_map> 22 #include <utility> 23 #include <vector> 21 24 22 25 #include "AlternativeFinder.h" … … 408 411 } 409 412 410 static const int recursionLimit = 10; 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 411 418 412 419 void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) { … … 417 424 } 418 425 } 419 426 420 427 template< typename ForwardIterator, typename OutputIterator > 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 ) { 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 ) { 422 430 if ( begin == end ) { 423 431 if ( newNeed.empty() ) { … … 432 440 printAssertionSet( newNeed, std::cerr, 8 ); 433 441 ) 434 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out );442 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, needParents, level+1, indexer, out ); 435 443 return; 436 444 } … … 439 447 ForwardIterator cur = begin++; 440 448 if ( ! cur->second ) { 441 inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out );449 inferRecursive( begin, end, newAlt, openVars, decls, newNeed, needParents, level, indexer, out ); 442 450 } 443 451 DeclarationWithType *curDecl = cur->first; … … 456 464 std::cerr << std::endl; 457 465 ) 466 458 467 AssertionSet newHave, newerNeed( newNeed ); 459 468 TypeEnvironment newEnv( newAlt.env ); … … 478 487 newerAlt.env = newEnv; 479 488 assert( (*candidate)->get_uniqueId() ); 480 Expression *varExpr = new VariableExpr( static_cast< DeclarationWithType* >( Declaration::declFromId( (*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 ); 481 494 deleteAll( varExpr->get_results() ); 482 495 varExpr->get_results().clear(); … … 492 505 // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions 493 506 appExpr->get_inferParams()[ curDecl->get_uniqueId() ] = ParamEntry( (*candidate)->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr ); 494 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );507 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, newNeedParents, level, indexer, out ); 495 508 } else { 496 509 delete adjType; … … 514 527 addToIndexer( have, decls ); 515 528 AssertionSet newNeed; 516 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out ); 529 AssertionParentSet needParents; 530 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, needParents, 0, indexer, out ); 517 531 // PRINT( 518 532 // std::cerr << "declaration 14 is "; -
TabularUnified src/ResolvExpr/RenameVars.cc ¶
r85f0713 rd06010a 45 45 void RenameVars::visit( PointerType *pointerType ) { 46 46 typeBefore( pointerType ); 47 /// std::cout << "do pointer" << std::endl;48 47 maybeAccept( pointerType->get_base(), *this ); 49 /// std::cout << "done pointer" << std::endl;50 48 typeAfter( pointerType ); 51 49 } … … 60 58 void RenameVars::visit( FunctionType *functionType ) { 61 59 typeBefore( functionType ); 62 /// std::cout << "return vals" << std::endl;63 60 acceptAll( functionType->get_returnVals(), *this ); 64 /// std::cout << functionType->get_parameters().size() << " parameters" << std::endl;65 61 acceptAll( functionType->get_parameters(), *this ); 66 /// std::cout << "done function" << std::endl;67 62 typeAfter( functionType ); 68 63 } … … 95 90 void RenameVars::visit( TypeInstType *instType ) { 96 91 typeBefore( instType ); 97 /// std::cout << "instance of type " << instType->get_name() << std::endl;98 92 std::map< std::string, std::string >::const_iterator i = mapStack.front().find( instType->get_name() ); 99 93 if ( i != mapStack.front().end() ) { 100 /// std::cout << "found name " << i->second << std::endl;101 94 instType->set_name( i->second ); 102 95 } else { 103 /// std::cout << "no name found" << std::endl;104 96 } // if 105 97 acceptAll( instType->get_parameters(), *this ); … … 120 112 void RenameVars::typeBefore( Type *type ) { 121 113 if ( ! type->get_forall().empty() ) { 122 /// std::cout << "type with forall: ";123 /// type->print( std::cout );124 /// std::cout << std::endl;125 114 // copies current name mapping into new mapping 126 115 mapStack.push_front( mapStack.front() ); -
TabularUnified src/ResolvExpr/typeops.h ¶
r85f0713 rd06010a 54 54 55 55 // in AdjustExprType.cc 56 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function 56 57 void adjustExprType( Type *&type, const TypeEnvironment &env, const SymTab::Indexer &indexer ); 57 58
Note: See TracChangeset
for help on using the changeset viewer.