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 abstract class _IntegerImplementation { | 5 abstract class _IntegerImplementation { |
6 // The Dart class _Bigint extending _IntegerImplementation requires a | 6 // The Dart class _Bigint extending _IntegerImplementation requires a |
7 // default constructor. | 7 // default constructor. |
8 | 8 |
9 Type get runtimeType => int; | 9 Type get runtimeType => int; |
10 | 10 |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 401 } |
402 return _binaryGcd(x, y, false); | 402 return _binaryGcd(x, y, false); |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 class _Smi extends _IntegerImplementation implements int { | 406 class _Smi extends _IntegerImplementation implements int { |
407 factory _Smi._uninstantiable() { | 407 factory _Smi._uninstantiable() { |
408 throw new UnsupportedError( | 408 throw new UnsupportedError( |
409 "_Smi can only be allocated by the VM"); | 409 "_Smi can only be allocated by the VM"); |
410 } | 410 } |
| 411 int get hashCode => this; |
411 int get _identityHashCode => this; | 412 int get _identityHashCode => this; |
412 int get hashCode => this; | |
413 int operator ~() native "Smi_bitNegate"; | 413 int operator ~() native "Smi_bitNegate"; |
414 int get bitLength native "Smi_bitLength"; | 414 int get bitLength native "Smi_bitLength"; |
415 | 415 |
416 int operator &(int other) => other._bitAndFromSmi(this); | 416 int operator &(int other) => other._bitAndFromSmi(this); |
417 | 417 |
418 int _bitAndFromSmi(int other) native "Smi_bitAndFromSmi"; | 418 int _bitAndFromSmi(int other) native "Smi_bitAndFromSmi"; |
419 int _shrFromInt(int other) native "Smi_shrFromInt"; | 419 int _shrFromInt(int other) native "Smi_shrFromInt"; |
420 int _shlFromInt(int other) native "Smi_shlFromInt"; | 420 int _shlFromInt(int other) native "Smi_shlFromInt"; |
421 | 421 |
422 /** | 422 /** |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 return result; | 601 return result; |
602 } | 602 } |
603 } | 603 } |
604 | 604 |
605 // Represents integers that cannot be represented by Smi but fit into 64bits. | 605 // Represents integers that cannot be represented by Smi but fit into 64bits. |
606 class _Mint extends _IntegerImplementation implements int { | 606 class _Mint extends _IntegerImplementation implements int { |
607 factory _Mint._uninstantiable() { | 607 factory _Mint._uninstantiable() { |
608 throw new UnsupportedError( | 608 throw new UnsupportedError( |
609 "_Mint can only be allocated by the VM"); | 609 "_Mint can only be allocated by the VM"); |
610 } | 610 } |
| 611 int get hashCode => this; |
611 int get _identityHashCode => this; | 612 int get _identityHashCode => this; |
612 int get hashCode => this; | |
613 int operator ~() native "Mint_bitNegate"; | 613 int operator ~() native "Mint_bitNegate"; |
614 int get bitLength native "Mint_bitLength"; | 614 int get bitLength native "Mint_bitLength"; |
615 | 615 |
616 int _bitAndFromSmi(int other) => _bitAndFromInteger(other); | 616 int _bitAndFromSmi(int other) => _bitAndFromInteger(other); |
617 | 617 |
618 // Shift by mint exceeds range that can be handled by the VM. | 618 // Shift by mint exceeds range that can be handled by the VM. |
619 int _shrFromInt(int other) { | 619 int _shrFromInt(int other) { |
620 if (other < 0) { | 620 if (other < 0) { |
621 return -1; | 621 return -1; |
622 } else { | 622 } else { |
623 return 0; | 623 return 0; |
624 } | 624 } |
625 } | 625 } |
626 int _shlFromInt(int other) native "Mint_shlFromInt"; | 626 int _shlFromInt(int other) native "Mint_shlFromInt"; |
627 } | 627 } |
OLD | NEW |