Changeset 7ebaa56 for src/ResolvExpr/Cost.h
- Timestamp:
- Jul 17, 2017, 3:05:57 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:
- e6cee92
- Parents:
- 89be1c68
- git-author:
- Rob Schluntz <rschlunt@…> (07/17/17 14:58:13)
- git-committer:
- Rob Schluntz <rschlunt@…> (07/17/17 15:05:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Cost.h
r89be1c68 r7ebaa56 22 22 class Cost { 23 23 private: 24 Cost( int unsafeCost, int polyCost, int safeCost );24 Cost( int unsafeCost, int polyCost, int safeCost, int referenceCost ); 25 25 26 26 public: … … 28 28 Cost & incPoly( int inc = 1 ); 29 29 Cost & incSafe( int inc = 1 ); 30 Cost & incReference( int inc = 1 ); 30 31 31 32 Cost operator+( const Cost &other ) const; … … 39 40 static const Cost zero; 40 41 static const Cost infinity; 42 41 43 static const Cost unsafe; 42 44 static const Cost poly; 43 45 static const Cost safe; 46 static const Cost reference; 44 47 private: 45 48 int compare( const Cost &other ) const; … … 48 51 int polyCost; 49 52 int safeCost; 53 int referenceCost; 50 54 }; 51 55 52 inline Cost::Cost( int unsafeCost, int polyCost, int safeCost ) : unsafeCost( unsafeCost ), polyCost( polyCost ), safeCost( safeCost ) {}56 inline Cost::Cost( int unsafeCost, int polyCost, int safeCost, int referenceCost ) : unsafeCost( unsafeCost ), polyCost( polyCost ), safeCost( safeCost ), referenceCost( referenceCost ) {} 53 57 54 58 inline Cost & Cost::incUnsafe( int inc ) { … … 67 71 } 68 72 73 inline Cost & Cost::incReference( int inc ) { 74 referenceCost += inc; 75 return *this; 76 } 77 69 78 inline Cost Cost::operator+( const Cost &other ) const { 70 return Cost( unsafeCost + other.unsafeCost, polyCost + other.polyCost, safeCost + other.safeCost );79 return Cost( unsafeCost + other.unsafeCost, polyCost + other.polyCost, safeCost + other.safeCost, referenceCost + other.referenceCost ); 71 80 } 72 81 73 82 inline Cost Cost::operator-( const Cost &other ) const { 74 return Cost( unsafeCost - other.unsafeCost, polyCost - other.polyCost, safeCost - other.safeCost );83 return Cost( unsafeCost - other.unsafeCost, polyCost - other.polyCost, safeCost - other.safeCost, referenceCost - other.referenceCost ); 75 84 } 76 85 … … 79 88 polyCost += other.polyCost; 80 89 safeCost += other.safeCost; 90 referenceCost += other.referenceCost; 81 91 return *this; 82 92 } … … 98 108 } else if ( safeCost < other.safeCost ) { 99 109 return true; 110 } else if ( referenceCost > other.referenceCost ) { 111 return false; 112 } else if ( referenceCost < other.referenceCost ) { 113 return true; 100 114 } else { 101 115 return false; … … 106 120 return unsafeCost == other.unsafeCost 107 121 && polyCost == other.polyCost 108 && safeCost == other.safeCost; 122 && safeCost == other.safeCost 123 && referenceCost == other.referenceCost; 109 124 } 110 125 … … 114 129 115 130 inline std::ostream &operator<<( std::ostream &os, const Cost &cost ) { 116 os << "( " << cost.unsafeCost << ", " << cost.polyCost << ", " << cost.safeCost << " )";131 os << "( " << cost.unsafeCost << ", " << cost.polyCost << ", " << cost.safeCost << ", " << cost.referenceCost << " )"; 117 132 return os; 118 133 }
Note: See TracChangeset
for help on using the changeset viewer.