| 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 fixnum; | 5 part of fixnum; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1]. | 8 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1]. |
| 9 * Arithmetic operations may overflow in order to maintain this range. | 9 * Arithmetic operations may overflow in order to maintain this range. |
| 10 */ | 10 */ |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 /** | 135 /** |
| 136 * Constructs an [int32] from an [int]. Only the low 32 bits of the input | 136 * Constructs an [int32] from an [int]. Only the low 32 bits of the input |
| 137 * are used. | 137 * are used. |
| 138 */ | 138 */ |
| 139 int32.fromInt(int i) : _i = (i & 0x7fffffff) - (i & 0x80000000); | 139 int32.fromInt(int i) : _i = (i & 0x7fffffff) - (i & 0x80000000); |
| 140 | 140 |
| 141 // Convert an [int] or [intx] to an [int32]. Note that an [int64] | 141 // Convert an [int] or [intx] to an [int32]. Note that an [int64] |
| 142 // will be truncated. | 142 // will be truncated. |
| 143 int _convert(other) { | 143 int _convert(other) { |
| 144 if (other == null) { | 144 if (other == null) { |
| 145 throw new NullPointerException(); | 145 throw new ArgumentError(null); |
| 146 } else if (other is intx) { | 146 } else if (other is intx) { |
| 147 return other.toInt32()._i; | 147 return other.toInt32()._i; |
| 148 } else if (other is int) { | 148 } else if (other is int) { |
| 149 return other; | 149 return other; |
| 150 } else { | 150 } else { |
| 151 throw new Exception("Can't retrieve 32-bit int from $other"); | 151 throw new Exception("Can't retrieve 32-bit int from $other"); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 // The +, -, * , &, |, and ^ operaters deal with types as follows: | 155 // The +, -, * , &, |, and ^ operaters deal with types as follows: |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 int toInt() => _i; | 349 int toInt() => _i; |
| 350 int32 toInt32() => this; | 350 int32 toInt32() => this; |
| 351 int64 toInt64() => new int64.fromInt(_i); | 351 int64 toInt64() => new int64.fromInt(_i); |
| 352 | 352 |
| 353 String toString() => _i.toString(); | 353 String toString() => _i.toString(); |
| 354 String toHexString() => _i.toRadixString(16); | 354 String toHexString() => _i.toRadixString(16); |
| 355 String toRadixString(int radix) => _i.toRadixString(radix); | 355 String toRadixString(int radix) => _i.toRadixString(radix); |
| 356 } | 356 } |
| OLD | NEW |