| Index: runtime/lib/integers_patch.dart
|
| diff --git a/runtime/lib/integers_patch.dart b/runtime/lib/integers_patch.dart
|
| index a65ced8bf1498cc59f48742a698914f581a4c10a..3ca6f61778c5a880a2e5e7b22ca23d349e4263b3 100644
|
| --- a/runtime/lib/integers_patch.dart
|
| +++ b/runtime/lib/integers_patch.dart
|
| @@ -5,13 +5,12 @@
|
|
|
| // VM implementation of int.
|
|
|
| -@patch class int {
|
| -
|
| - @patch const factory int.fromEnvironment(String name,
|
| - {int defaultValue})
|
| +@patch
|
| +class int {
|
| + @patch
|
| + const factory int.fromEnvironment(String name, {int defaultValue})
|
| native "Integer_fromEnvironment";
|
|
|
| -
|
| static int _tryParseSmi(String str, int first, int last) {
|
| assert(first <= last);
|
| var ix = first;
|
| @@ -20,14 +19,14 @@
|
| // Check for leading '+' or '-'.
|
| if ((c == 0x2b) || (c == 0x2d)) {
|
| ix++;
|
| - sign = 0x2c - c; // -1 for '-', +1 for '+'.
|
| + sign = 0x2c - c; // -1 for '-', +1 for '+'.
|
| if (ix > last) {
|
| - return null; // Empty.
|
| + return null; // Empty.
|
| }
|
| }
|
| var smiLimit = internal.is64Bit ? 18 : 9;
|
| if ((last - ix) >= smiLimit) {
|
| - return null; // May not fit into a Smi.
|
| + return null; // May not fit into a Smi.
|
| }
|
| var result = 0;
|
| for (int i = ix; i <= last; i++) {
|
| @@ -40,9 +39,8 @@
|
| return sign * result;
|
| }
|
|
|
| - @patch static int parse(String source,
|
| - { int radix,
|
| - int onError(String source) }) {
|
| + @patch
|
| + static int parse(String source, {int radix, int onError(String source)}) {
|
| if (source == null) throw new ArgumentError("The source must not be null");
|
| if (source.isEmpty) return _throwFormatException(onError, source, 0, radix);
|
| if (radix == null || radix == 10) {
|
| @@ -66,7 +64,7 @@
|
| int first = source.codeUnitAt(start);
|
| int sign = 1;
|
| if (first == 0x2b /* + */ || first == 0x2d /* - */) {
|
| - sign = 0x2c - first; // -1 if '-', +1 if '+'.
|
| + sign = 0x2c - first; // -1 if '-', +1 if '+'.
|
| start++;
|
| if (start == end) {
|
| return _throwFormatException(onError, source, end, radix);
|
| @@ -109,8 +107,8 @@
|
| throw new FormatException("Invalid radix-$radix number", source, index);
|
| }
|
|
|
| - static int _parseRadix(String source, int radix,
|
| - int start, int end, int sign) {
|
| + static int _parseRadix(
|
| + String source, int radix, int start, int end, int sign) {
|
| int tableIndex = (radix - 2) * 4 + (internal.is64Bit ? 2 : 0);
|
| int blockSize = _PARSE_LIMITS[tableIndex];
|
| int length = end - start;
|
| @@ -172,40 +170,40 @@
|
| // and magnitude of such a block (radix ** digit-count).
|
| // 32-bit limit/multiplier at (radix - 2)*4, 64-bit limit at (radix-2)*4+2
|
| static const _PARSE_LIMITS = const [
|
| - 30, 1073741824, 62, 4611686018427387904, /* radix: 2 */
|
| - 18, 387420489, 39, 4052555153018976267,
|
| - 15, 1073741824, 30, 1152921504606846976,
|
| - 12, 244140625, 26, 1490116119384765625, /* radix: 5 */
|
| - 11, 362797056, 23, 789730223053602816,
|
| - 10, 282475249, 22, 3909821048582988049,
|
| - 10, 1073741824, 20, 1152921504606846976,
|
| - 9, 387420489, 19, 1350851717672992089,
|
| - 9, 1000000000, 18, 1000000000000000000, /* radix: 10 */
|
| - 8, 214358881, 17, 505447028499293771,
|
| - 8, 429981696, 17, 2218611106740436992,
|
| - 8, 815730721, 16, 665416609183179841,
|
| - 7, 105413504, 16, 2177953337809371136,
|
| - 7, 170859375, 15, 437893890380859375, /* radix: 15 */
|
| - 7, 268435456, 15, 1152921504606846976,
|
| - 7, 410338673, 15, 2862423051509815793,
|
| - 7, 612220032, 14, 374813367582081024,
|
| - 7, 893871739, 14, 799006685782884121,
|
| - 6, 64000000, 14, 1638400000000000000, /* radix: 20 */
|
| - 6, 85766121, 14, 3243919932521508681,
|
| - 6, 113379904, 13, 282810057883082752,
|
| - 6, 148035889, 13, 504036361936467383,
|
| - 6, 191102976, 13, 876488338465357824,
|
| - 6, 244140625, 13, 1490116119384765625, /* radix: 25 */
|
| - 6, 308915776, 13, 2481152873203736576,
|
| - 6, 387420489, 13, 4052555153018976267,
|
| - 6, 481890304, 12, 232218265089212416,
|
| - 6, 594823321, 12, 353814783205469041,
|
| - 6, 729000000, 12, 531441000000000000, /* radix: 30 */
|
| - 6, 887503681, 12, 787662783788549761,
|
| - 6, 1073741824, 12, 1152921504606846976,
|
| - 5, 39135393, 12, 1667889514952984961,
|
| - 5, 45435424, 12, 2386420683693101056,
|
| - 5, 52521875, 12, 3379220508056640625, /* radix: 35 */
|
| - 5, 60466176, 11, 131621703842267136,
|
| + 30, 1073741824, 62, 4611686018427387904, // radix: 2
|
| + 18, 387420489, 39, 4052555153018976267,
|
| + 15, 1073741824, 30, 1152921504606846976,
|
| + 12, 244140625, 26, 1490116119384765625, // radix: 5
|
| + 11, 362797056, 23, 789730223053602816,
|
| + 10, 282475249, 22, 3909821048582988049,
|
| + 10, 1073741824, 20, 1152921504606846976,
|
| + 9, 387420489, 19, 1350851717672992089,
|
| + 9, 1000000000, 18, 1000000000000000000, // radix: 10
|
| + 8, 214358881, 17, 505447028499293771,
|
| + 8, 429981696, 17, 2218611106740436992,
|
| + 8, 815730721, 16, 665416609183179841,
|
| + 7, 105413504, 16, 2177953337809371136,
|
| + 7, 170859375, 15, 437893890380859375, // radix: 15
|
| + 7, 268435456, 15, 1152921504606846976,
|
| + 7, 410338673, 15, 2862423051509815793,
|
| + 7, 612220032, 14, 374813367582081024,
|
| + 7, 893871739, 14, 799006685782884121,
|
| + 6, 64000000, 14, 1638400000000000000, // radix: 20
|
| + 6, 85766121, 14, 3243919932521508681,
|
| + 6, 113379904, 13, 282810057883082752,
|
| + 6, 148035889, 13, 504036361936467383,
|
| + 6, 191102976, 13, 876488338465357824,
|
| + 6, 244140625, 13, 1490116119384765625, // radix: 25
|
| + 6, 308915776, 13, 2481152873203736576,
|
| + 6, 387420489, 13, 4052555153018976267,
|
| + 6, 481890304, 12, 232218265089212416,
|
| + 6, 594823321, 12, 353814783205469041,
|
| + 6, 729000000, 12, 531441000000000000, // radix: 30
|
| + 6, 887503681, 12, 787662783788549761,
|
| + 6, 1073741824, 12, 1152921504606846976,
|
| + 5, 39135393, 12, 1667889514952984961,
|
| + 5, 45435424, 12, 2386420683693101056,
|
| + 5, 52521875, 12, 3379220508056640625, // radix: 35
|
| + 5, 60466176, 11, 131621703842267136,
|
| ];
|
| }
|
|
|