| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 int operator ~() native "Mint_bitNegate"; | 266 int operator ~() native "Mint_bitNegate"; |
| 267 | 267 |
| 268 // Shift by mint exceeds range that can be handled by the VM. | 268 // Shift by mint exceeds range that can be handled by the VM. |
| 269 int _shrFromInt(int other) { | 269 int _shrFromInt(int other) { |
| 270 if (other < 0) { | 270 if (other < 0) { |
| 271 return -1; | 271 return -1; |
| 272 } else { | 272 } else { |
| 273 return 0; | 273 return 0; |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 int _shlFromInt(int other) { | 276 int _shlFromInt(int other) native "Mint_shlFromInt"; |
| 277 throw const OutOfMemoryError(); | |
| 278 } | |
| 279 } | 277 } |
| 280 | 278 |
| 281 // A number that can be represented as Smi or Mint will never be represented as | 279 // A number that can be represented as Smi or Mint will never be represented as |
| 282 // Bigint. | 280 // Bigint. |
| 283 class _Bigint extends _IntegerImplementation implements int { | 281 class _Bigint extends _IntegerImplementation implements int { |
| 284 factory _Bigint._uninstantiable() { | 282 factory _Bigint._uninstantiable() { |
| 285 throw new UnsupportedError( | 283 throw new UnsupportedError( |
| 286 "_Bigint can only be allocated by the VM"); | 284 "_Bigint can only be allocated by the VM"); |
| 287 } | 285 } |
| 288 int get hashCode { | 286 int get hashCode { |
| 289 return this; | 287 return this; |
| 290 } | 288 } |
| 291 int operator ~() native "Bigint_bitNegate"; | 289 int operator ~() native "Bigint_bitNegate"; |
| 292 | 290 |
| 293 // Shift by bigint exceeds range that can be handled by the VM. | 291 // Shift by bigint exceeds range that can be handled by the VM. |
| 294 int _shrFromInt(int other) { | 292 int _shrFromInt(int other) { |
| 295 if (other < 0) { | 293 if (other < 0) { |
| 296 return -1; | 294 return -1; |
| 297 } else { | 295 } else { |
| 298 return 0; | 296 return 0; |
| 299 } | 297 } |
| 300 } | 298 } |
| 301 int _shlFromInt(int other) { | 299 int _shlFromInt(int other) native "Bigint_shlFromInt"; |
| 302 throw const OutOfMemoryError(); | |
| 303 } | |
| 304 | 300 |
| 305 int pow(int exponent) { | 301 int pow(int exponent) { |
| 306 throw "Bigint.pow not implemented"; | 302 throw "Bigint.pow not implemented"; |
| 307 } | 303 } |
| 308 } | 304 } |
| OLD | NEW |