Changeset 150ec33
- Timestamp:
- Oct 19, 2017, 11:15:35 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- f232977
- Parents:
- d411426d
- git-author:
- Rob Schluntz <rschlunt@…> (10/13/17 16:03:35)
- git-committer:
- Rob Schluntz <rschlunt@…> (10/19/17 11:15:35)
- Location:
- src/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CastCost.cc
rd411426d r150ec33 24 24 #include "typeops.h" // for typesCompatibleIgnoreQualifiers 25 25 26 #if 0 27 #define PRINT(x) x 28 #else 29 #define PRINT(x) 30 #endif 26 31 27 32 namespace ResolvExpr { … … 52 57 } // if 53 58 } // if 59 60 PRINT( 61 std::cerr << "castCost ::: src is "; 62 src->print( std::cerr ); 63 std::cerr << std::endl << "dest is "; 64 dest->print( std::cerr ); 65 std::cerr << std::endl << "env is" << std::endl; 66 env.print( std::cerr, 8 ); 67 ) 68 54 69 if ( typesCompatibleIgnoreQualifiers( src, dest, indexer, env ) ) { 70 PRINT( std::cerr << "compatible!" << std::endl; ) 55 71 return Cost::zero; 56 72 } else if ( dynamic_cast< VoidType* >( dest ) ) { 57 73 return Cost::safe; 58 74 } else if ( ReferenceType * refType = dynamic_cast< ReferenceType * > ( dest ) ) { 75 PRINT( std::cerr << "conversionCost: dest is reference" << std::endl; ) 59 76 return convertToReferenceCost( src, refType, indexer, env, [](Type * t1, Type * t2, const TypeEnvironment & env, const SymTab::Indexer & indexer) { 60 77 return ptrsCastable( t1, t2, env, indexer ); -
src/ResolvExpr/ConversionCost.cc
rd411426d r150ec33 306 306 // recursively compute conversion cost from T1 to T2. 307 307 // cv can be safely dropped because of 'implicit dereference' behavior. 308 refType-> get_base()->accept( *this );309 if ( refType-> get_base()->get_qualifiers() == dest->get_qualifiers() ) {308 refType->base->accept( *this ); 309 if ( refType->base->get_qualifiers() == dest->get_qualifiers() ) { 310 310 cost.incReference(); // prefer exact qualifiers 311 } else if ( refType-> get_base()->get_qualifiers() < dest->get_qualifiers() ) {311 } else if ( refType->base->get_qualifiers() < dest->get_qualifiers() ) { 312 312 cost.incSafe(); // then gaining qualifiers 313 313 } else { … … 321 321 void ConversionCost::visit(StructInstType *inst) { 322 322 if ( StructInstType *destAsInst = dynamic_cast< StructInstType* >( dest ) ) { 323 if ( inst-> get_name() == destAsInst->get_name()) {323 if ( inst->name == destAsInst->name ) { 324 324 cost = Cost::zero; 325 325 } // if … … 328 328 329 329 void ConversionCost::visit(UnionInstType *inst) { 330 if ( StructInstType *destAsInst = dynamic_cast< StructInstType* >( dest ) ) {331 if ( inst-> get_name() == destAsInst->get_name()) {330 if ( UnionInstType *destAsInst = dynamic_cast< UnionInstType* >( dest ) ) { 331 if ( inst->name == destAsInst->name ) { 332 332 cost = Cost::zero; 333 333 } // if
Note: See TracChangeset
for help on using the changeset viewer.