| 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 /** | 5 /** |
| 6 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 1]. | 6 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 1]. |
| 7 * Arithmetic operations may overflow in order to maintain this range. | 7 * Arithmetic operations may overflow in order to maintain this range. |
| 8 */ | 8 */ |
| 9 class int64 implements intx { | 9 class int64 implements intx { |
| 10 | 10 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 _l = bottom & _MASK; | 236 _l = bottom & _MASK; |
| 237 _m = ((top & 0xfff) << 10) | ((bottom >> _BITS) & 0x3ff); | 237 _m = ((top & 0xfff) << 10) | ((bottom >> _BITS) & 0x3ff); |
| 238 _h = (top >> 12) & _MASK_2; | 238 _h = (top >> 12) & _MASK_2; |
| 239 } | 239 } |
| 240 | 240 |
| 241 int64 _promote(other) { | 241 int64 _promote(other) { |
| 242 if (other == null) { | 242 if (other == null) { |
| 243 throw new NullPointerException(); | 243 throw new NullPointerException(); |
| 244 } else if (other is intx) { | 244 } else if (other is intx) { |
| 245 other = other.toInt64(); | 245 other = other.toInt64(); |
| 246 } else if (other is int) { | 246 } else if (other is num) { |
| 247 other = new int64.fromInt(other); | 247 other = new int64.fromInt(other.toInt()); |
| 248 } | 248 } |
| 249 if (other is !int64) { | 249 if (other is !int64) { |
| 250 throw new Exception("Can't promote $other to int64"); | 250 throw new Exception("Can't promote $other to int64"); |
| 251 } | 251 } |
| 252 return other; | 252 return other; |
| 253 } | 253 } |
| 254 | 254 |
| 255 int64 operator +(other) { | 255 int64 operator +(other) { |
| 256 int64 o = _promote(other); | 256 int64 o = _promote(other); |
| 257 int sum0 = _l + o._l; | 257 int sum0 = _l + o._l; |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 } | 1086 } |
| 1087 } | 1087 } |
| 1088 return ZERO; | 1088 return ZERO; |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 // Generate the quotient using bit-at-a-time long division. | 1091 // Generate the quotient using bit-at-a-time long division. |
| 1092 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative, | 1092 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative, |
| 1093 aIsNegative, aIsMinValue, computeRemainder); | 1093 aIsNegative, aIsMinValue, computeRemainder); |
| 1094 } | 1094 } |
| 1095 } | 1095 } |
| OLD | NEW |