| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 e ~/= 2; | 408 e ~/= 2; |
| 409 b = (b * b) % m; | 409 b = (b * b) % m; |
| 410 } | 410 } |
| 411 return r; | 411 return r; |
| 412 } | 412 } |
| 413 | 413 |
| 414 // Returns 1/this % m, with m > 0. | 414 // Returns 1/this % m, with m > 0. |
| 415 int modInverse(int m) { | 415 int modInverse(int m) { |
| 416 if (m is! int) throw new ArgumentError(m); | 416 if (m is! int) throw new ArgumentError(m); |
| 417 if (m <= 0) throw new RangeError(m); | 417 if (m <= 0) throw new RangeError(m); |
| 418 if (this == 0) return 0; |
| 418 bool ac = m.isEven; | 419 bool ac = m.isEven; |
| 419 int u = m; | 420 int u = m; |
| 420 int v = this; | 421 int v = this; |
| 421 int a = 1, | 422 int a = 1, |
| 422 b = 0, | 423 b = 0, |
| 423 c = 0, | 424 c = 0, |
| 424 d = 1; | 425 d = 1; |
| 425 while (u != 0) { | 426 while (u != 0) { |
| 426 while (u.isEven) { | 427 while (u.isEven) { |
| 427 u ~/= 2; | 428 u ~/= 2; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 } | 514 } |
| 514 | 515 |
| 515 class JSDouble extends JSNumber implements double { | 516 class JSDouble extends JSNumber implements double { |
| 516 const JSDouble(); | 517 const JSDouble(); |
| 517 Type get runtimeType => double; | 518 Type get runtimeType => double; |
| 518 } | 519 } |
| 519 | 520 |
| 520 class JSPositiveInt extends JSInt {} | 521 class JSPositiveInt extends JSInt {} |
| 521 class JSUInt32 extends JSPositiveInt {} | 522 class JSUInt32 extends JSPositiveInt {} |
| 522 class JSUInt31 extends JSUInt32 {} | 523 class JSUInt31 extends JSUInt32 {} |
| OLD | NEW |