Changeset 7d01cf44 for src/ResolvExpr/CastCost.cc
- Timestamp:
- Aug 12, 2019, 1:47:37 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 14388c1, e0bd0f9
- Parents:
- 4f5a8a2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CastCost.cc
r4f5a8a2 r7d01cf44 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 06:57:43 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Feb 2 15:34:36 201613 // Update Count : 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Aug 8 16:12:00 2019 13 // Update Count : 8 14 14 // 15 15 … … 37 37 struct CastCost_old : public ConversionCost { 38 38 public: 39 CastCost_old( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc ); 39 CastCost_old( const Type * dest, bool srcIsLvalue, 40 const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc ); 40 41 41 42 using ConversionCost::previsit; … … 45 46 }; 46 47 47 Cost castCost( const Type * src, const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) { 48 Cost castCost( const Type * src, const Type * dest, bool srcIsLvalue, 49 const SymTab::Indexer &indexer, const TypeEnvironment &env ) { 48 50 if ( const TypeInstType * destAsTypeInst = dynamic_cast< const TypeInstType * >( dest ) ) { 49 51 if ( const EqvClass * eqvClass = env.lookup( destAsTypeInst->name ) ) { 50 52 if ( eqvClass->type ) { 51 return castCost( src, eqvClass->type, indexer, env );53 return castCost( src, eqvClass->type, srcIsLvalue, indexer, env ); 52 54 } else { 53 55 return Cost::infinity; … … 57 59 const TypeDecl * type = strict_dynamic_cast< const TypeDecl * >( namedType ); 58 60 if ( type->base ) { 59 return castCost( src, type->base, indexer, env ) + Cost::safe;61 return castCost( src, type->base, srcIsLvalue, indexer, env ) + Cost::safe; 60 62 } // if 61 63 } // if … … 78 80 } else if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * > ( dest ) ) { 79 81 PRINT( std::cerr << "conversionCost: dest is reference" << std::endl; ) 80 return convertToReferenceCost( src, refType, indexer, env, [](const Type * t1, const Type * t2, const SymTab::Indexer & indexer, const TypeEnvironment & env ) {82 return convertToReferenceCost( src, refType, srcIsLvalue, indexer, env, [](const Type * t1, const Type * t2, const SymTab::Indexer & indexer, const TypeEnvironment & env ) { 81 83 return ptrsCastable( t1, t2, env, indexer ); 82 84 }); 83 85 } else { 84 86 PassVisitor<CastCost_old> converter( 85 dest, indexer, env,86 (Cost (*)( const Type *, const Type *, const SymTab::Indexer &, const TypeEnvironment & ))87 dest, srcIsLvalue, indexer, env, 88 (Cost (*)( const Type *, const Type *, bool, const SymTab::Indexer &, const TypeEnvironment & )) 87 89 castCost ); 88 90 src->accept( converter ); … … 96 98 } 97 99 98 CastCost_old::CastCost_old( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc ) 99 : ConversionCost( dest, indexer, env, costFunc ) { 100 CastCost_old::CastCost_old( const Type * dest, bool srcIsLvalue, 101 const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc ) 102 : ConversionCost( dest, srcIsLvalue, indexer, env, costFunc ) { 100 103 } 101 104 … … 106 109 cost = Cost::unsafe; 107 110 } else { 108 cost = conversionCost( basicType, dest, indexer, env );111 cost = conversionCost( basicType, dest, srcIsLvalue, indexer, env ); 109 112 } // if 110 113 }
Note: See TracChangeset
for help on using the changeset viewer.