Changeset b46e3bd for src/ResolvExpr
- Timestamp:
- Jul 17, 2017, 1:59:53 PM (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:
- 89be1c68
- Parents:
- a493682
- Location:
- src/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/ConversionCost.cc
ra493682 rb46e3bd 23 23 const Cost Cost::zero = Cost( 0, 0, 0 ); 24 24 const Cost Cost::infinity = Cost( -1, -1, -1 ); 25 const Cost Cost::unsafe = Cost( 1, 0, 0 ); 26 const Cost Cost::poly = Cost( 0, 1, 0 ); 27 const Cost Cost::safe = Cost( 0, 0, 1 ); 28 25 29 26 30 Cost conversionCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) { -
src/ResolvExpr/Cost.h
ra493682 rb46e3bd 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Cost.h -- 7 // Cost.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 23 23 public: 24 24 Cost(); 25 Cost( int unsafe , int poly, int safe);26 25 Cost( int unsafeCost, int polyCost, int safeCost ); 26 27 27 void incUnsafe( int inc = 1 ); 28 28 void incPoly( int inc = 1 ); 29 29 void incSafe( int inc = 1 ); 30 30 31 31 Cost operator+( const Cost &other ) const; 32 32 Cost operator-( const Cost &other ) const; … … 36 36 bool operator!=( const Cost &other ) const; 37 37 friend std::ostream &operator<<( std::ostream &os, const Cost &cost ); 38 38 39 39 static const Cost zero; 40 40 static const Cost infinity; 41 static const Cost unsafe; 42 static const Cost poly; 43 static const Cost safe; 41 44 private: 42 45 int compare( const Cost &other ) const; 43 46 44 int unsafe ;45 int poly ;46 int safe ;47 int unsafeCost; 48 int polyCost; 49 int safeCost; 47 50 }; 48 51 49 inline Cost::Cost() : unsafe ( 0 ), poly( 0 ), safe( 0 ) {}52 inline Cost::Cost() : unsafeCost( 0 ), polyCost( 0 ), safeCost( 0 ) {} 50 53 51 inline Cost::Cost( int unsafe , int poly, int safe ) : unsafe( unsafe ), poly( poly ), safe( safe) {}54 inline Cost::Cost( int unsafeCost, int polyCost, int safeCost ) : unsafeCost( unsafeCost ), polyCost( polyCost ), safeCost( safeCost ) {} 52 55 53 56 inline void Cost::incUnsafe( int inc ) { 54 unsafe += inc;57 unsafeCost += inc; 55 58 } 56 59 57 60 inline void Cost::incPoly( int inc ) { 58 poly += inc;61 polyCost += inc; 59 62 } 60 63 61 64 inline void Cost::incSafe( int inc ) { 62 safe += inc;65 safeCost += inc; 63 66 } 64 67 65 68 inline Cost Cost::operator+( const Cost &other ) const { 66 return Cost( unsafe + other.unsafe, poly + other.poly, safe + other.safe);69 return Cost( unsafeCost + other.unsafeCost, polyCost + other.polyCost, safeCost + other.safeCost ); 67 70 } 68 71 69 72 inline Cost Cost::operator-( const Cost &other ) const { 70 return Cost( unsafe - other.unsafe, poly - other.poly, safe - other.safe);73 return Cost( unsafeCost - other.unsafeCost, polyCost - other.polyCost, safeCost - other.safeCost ); 71 74 } 72 75 73 76 inline Cost &Cost::operator+=( const Cost &other ) { 74 unsafe += other.unsafe;75 poly += other.poly;76 safe += other.safe;77 unsafeCost += other.unsafeCost; 78 polyCost += other.polyCost; 79 safeCost += other.safeCost; 77 80 return *this; 78 81 } 79 82 80 83 inline bool Cost::operator<( const Cost &other ) const { 81 if ( *this == infinity ) return false; 82 if ( other == infinity ) return true; 83 if ( unsafe > other.unsafe ) { 84 if ( *this == infinity ) return false; 85 if ( other == infinity ) return true; 86 87 if ( unsafeCost > other.unsafeCost ) { 84 88 return false; 85 } else if ( unsafe < other.unsafe) {89 } else if ( unsafeCost < other.unsafeCost ) { 86 90 return true; 87 } else if ( poly > other.poly) {91 } else if ( polyCost > other.polyCost ) { 88 92 return false; 89 } else if ( poly < other.poly) {93 } else if ( polyCost < other.polyCost ) { 90 94 return true; 91 } else if ( safe > other.safe) {95 } else if ( safeCost > other.safeCost ) { 92 96 return false; 93 } else if ( safe < other.safe) {97 } else if ( safeCost < other.safeCost ) { 94 98 return true; 95 99 } else { 96 100 return false; 97 101 } // if 98 102 } 99 103 100 104 inline bool Cost::operator==( const Cost &other ) const { 101 return unsafe == other.unsafe102 && poly == other.poly103 && safe == other.safe;105 return unsafeCost == other.unsafeCost 106 && polyCost == other.polyCost 107 && safeCost == other.safeCost; 104 108 } 105 109 … … 109 113 110 114 inline std::ostream &operator<<( std::ostream &os, const Cost &cost ) { 111 os << "( " << cost.unsafe << ", " << cost.poly << ", " << cost.safe<< " )";115 os << "( " << cost.unsafeCost << ", " << cost.polyCost << ", " << cost.safeCost << " )"; 112 116 return os; 113 117 }
Note: See TracChangeset
for help on using the changeset viewer.