| 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 // Dart core library. | 4 // Dart core library. |
| 5 | 5 |
| 6 // VM implementation of int. | 6 // VM implementation of int. |
| 7 | 7 |
| 8 @patch class int { | 8 @patch class int { |
| 9 | 9 |
| 10 @patch const factory int.fromEnvironment(String name, | 10 @patch const factory int.fromEnvironment(String name, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 if (9 < c) { | 35 if (9 < c) { |
| 36 return null; | 36 return null; |
| 37 } | 37 } |
| 38 result = 10 * result + c; | 38 result = 10 * result + c; |
| 39 } | 39 } |
| 40 return sign * result; | 40 return sign * result; |
| 41 } | 41 } |
| 42 | 42 |
| 43 @patch static int parse(String source, | 43 @patch static int parse(String source, |
| 44 { int radix, | 44 { int radix, |
| 45 int onError(String str) }) { | 45 int onError(String source) }) { |
| 46 if (source == null) throw new ArgumentError("The source must not be null"); | 46 if (source == null) throw new ArgumentError("The source must not be null"); |
| 47 if (source.isEmpty) return _throwFormatException(onError, source, 0, radix); | 47 if (source.isEmpty) return _throwFormatException(onError, source, 0, radix); |
| 48 if (radix == null || radix == 10) { | 48 if (radix == null || radix == 10) { |
| 49 // Try parsing immediately, without trimming whitespace. | 49 // Try parsing immediately, without trimming whitespace. |
| 50 int result = _tryParseSmi(source, 0, source.length - 1); | 50 int result = _tryParseSmi(source, 0, source.length - 1); |
| 51 if (result != null) return result; | 51 if (result != null) return result; |
| 52 } else if (radix < 2 || radix > 36) { | 52 } else if (radix < 2 || radix > 36) { |
| 53 throw new RangeError("Radix $radix not in range 2..36"); | 53 throw new RangeError("Radix $radix not in range 2..36"); |
| 54 } | 54 } |
| 55 // Split here so improve odds of parse being inlined and the checks omitted. | 55 // Split here so improve odds of parse being inlined and the checks omitted. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 6, 594823321, 12, 353814783205469041, | 202 6, 594823321, 12, 353814783205469041, |
| 203 6, 729000000, 12, 531441000000000000, /* radix: 30 */ | 203 6, 729000000, 12, 531441000000000000, /* radix: 30 */ |
| 204 6, 887503681, 12, 787662783788549761, | 204 6, 887503681, 12, 787662783788549761, |
| 205 6, 1073741824, 12, 1152921504606846976, | 205 6, 1073741824, 12, 1152921504606846976, |
| 206 5, 39135393, 12, 1667889514952984961, | 206 5, 39135393, 12, 1667889514952984961, |
| 207 5, 45435424, 12, 2386420683693101056, | 207 5, 45435424, 12, 2386420683693101056, |
| 208 5, 52521875, 12, 3379220508056640625, /* radix: 35 */ | 208 5, 52521875, 12, 3379220508056640625, /* radix: 35 */ |
| 209 5, 60466176, 11, 131621703842267136, | 209 5, 60466176, 11, 131621703842267136, |
| 210 ]; | 210 ]; |
| 211 } | 211 } |
| OLD | NEW |