| 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"); |
| 11 } | 11 } |
| 12 num operator +(num other) { | 12 num operator +(num other) { |
| 13 return other.addFromInteger(this); | 13 return other.addFromInteger(this); |
| 14 } | 14 } |
| 15 num operator -(num other) { | 15 num operator -(num other) { |
| 16 return other.subFromInteger(this); | 16 return other.subFromInteger(this); |
| 17 } | 17 } |
| 18 num operator *(num other) { | 18 num operator *(num other) { |
| 19 return other.mulFromInteger(this); | 19 return other.mulFromInteger(this); |
| 20 } | 20 } |
| 21 num operator ~/(num other) { | 21 num operator ~/(num other) { |
| 22 if (other == 0) { | 22 if ((other is int) && (other == 0)) { |
| 23 throw const IntegerDivisionByZeroException(); | 23 throw const IntegerDivisionByZeroException(); |
| 24 } | 24 } |
| 25 return other.truncDivFromInteger(this); | 25 return other.truncDivFromInteger(this); |
| 26 } | 26 } |
| 27 num operator /(num other) { | 27 num operator /(num other) { |
| 28 return this.toDouble() / other.toDouble(); | 28 return this.toDouble() / other.toDouble(); |
| 29 } | 29 } |
| 30 num operator %(num other) { | 30 num operator %(num other) { |
| 31 if ((other is int) && (other == 0)) { | 31 if ((other is int) && (other == 0)) { |
| 32 throw const IntegerDivisionByZeroException(); | 32 throw const IntegerDivisionByZeroException(); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 int shlFromInt(int other) { | 238 int shlFromInt(int other) { |
| 239 throw const OutOfMemoryException(); | 239 throw const OutOfMemoryException(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 int pow(int exponent) { | 242 int pow(int exponent) { |
| 243 throw "Bigint.pow not implemented"; | 243 throw "Bigint.pow not implemented"; |
| 244 } | 244 } |
| 245 } | 245 } |
| OLD | NEW |