| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of _interceptors; | 5 part of _interceptors; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler | 8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler |
| 9 * recognizes this class as an interceptor, and changes references to | 9 * recognizes this class as an interceptor, and changes references to |
| 10 * [:this:] to actually use the receiver of the method, which is | 10 * [:this:] to actually use the receiver of the method, which is |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 double roundToDouble() { | 87 double roundToDouble() { |
| 88 if (this < 0) { | 88 if (this < 0) { |
| 89 return JS('num', r'-Math.round(-#)', this); | 89 return JS('num', r'-Math.round(-#)', this); |
| 90 } else { | 90 } else { |
| 91 return JS('num', r'Math.round(#)', this); | 91 return JS('num', r'Math.round(#)', this); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 double truncateToDouble() => this < 0 ? ceilToDouble() : floorToDouble(); | 95 double truncateToDouble() => this < 0 ? ceilToDouble() : floorToDouble(); |
| 96 | 96 |
| 97 num clamp(lowerLimit, upperLimit) { | 97 num clamp(num lowerLimit, num upperLimit) { |
| 98 if (lowerLimit is! num) throw new ArgumentError(lowerLimit); | 98 if (lowerLimit is! num) throw new ArgumentError(lowerLimit); |
| 99 if (upperLimit is! num) throw new ArgumentError(upperLimit); | 99 if (upperLimit is! num) throw new ArgumentError(upperLimit); |
| 100 if (lowerLimit.compareTo(upperLimit) > 0) { | 100 if (lowerLimit.compareTo(upperLimit) > 0) { |
| 101 throw new ArgumentError(lowerLimit); | 101 throw new ArgumentError(lowerLimit); |
| 102 } | 102 } |
| 103 if (this.compareTo(lowerLimit) < 0) return lowerLimit; | 103 if (this.compareTo(lowerLimit) < 0) return lowerLimit; |
| 104 if (this.compareTo(upperLimit) > 0) return upperLimit; | 104 if (this.compareTo(upperLimit) > 0) return upperLimit; |
| 105 return this; | 105 return this; |
| 106 } | 106 } |
| 107 | 107 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 num operator +(num other) { | 191 num operator +(num other) { |
| 192 if (other is !num) throw new ArgumentError(other); | 192 if (other is !num) throw new ArgumentError(other); |
| 193 return JS('num', '# + #', this, other); | 193 return JS('num', '# + #', this, other); |
| 194 } | 194 } |
| 195 | 195 |
| 196 num operator -(num other) { | 196 num operator -(num other) { |
| 197 if (other is !num) throw new ArgumentError(other); | 197 if (other is !num) throw new ArgumentError(other); |
| 198 return JS('num', '# - #', this, other); | 198 return JS('num', '# - #', this, other); |
| 199 } | 199 } |
| 200 | 200 |
| 201 num operator /(num other) { | 201 double operator /(num other) { |
| 202 if (other is !num) throw new ArgumentError(other); | 202 if (other is !num) throw new ArgumentError(other); |
| 203 return JS('num', '# / #', this, other); | 203 return JS('double', '# / #', this, other); |
| 204 } | 204 } |
| 205 | 205 |
| 206 num operator *(num other) { | 206 num operator *(num other) { |
| 207 if (other is !num) throw new ArgumentError(other); | 207 if (other is !num) throw new ArgumentError(other); |
| 208 return JS('num', '# * #', this, other); | 208 return JS('num', '# * #', this, other); |
| 209 } | 209 } |
| 210 | 210 |
| 211 num operator %(num other) { | 211 num operator %(num other) { |
| 212 if (other is !num) throw new ArgumentError(other); | 212 if (other is !num) throw new ArgumentError(other); |
| 213 // Euclidean Modulo. | 213 // Euclidean Modulo. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 } | 413 } |
| 414 | 414 |
| 415 class JSDouble extends JSNumber implements double { | 415 class JSDouble extends JSNumber implements double { |
| 416 const JSDouble(); | 416 const JSDouble(); |
| 417 Type get runtimeType => double; | 417 Type get runtimeType => double; |
| 418 } | 418 } |
| 419 | 419 |
| 420 class JSPositiveInt extends JSInt {} | 420 class JSPositiveInt extends JSInt {} |
| 421 class JSUInt32 extends JSPositiveInt {} | 421 class JSUInt32 extends JSPositiveInt {} |
| 422 class JSUInt31 extends JSUInt32 {} | 422 class JSUInt31 extends JSUInt32 {} |
| OLD | NEW |