| 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 const UnsupportedOperationException( | 9 throw const UnsupportedOperationException( |
| 10 "_IntegerImplementation can only be allocated by the VM"); | 10 "_IntegerImplementation can only be allocated by the VM"); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 // Shift by mint exceeds range that can be handled by the VM. | 207 // Shift by mint exceeds range that can be handled by the VM. |
| 208 int _shrFromInt(int other) { | 208 int _shrFromInt(int other) { |
| 209 if (other < 0) { | 209 if (other < 0) { |
| 210 return -1; | 210 return -1; |
| 211 } else { | 211 } else { |
| 212 return 0; | 212 return 0; |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 int _shlFromInt(int other) { | 215 int _shlFromInt(int other) { |
| 216 throw const OutOfMemoryException(); | 216 throw const OutOfMemoryError(); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 // A number that can be represented as Smi or Mint will never be represented as | 220 // A number that can be represented as Smi or Mint will never be represented as |
| 221 // Bigint. | 221 // Bigint. |
| 222 class _Bigint extends _IntegerImplementation implements int { | 222 class _Bigint extends _IntegerImplementation implements int { |
| 223 factory _Bigint._uninstantiable() { | 223 factory _Bigint._uninstantiable() { |
| 224 throw const UnsupportedOperationException( | 224 throw const UnsupportedOperationException( |
| 225 "_Bigint can only be allocated by the VM"); | 225 "_Bigint can only be allocated by the VM"); |
| 226 } | 226 } |
| 227 int hashCode() { | 227 int hashCode() { |
| 228 return this; | 228 return this; |
| 229 } | 229 } |
| 230 int operator ~() native "Bigint_bitNegate"; | 230 int operator ~() native "Bigint_bitNegate"; |
| 231 | 231 |
| 232 // Shift by bigint exceeds range that can be handled by the VM. | 232 // Shift by bigint exceeds range that can be handled by the VM. |
| 233 int _shrFromInt(int other) { | 233 int _shrFromInt(int other) { |
| 234 if (other < 0) { | 234 if (other < 0) { |
| 235 return -1; | 235 return -1; |
| 236 } else { | 236 } else { |
| 237 return 0; | 237 return 0; |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 int _shlFromInt(int other) { | 240 int _shlFromInt(int other) { |
| 241 throw const OutOfMemoryException(); | 241 throw const OutOfMemoryError(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 int pow(int exponent) { | 244 int pow(int exponent) { |
| 245 throw "Bigint.pow not implemented"; | 245 throw "Bigint.pow not implemented"; |
| 246 } | 246 } |
| 247 } | 247 } |
| OLD | NEW |