Changes in / [d06010a:85f0713]
- Location:
- src
- Files:
-
- 4 edited
-
ResolvExpr/AlternativeFinder.cc (modified) (9 diffs)
-
ResolvExpr/RenameVars.cc (modified) (4 diffs)
-
ResolvExpr/typeops.h (modified) (1 diff)
-
tests/test.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
rd06010a r85f0713 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
rd06010a r85f0713 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
rd06010a r85f0713 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 -
src/tests/test.py
rd06010a r85f0713 21 21 return list 22 22 23 def sh(cmd, dry_run = False, print2stdout = True):23 def sh(cmd, dry_run): 24 24 if dry_run : 25 25 print("cmd: %s" % cmd) 26 return 0 , None26 return 0 27 27 else : 28 proc = Popen(cmd, std out=None if print2stdout else PIPE, stderr=STDOUT, shell=True)29 out, err =proc.communicate()30 return proc.returncode , out28 proc = Popen(cmd, stderr=STDOUT, shell=True) 29 proc.communicate() 30 return proc.returncode 31 31 32 32 def file_replace(fname, pat, s_after): … … 61 61 62 62 # build, skipping to next test on error 63 make_ret , _= sh("%s %s 2> %s 1> /dev/null" % (make_cmd, test, out_file), dry_run)63 make_ret = sh("%s %s 2> %s 1> /dev/null" % (make_cmd, test, out_file), dry_run) 64 64 65 65 if make_ret == 0 : … … 71 71 72 72 retcode = 0 73 error = None74 73 75 74 fix_MakeLevel(out_file) … … 77 76 if not generate : 78 77 # diff the output of the files 79 diff_cmd = ("diff --old-group-format='\t\tmissing lines :\n" 80 "%%<' \\\n" 81 "--new-group-format='\t\tnew lines :\n" 82 "%%>' \\\n" 83 "--unchanged-group-format='%%=' \\" 84 "--changed-group-format='\t\texpected :\n" 85 "%%<\n" 86 "\t\tgot :\n" 87 "%%>' \\\n" 88 "--new-line-format='\t\t%%dn\t%%L' \\\n" 89 "--old-line-format='\t\t%%dn\t%%L' \\\n" 90 "--unchanged-line-format='' \\\n" 91 ".expect/%s.txt .out/%s.log") 92 93 retcode, error = sh(diff_cmd % (test, test), dry_run, False) 78 retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run) 94 79 95 80 # clean the executable 96 81 sh("rm -f %s > /dev/null 2>&1" % test, dry_run) 97 82 98 return retcode , error83 return retcode 99 84 100 85 def run_tests(tests, generate, dry_run) : … … 109 94 print("%20s " % t, end="") 110 95 sys.stdout.flush() 111 test_failed , error= run_test_instance(t, generate, dry_run)96 test_failed = run_test_instance(t, generate, dry_run) 112 97 failed = test_failed or failed 113 98 114 99 if not generate : 115 100 print("FAILED" if test_failed else "PASSED") 116 if error :117 print(error)118 101 else : 119 102 print( "Done" )
Note:
See TracChangeset
for help on using the changeset viewer.