| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 List temp = new List(); | 190 List temp = new List(); |
| 191 while (value > 0) { | 191 while (value > 0) { |
| 192 int digit = value % radix; | 192 int digit = value % radix; |
| 193 value ~/= radix; | 193 value ~/= radix; |
| 194 temp.add(digit); | 194 temp.add(digit); |
| 195 } | 195 } |
| 196 if (temp.isEmpty) { | 196 if (temp.isEmpty) { |
| 197 return "0"; | 197 return "0"; |
| 198 } | 198 } |
| 199 StringBuffer buffer = new StringBuffer(); | 199 StringBuffer buffer = new StringBuffer(); |
| 200 if (isNegative) buffer.add("-"); | 200 if (isNegative) buffer.write("-"); |
| 201 for (int i = temp.length - 1; i >= 0; i--) { | 201 for (int i = temp.length - 1; i >= 0; i--) { |
| 202 buffer.add(table[temp[i]]); | 202 buffer.write(table[temp[i]]); |
| 203 } | 203 } |
| 204 return buffer.toString(); | 204 return buffer.toString(); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 class _Smi extends _IntegerImplementation implements int { | 208 class _Smi extends _IntegerImplementation implements int { |
| 209 factory _Smi._uninstantiable() { | 209 factory _Smi._uninstantiable() { |
| 210 throw new UnsupportedError( | 210 throw new UnsupportedError( |
| 211 "_Smi can only be allocated by the VM"); | 211 "_Smi can only be allocated by the VM"); |
| 212 } | 212 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 int _shlFromInt(int other) { | 265 int _shlFromInt(int other) { |
| 266 throw const OutOfMemoryError(); | 266 throw const OutOfMemoryError(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 int pow(int exponent) { | 269 int pow(int exponent) { |
| 270 throw "Bigint.pow not implemented"; | 270 throw "Bigint.pow not implemented"; |
| 271 } | 271 } |
| 272 } | 272 } |
| OLD | NEW |