| 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 (m is _Bigint) { | |
| 419 return _toBigint().modInverse(m); | |
| 420 } | |
| 421 bool ac = m.isEven; | 418 bool ac = m.isEven; |
| 422 int u = m; | 419 int u = m; |
| 423 int v = this; | 420 int v = this; |
| 424 int a = 1, | 421 int a = 1, |
| 425 b = 0, | 422 b = 0, |
| 426 c = 0, | 423 c = 0, |
| 427 d = 1; | 424 d = 1; |
| 428 while (u != 0) { | 425 while (u != 0) { |
| 429 while (u.isEven) { | 426 while (u.isEven) { |
| 430 u ~/= 2; | 427 u ~/= 2; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 } | 513 } |
| 517 | 514 |
| 518 class JSDouble extends JSNumber implements double { | 515 class JSDouble extends JSNumber implements double { |
| 519 const JSDouble(); | 516 const JSDouble(); |
| 520 Type get runtimeType => double; | 517 Type get runtimeType => double; |
| 521 } | 518 } |
| 522 | 519 |
| 523 class JSPositiveInt extends JSInt {} | 520 class JSPositiveInt extends JSInt {} |
| 524 class JSUInt32 extends JSPositiveInt {} | 521 class JSUInt32 extends JSPositiveInt {} |
| 525 class JSUInt31 extends JSUInt32 {} | 522 class JSUInt31 extends JSUInt32 {} |
| OLD | NEW |