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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (digit < 10 || digit >= radix) return null; | 164 if (digit < 10 || digit >= radix) return null; |
165 } | 165 } |
166 result = radix * result + digit; | 166 result = radix * result + digit; |
167 } | 167 } |
168 } | 168 } |
169 return result; | 169 return result; |
170 } | 170 } |
171 | 171 |
172 // For each radix, 2-36, how many digits are guaranteed to fit in a smi, | 172 // For each radix, 2-36, how many digits are guaranteed to fit in a smi, |
173 // and magnitude of such a block (radix ** digit-count). | 173 // and magnitude of such a block (radix ** digit-count). |
174 // 32-bit limit/multiplier at (radix - 2)*4, 64-bit limit at (radix-2)*4+1 | 174 // 32-bit limit/multiplier at (radix - 2)*4, 64-bit limit at (radix-2)*4+2 |
175 static const _PARSE_LIMITS = const [ | 175 static const _PARSE_LIMITS = const [ |
176 30, 1073741824, 62, 4611686018427387904, /* radix: 2 */ | 176 30, 1073741824, 62, 4611686018427387904, /* radix: 2 */ |
177 18, 387420489, 39, 4052555153018976267, | 177 18, 387420489, 39, 4052555153018976267, |
178 15, 1073741824, 30, 1152921504606846976, | 178 15, 1073741824, 30, 1152921504606846976, |
179 12, 244140625, 26, 1490116119384765625, /* radix: 5 */ | 179 12, 244140625, 26, 1490116119384765625, /* radix: 5 */ |
180 11, 362797056, 23, 789730223053602816, | 180 11, 362797056, 23, 789730223053602816, |
181 10, 282475249, 22, 3909821048582988049, | 181 10, 282475249, 22, 3909821048582988049, |
182 10, 1073741824, 20, 1152921504606846976, | 182 10, 1073741824, 20, 1152921504606846976, |
183 9, 387420489, 19, 1350851717672992089, | 183 9, 387420489, 19, 1350851717672992089, |
184 9, 1000000000, 18, 1000000000000000000, /* radix: 10 */ | 184 9, 1000000000, 18, 1000000000000000000, /* radix: 10 */ |
(...skipping 18 matching lines...) Expand all Loading... |
203 6, 594823321, 12, 353814783205469041, | 203 6, 594823321, 12, 353814783205469041, |
204 6, 729000000, 12, 531441000000000000, /* radix: 30 */ | 204 6, 729000000, 12, 531441000000000000, /* radix: 30 */ |
205 6, 887503681, 12, 787662783788549761, | 205 6, 887503681, 12, 787662783788549761, |
206 6, 1073741824, 12, 1152921504606846976, | 206 6, 1073741824, 12, 1152921504606846976, |
207 5, 39135393, 12, 1667889514952984961, | 207 5, 39135393, 12, 1667889514952984961, |
208 5, 45435424, 12, 2386420683693101056, | 208 5, 45435424, 12, 2386420683693101056, |
209 5, 52521875, 12, 3379220508056640625, /* radix: 35 */ | 209 5, 52521875, 12, 3379220508056640625, /* radix: 35 */ |
210 5, 60466176, 11, 131621703842267136, | 210 5, 60466176, 11, 131621703842267136, |
211 ]; | 211 ]; |
212 } | 212 } |
OLD | NEW |