Changeset 6ed1d4b for src/ResolvExpr
- Timestamp:
- Feb 23, 2016, 11:05:01 AM (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, string, with_gc
- Children:
- 6ce67ce
- Parents:
- bd85400
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
rbd85400 r6ed1d4b 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 : Peter A. Buhr12 // Last Modified On : Fri Jul 3 17:58:39 201513 // Update Count : 2 211 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Feb 10 17:00:04 2016 13 // Update Count : 24 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 out<< "cost " << candidate->cost << " beats " << mapPlace->second.candidate->cost << std::endl;109 std::cerr << "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 out<< "marking ambiguous" << std::endl;114 std::cerr << "marking ambiguous" << std::endl; 115 115 ) 116 116 mapPlace->second.isAmbiguous = true; … … 122 122 123 123 PRINT( 124 std::c out<< "there are " << selected.size() << " alternatives before elimination" << std::endl;124 std::cerr << "there are " << selected.size() << " alternatives before elimination" << std::endl; 125 125 ) 126 126 … … 182 182 begin++; 183 183 PRINT( 184 std::c out<< "findSubExprs" << std::endl;185 printAlts( finder.alternatives, std::c out);184 std::cerr << "findSubExprs" << std::endl; 185 printAlts( finder.alternatives, std::cerr ); 186 186 ) 187 187 *out++ = finder; … … 204 204 } 205 205 PRINT( 206 std::c out<< "alternatives before prune:" << std::endl;207 printAlts( alternatives, std::c out);206 std::cerr << "alternatives before prune:" << std::endl; 207 printAlts( alternatives, std::cerr ); 208 208 ) 209 209 AltList::iterator oldBegin = alternatives.begin(); … … 221 221 alternatives.erase( oldBegin, alternatives.end() ); 222 222 PRINT( 223 std::c out<< "there are " << alternatives.size() << " alternatives after elimination" << std::endl;223 std::cerr << "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 out<< "actual expression:" << std::endl;264 (*actualExpr)->print( std::c out, 8 );265 std::c out<< "--- results are" << std::endl;266 printAll( (*actualExpr)->get_results(), std::c out, 8 );263 std::cerr << "actual expression:" << std::endl; 264 (*actualExpr)->print( std::cerr, 8 ); 265 std::cerr << "--- results are" << std::endl; 266 printAll( (*actualExpr)->get_results(), std::cerr, 8 ); 267 267 ) 268 268 std::list< DeclarationWithType* >::iterator startFormal = formal; … … 278 278 } 279 279 PRINT( 280 std::c out<< std::endl << "converting ";281 (*actual)->print( std::c out, 8 );282 std::c out<< std::endl << " to ";283 (*formal)->get_type()->print( std::c out, 8 );280 std::cerr << std::endl << "converting "; 281 (*actual)->print( std::cerr, 8 ); 282 std::cerr << std::endl << " to "; 283 (*formal)->get_type()->print( std::cerr, 8 ); 284 284 ) 285 285 Cost newCost = conversionCost( *actual, (*formal)->get_type(), indexer, alt.env ); 286 286 PRINT( 287 std::c out<< std::endl << "cost is" << newCost << std::endl;287 std::cerr << 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 out<< std::endl << "converting ";326 assert->second.actualType->print( std::c out, 8 );327 std::c out<< std::endl << " to ";328 assert->second.formalType->print( std::c out, 8 );325 std::cerr << std::endl << "converting "; 326 assert->second.actualType->print( std::cerr, 8 ); 327 std::cerr << std::endl << " to "; 328 assert->second.formalType->print( std::cerr, 8 ); 329 329 ) 330 330 Cost newCost = conversionCost( assert->second.actualType, assert->second.formalType, indexer, alt.env ); 331 331 PRINT( 332 std::c out<< std::endl << "cost of conversion is " << newCost << std::endl;332 std::cerr << 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 out<< "no candidates!" << std::endl; }450 /// if ( candidates.empty() ) { std::cerr << "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 out<< "inferRecursive: candidate is ";454 (*candidate)->print( std::c out);455 std::c out<< std::endl;453 std::cerr << "inferRecursive: candidate is "; 454 (*candidate)->print( std::cerr ); 455 std::cerr << 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 out<< "satisfying assertion " << curDecl->get_uniqueId() << " ";485 curDecl->print( std::c out);486 std::c out<< " with declaration " << (*candidate)->get_uniqueId() << " ";487 (*candidate)->print( std::c out);488 std::c out<< std::endl;484 std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " "; 485 curDecl->print( std::cerr ); 486 std::cerr << " with declaration " << (*candidate)->get_uniqueId() << " "; 487 (*candidate)->print( std::cerr ); 488 std::cerr << 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 out<< "inferParameters: assertions needed are" << std::endl;504 // printAll( need, std::c out, 8 );503 // std::cerr << "inferParameters: assertions needed are" << std::endl; 504 // printAll( need, std::cerr, 8 ); 505 505 // ) 506 506 SymTab::Indexer decls( indexer ); 507 507 PRINT( 508 std::c out<< "============= original indexer" << std::endl;509 indexer.print( std::c out);510 std::c out<< "============= new indexer" << std::endl;511 decls.print( std::c out);508 std::cerr << "============= original indexer" << std::endl; 509 indexer.print( std::cerr ); 510 std::cerr << "============= new indexer" << std::endl; 511 decls.print( std::cerr ); 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 out<< "declaration 14 is ";517 // std::cerr << "declaration 14 is "; 518 518 // Declaration::declFromId 519 519 // *out++ = newAlt; … … 532 532 makeExprList( actualAlt, appExpr->get_args() ); 533 533 PRINT( 534 std::c out<< "need assertions:" << std::endl;535 printAssertionSet( resultNeed, std::c out, 8 );534 std::cerr << "need assertions:" << std::endl; 535 printAssertionSet( resultNeed, std::cerr, 8 ); 536 536 ) 537 537 inferParameters( resultNeed, resultHave, newAlt, openVars, out ); … … 543 543 AlternativeFinder funcOpFinder( indexer, env ); 544 544 545 AlternativeFinder funcFinder( indexer, env ); { 545 AlternativeFinder funcFinder( indexer, env ); 546 547 { 546 548 NameExpr *fname = 0;; 547 549 if ( ( fname = dynamic_cast<NameExpr *>( untypedExpr->get_function())) … … 573 575 for ( AltList::const_iterator func = funcFinder.alternatives.begin(); func != funcFinder.alternatives.end(); ++func ) { 574 576 PRINT( 575 std::c out<< "working on alternative: " << std::endl;576 func->print( std::c out, 8 );577 std::cerr << "working on alternative: " << std::endl; 578 func->print( std::cerr, 8 ); 577 579 ) 578 580 // check if the type is pointer to function … … 606 608 } 607 609 PRINT( 608 std::c out<< "known function ops:" << std::endl;609 printAlts( funcOpFinder.alternatives, std::c out, 8 );610 std::cerr << "known function ops:" << std::endl; 611 printAlts( funcOpFinder.alternatives, std::cerr, 8 ); 610 612 ) 611 613 } … … 639 641 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 640 642 assert( function ); 641 std::c out<< "Case +++++++++++++" << std::endl;642 std::c out<< "formals are:" << std::endl;643 printAll( function->get_parameters(), std::c out, 8 );644 std::c out<< "actuals are:" << std::endl;645 printAll( appExpr->get_args(), std::c out, 8 );646 std::c out<< "bindings are:" << std::endl;647 withFunc->env.print( std::c out, 8 );648 std::c out<< "cost of conversion is:" << cvtCost << std::endl;643 std::cerr << "Case +++++++++++++" << std::endl; 644 std::cerr << "formals are:" << std::endl; 645 printAll( function->get_parameters(), std::cerr, 8 ); 646 std::cerr << "actuals are:" << std::endl; 647 printAll( appExpr->get_args(), std::cerr, 8 ); 648 std::cerr << "bindings are:" << std::endl; 649 withFunc->env.print( std::cerr, 8 ); 650 std::cerr << "cost of conversion is:" << cvtCost << std::endl; 649 651 ) 650 652 if ( cvtCost != Cost::infinity ) { … … 824 826 } 825 827 } 826 828 827 829 void AlternativeFinder::visit( UntypedOffsetofExpr *offsetofExpr ) { 828 830 AlternativeFinder funcFinder( indexer, env ); … … 833 835 } 834 836 } 835 837 836 838 void AlternativeFinder::visit( OffsetofExpr *offsetofExpr ) { 837 839 alternatives.push_back( Alternative( offsetofExpr->clone(), env, Cost::zero ) ); … … 843 845 assert( function->get_parameters().size() == 1 ); 844 846 PRINT( 845 std::c out<< "resolvAttr: funcDecl is ";846 funcDecl->print( std::c out);847 std::c out<< " argType is ";848 argType->print( std::c out);849 std::c out<< std::endl;847 std::cerr << "resolvAttr: funcDecl is "; 848 funcDecl->print( std::cerr ); 849 std::cerr << " argType is "; 850 argType->print( std::cerr ); 851 std::cerr << std::endl; 850 852 ) 851 853 if ( typesCompatibleIgnoreQualifiers( argType, function->get_parameters().front()->get_type(), indexer, env ) ) {
Note: See TracChangeset
for help on using the changeset viewer.