| 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 15 matching lines...) Expand all Loading... |
| 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(); |
| 33 } | 33 } |
| 34 return other.moduloFromInteger(this); | 34 return other.moduloFromInteger(this); |
| 35 } | 35 } |
| 36 int operator negate() { | 36 int operator -() { |
| 37 return 0 - this; | 37 return 0 - this; |
| 38 } | 38 } |
| 39 int operator &(int other) { | 39 int operator &(int other) { |
| 40 return other.bitAndFromInteger(this); | 40 return other.bitAndFromInteger(this); |
| 41 } | 41 } |
| 42 int operator |(int other) { | 42 int operator |(int other) { |
| 43 return other.bitOrFromInteger(this); | 43 return other.bitOrFromInteger(this); |
| 44 } | 44 } |
| 45 int operator ^(int other) { | 45 int operator ^(int other) { |
| 46 return other.bitXorFromInteger(this); | 46 return other.bitXorFromInteger(this); |
| (...skipping 189 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 |