Changes in / [6ce67ce:4318107]
- File:
-
- 1 edited
-
src/ResolvExpr/AlternativeFinder.cc (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r6ce67ce r4318107 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // AlternativeFinder.cc -- 7 // AlternativeFinder.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sat May 16 23:52:08 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Feb 10 17:00:04 201613 // Update Count : 2 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 3 17:58:39 2015 13 // Update Count : 22 14 14 // 15 15 … … 41 41 42 42 extern bool resolvep; 43 #define PRINT( text ) if ( resolvep ) { text } 43 #define PRINT( text ) if ( resolvep ) { text } 44 44 //#define DEBUG_COST 45 45 … … 107 107 if ( candidate->cost < mapPlace->second.candidate->cost ) { 108 108 PRINT( 109 std::c err<< "cost " << candidate->cost << " beats " << mapPlace->second.candidate->cost << std::endl;109 std::cout << "cost " << candidate->cost << " beats " << mapPlace->second.candidate->cost << std::endl; 110 110 ) 111 111 selected[ mangleName ] = current; 112 112 } else if ( candidate->cost == mapPlace->second.candidate->cost ) { 113 113 PRINT( 114 std::c err<< "marking ambiguous" << std::endl;114 std::cout << "marking ambiguous" << std::endl; 115 115 ) 116 116 mapPlace->second.isAmbiguous = true; … … 122 122 123 123 PRINT( 124 std::c err<< "there are " << selected.size() << " alternatives before elimination" << std::endl;124 std::cout << "there are " << selected.size() << " alternatives before elimination" << std::endl; 125 125 ) 126 126 … … 182 182 begin++; 183 183 PRINT( 184 std::c err<< "findSubExprs" << std::endl;185 printAlts( finder.alternatives, std::c err);184 std::cout << "findSubExprs" << std::endl; 185 printAlts( finder.alternatives, std::cout ); 186 186 ) 187 187 *out++ = finder; … … 204 204 } 205 205 PRINT( 206 std::c err<< "alternatives before prune:" << std::endl;207 printAlts( alternatives, std::c err);206 std::cout << "alternatives before prune:" << std::endl; 207 printAlts( alternatives, std::cout ); 208 208 ) 209 209 AltList::iterator oldBegin = alternatives.begin(); … … 221 221 alternatives.erase( oldBegin, alternatives.end() ); 222 222 PRINT( 223 std::c err<< "there are " << alternatives.size() << " alternatives after elimination" << std::endl;223 std::cout << "there are " << alternatives.size() << " alternatives after elimination" << std::endl; 224 224 ) 225 225 } … … 261 261 for ( std::list< Expression* >::iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) { 262 262 PRINT( 263 std::c err<< "actual expression:" << std::endl;264 (*actualExpr)->print( std::c err, 8 );265 std::c err<< "--- results are" << std::endl;266 printAll( (*actualExpr)->get_results(), std::c err, 8 );263 std::cout << "actual expression:" << std::endl; 264 (*actualExpr)->print( std::cout, 8 ); 265 std::cout << "--- results are" << std::endl; 266 printAll( (*actualExpr)->get_results(), std::cout, 8 ); 267 267 ) 268 268 std::list< DeclarationWithType* >::iterator startFormal = formal; … … 278 278 } 279 279 PRINT( 280 std::c err<< std::endl << "converting ";281 (*actual)->print( std::c err, 8 );282 std::c err<< std::endl << " to ";283 (*formal)->get_type()->print( std::c err, 8 );280 std::cout << std::endl << "converting "; 281 (*actual)->print( std::cout, 8 ); 282 std::cout << std::endl << " to "; 283 (*formal)->get_type()->print( std::cout, 8 ); 284 284 ) 285 285 Cost newCost = conversionCost( *actual, (*formal)->get_type(), indexer, alt.env ); 286 286 PRINT( 287 std::c err<< std::endl << "cost is" << newCost << std::endl;287 std::cout << std::endl << "cost is" << newCost << std::endl; 288 288 ) 289 289 … … 323 323 for ( InferredParams::const_iterator assert = appExpr->get_inferParams().begin(); assert != appExpr->get_inferParams().end(); ++assert ) { 324 324 PRINT( 325 std::c err<< std::endl << "converting ";326 assert->second.actualType->print( std::c err, 8 );327 std::c err<< std::endl << " to ";328 assert->second.formalType->print( std::c err, 8 );325 std::cout << std::endl << "converting "; 326 assert->second.actualType->print( std::cout, 8 ); 327 std::cout << std::endl << " to "; 328 assert->second.formalType->print( std::cout, 8 ); 329 329 ) 330 330 Cost newCost = conversionCost( assert->second.actualType, assert->second.formalType, indexer, alt.env ); 331 331 PRINT( 332 std::c err<< std::endl << "cost of conversion is " << newCost << std::endl;332 std::cout << std::endl << "cost of conversion is " << newCost << std::endl; 333 333 ) 334 334 if ( newCost == Cost::infinity ) { … … 448 448 std::list< DeclarationWithType* > candidates; 449 449 decls.lookupId( curDecl->get_name(), candidates ); 450 /// if ( candidates.empty() ) { std::c err<< "no candidates!" << std::endl; }450 /// if ( candidates.empty() ) { std::cout << "no candidates!" << std::endl; } 451 451 for ( std::list< DeclarationWithType* >::const_iterator candidate = candidates.begin(); candidate != candidates.end(); ++candidate ) { 452 452 PRINT( 453 std::c err<< "inferRecursive: candidate is ";454 (*candidate)->print( std::c err);455 std::c err<< std::endl;453 std::cout << "inferRecursive: candidate is "; 454 (*candidate)->print( std::cout ); 455 std::cout << std::endl; 456 456 ) 457 457 AssertionSet newHave, newerNeed( newNeed ); … … 482 482 varExpr->get_results().push_front( adjType->clone() ); 483 483 PRINT( 484 std::c err<< "satisfying assertion " << curDecl->get_uniqueId() << " ";485 curDecl->print( std::c err);486 std::c err<< " with declaration " << (*candidate)->get_uniqueId() << " ";487 (*candidate)->print( std::c err);488 std::c err<< std::endl;484 std::cout << "satisfying assertion " << curDecl->get_uniqueId() << " "; 485 curDecl->print( std::cout ); 486 std::cout << " with declaration " << (*candidate)->get_uniqueId() << " "; 487 (*candidate)->print( std::cout ); 488 std::cout << std::endl; 489 489 ) 490 490 ApplicationExpr *appExpr = static_cast< ApplicationExpr* >( newerAlt.expr ); … … 501 501 void AlternativeFinder::inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out ) { 502 502 // PRINT( 503 // std::c err<< "inferParameters: assertions needed are" << std::endl;504 // printAll( need, std::c err, 8 );503 // std::cout << "inferParameters: assertions needed are" << std::endl; 504 // printAll( need, std::cout, 8 ); 505 505 // ) 506 506 SymTab::Indexer decls( indexer ); 507 507 PRINT( 508 std::c err<< "============= original indexer" << std::endl;509 indexer.print( std::c err);510 std::c err<< "============= new indexer" << std::endl;511 decls.print( std::c err);508 std::cout << "============= original indexer" << std::endl; 509 indexer.print( std::cout ); 510 std::cout << "============= new indexer" << std::endl; 511 decls.print( std::cout ); 512 512 ) 513 513 addToIndexer( have, decls ); … … 515 515 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out ); 516 516 // PRINT( 517 // std::c err<< "declaration 14 is ";517 // std::cout << "declaration 14 is "; 518 518 // Declaration::declFromId 519 519 // *out++ = newAlt; … … 532 532 makeExprList( actualAlt, appExpr->get_args() ); 533 533 PRINT( 534 std::c err<< "need assertions:" << std::endl;535 printAssertionSet( resultNeed, std::c err, 8 );534 std::cout << "need assertions:" << std::endl; 535 printAssertionSet( resultNeed, std::cout, 8 ); 536 536 ) 537 537 inferParameters( resultNeed, resultHave, newAlt, openVars, out ); … … 543 543 AlternativeFinder funcOpFinder( indexer, env ); 544 544 545 AlternativeFinder funcFinder( indexer, env ); 546 547 { 545 AlternativeFinder funcFinder( indexer, env ); { 548 546 NameExpr *fname = 0;; 549 547 if ( ( fname = dynamic_cast<NameExpr *>( untypedExpr->get_function())) … … 575 573 for ( AltList::const_iterator func = funcFinder.alternatives.begin(); func != funcFinder.alternatives.end(); ++func ) { 576 574 PRINT( 577 std::c err<< "working on alternative: " << std::endl;578 func->print( std::c err, 8 );575 std::cout << "working on alternative: " << std::endl; 576 func->print( std::cout, 8 ); 579 577 ) 580 578 // check if the type is pointer to function … … 608 606 } 609 607 PRINT( 610 std::c err<< "known function ops:" << std::endl;611 printAlts( funcOpFinder.alternatives, std::c err, 8 );608 std::cout << "known function ops:" << std::endl; 609 printAlts( funcOpFinder.alternatives, std::cout, 8 ); 612 610 ) 613 611 } … … 641 639 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 642 640 assert( function ); 643 std::c err<< "Case +++++++++++++" << std::endl;644 std::c err<< "formals are:" << std::endl;645 printAll( function->get_parameters(), std::c err, 8 );646 std::c err<< "actuals are:" << std::endl;647 printAll( appExpr->get_args(), std::c err, 8 );648 std::c err<< "bindings are:" << std::endl;649 withFunc->env.print( std::c err, 8 );650 std::c err<< "cost of conversion is:" << cvtCost << std::endl;641 std::cout << "Case +++++++++++++" << std::endl; 642 std::cout << "formals are:" << std::endl; 643 printAll( function->get_parameters(), std::cout, 8 ); 644 std::cout << "actuals are:" << std::endl; 645 printAll( appExpr->get_args(), std::cout, 8 ); 646 std::cout << "bindings are:" << std::endl; 647 withFunc->env.print( std::cout, 8 ); 648 std::cout << "cost of conversion is:" << cvtCost << std::endl; 651 649 ) 652 650 if ( cvtCost != Cost::infinity ) { … … 826 824 } 827 825 } 828 826 829 827 void AlternativeFinder::visit( UntypedOffsetofExpr *offsetofExpr ) { 830 828 AlternativeFinder funcFinder( indexer, env ); … … 835 833 } 836 834 } 837 835 838 836 void AlternativeFinder::visit( OffsetofExpr *offsetofExpr ) { 839 837 alternatives.push_back( Alternative( offsetofExpr->clone(), env, Cost::zero ) ); … … 845 843 assert( function->get_parameters().size() == 1 ); 846 844 PRINT( 847 std::c err<< "resolvAttr: funcDecl is ";848 funcDecl->print( std::c err);849 std::c err<< " argType is ";850 argType->print( std::c err);851 std::c err<< std::endl;845 std::cout << "resolvAttr: funcDecl is "; 846 funcDecl->print( std::cout ); 847 std::cout << " argType is "; 848 argType->print( std::cout ); 849 std::cout << std::endl; 852 850 ) 853 851 if ( typesCompatibleIgnoreQualifiers( argType, function->get_parameters().front()->get_type(), indexer, env ) ) {
Note:
See TracChangeset
for help on using the changeset viewer.