| 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 // TODO(srdjan): fix limitations. | 5 // TODO(srdjan): fix limitations. |
| 6 // - shift amount must be a Smi. | 6 // - shift amount must be a Smi. |
| 7 class _IntegerImplementation { | 7 class _IntegerImplementation { |
| 8 factory _IntegerImplementation._uninstantiable() { | 8 factory _IntegerImplementation._uninstantiable() { |
| 9 throw new UnsupportedError( | 9 throw new UnsupportedError( |
| 10 "_IntegerImplementation can only be allocated by the VM"); | 10 "_IntegerImplementation can only be allocated by the VM"); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 bool _equalToInteger(int other) native "Integer_equalToInteger"; | 91 bool _equalToInteger(int other) native "Integer_equalToInteger"; |
| 92 int abs() { | 92 int abs() { |
| 93 return this < 0 ? -this : this; | 93 return this < 0 ? -this : this; |
| 94 } | 94 } |
| 95 bool get isEven => ((this & 1) == 0); | 95 bool get isEven => ((this & 1) == 0); |
| 96 bool get isOdd => !isEven; | 96 bool get isOdd => !isEven; |
| 97 bool get isNaN => false; | 97 bool get isNaN => false; |
| 98 bool get isNegative => this < 0; | 98 bool get isNegative => this < 0; |
| 99 bool get isInfinite => false; | 99 bool get isInfinite => false; |
| 100 bool get isFinite => true; |
| 100 | 101 |
| 101 int toUnsigned(int width) { | 102 int toUnsigned(int width) { |
| 102 return this & ((1 << width) - 1); | 103 return this & ((1 << width) - 1); |
| 103 } | 104 } |
| 104 | 105 |
| 105 int toSigned(int width) { | 106 int toSigned(int width) { |
| 106 // The value of binary number weights each bit by a power of two. The | 107 // The value of binary number weights each bit by a power of two. The |
| 107 // twos-complement value weights the sign bit negatively. We compute the | 108 // twos-complement value weights the sign bit negatively. We compute the |
| 108 // value of the negative weighting by isolating the sign bit with the | 109 // value of the negative weighting by isolating the sign bit with the |
| 109 // correct power of two weighting and subtracting it from the value of the | 110 // correct power of two weighting and subtracting it from the value of the |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } else { | 334 } else { |
| 334 return 0; | 335 return 0; |
| 335 } | 336 } |
| 336 } | 337 } |
| 337 int _shlFromInt(int other) native "Bigint_shlFromInt"; | 338 int _shlFromInt(int other) native "Bigint_shlFromInt"; |
| 338 | 339 |
| 339 int pow(int exponent) { | 340 int pow(int exponent) { |
| 340 throw "Bigint.pow not implemented"; | 341 throw "Bigint.pow not implemented"; |
| 341 } | 342 } |
| 342 } | 343 } |
| OLD | NEW |