| 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 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An arbitrarily large integer. | 8 * An arbitrarily large integer. |
| 9 * | 9 * |
| 10 * **Note:** When compiling to JavaScript, integers are | 10 * **Note:** When compiling to JavaScript, integers are |
| 11 * implemented as JavaScript numbers. When compiling to JavaScript, | 11 * implemented as JavaScript numbers. When compiling to JavaScript, |
| 12 * integers are therefore restricted to 53 significant bits because | 12 * integers are therefore restricted to 53 significant bits because |
| 13 * all JavaScript numbers are double-precision floating point | 13 * all JavaScript numbers are double-precision floating point |
| 14 * values. The behavior of the operators and methods in the [int] | 14 * values. The behavior of the operators and methods in the [int] |
| 15 * class therefore sometimes differs between the Dart VM and Dart code | 15 * class therefore sometimes differs between the Dart VM and Dart code |
| 16 * compiled to JavaScript. | 16 * compiled to JavaScript. |
| 17 * | 17 * |
| 18 * It is a compile-time error for a class to attempt to extend or implement int. | 18 * It is a compile-time error for a class to attempt to extend or implement int. |
| 19 */ | 19 */ |
| 20 abstract class int extends num { | 20 abstract class int extends num { |
| 21 @patch | 21 /** |
| 22 * Returns the integer value of the given environment declaration [name]. |
| 23 * |
| 24 * The result is the same as would be returned by: |
| 25 * |
| 26 * int.parse(const String.fromEnvironment(name, defaultValue: ""), |
| 27 * (_) => defaultValue) |
| 28 * |
| 29 * Example: |
| 30 * |
| 31 * const int.fromEnvironment("defaultPort", defaultValue: 80) |
| 32 */ |
| 22 factory int.fromEnvironment(String name, {int defaultValue}) { | 33 factory int.fromEnvironment(String name, {int defaultValue}) { |
| 23 throw new UnsupportedError( | 34 throw new UnsupportedError( |
| 24 'int.fromEnvironment can only be used as a const constructor'); | 35 'int.fromEnvironment can only be used as a const constructor'); |
| 25 } | 36 } |
| 26 | 37 |
| 27 /** | 38 /** |
| 28 * Bit-wise and operator. | 39 * Bit-wise and operator. |
| 29 * | 40 * |
| 30 * Treating both `this` and [other] as sufficiently large two's component | 41 * Treating both `this` and [other] as sufficiently large two's component |
| 31 * integers, the result is a number with only the bits set that are set in | 42 * integers, the result is a number with only the bits set that are set in |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 /** | 243 /** |
| 233 * Converts [this] to a string representation in the given [radix]. | 244 * Converts [this] to a string representation in the given [radix]. |
| 234 * | 245 * |
| 235 * In the string representation, lower-case letters are used for digits above | 246 * In the string representation, lower-case letters are used for digits above |
| 236 * '9'. | 247 * '9'. |
| 237 * | 248 * |
| 238 * The [radix] argument must be an integer in the range 2 to 36. | 249 * The [radix] argument must be an integer in the range 2 to 36. |
| 239 */ | 250 */ |
| 240 String toRadixString(int radix); | 251 String toRadixString(int radix); |
| 241 | 252 |
| 242 @patch | 253 /** |
| 254 * Parse [source] as an integer literal and return its value. |
| 255 * |
| 256 * The [radix] must be in the range 2..36. The digits used are |
| 257 * first the decimal digits 0..9, and then the letters 'a'..'z'. |
| 258 * Accepts capital letters as well. |
| 259 * |
| 260 * If no [radix] is given then it defaults to 10, unless the string starts |
| 261 * with "0x", "-0x" or "+0x", in which case the radix is set to 16 and the |
| 262 * "0x" is ignored. |
| 263 * |
| 264 * The [source] must be a non-empty sequence of base-[radix] digits, |
| 265 * optionally prefixed with a minus or plus sign ('-' or '+'). |
| 266 * |
| 267 * It must always be the case for an int [:n:] and radix [:r:] that |
| 268 * [:n == int.parse(n.toRadixString(r), radix: r):]. |
| 269 * |
| 270 * If the [source] is not a valid integer literal, optionally prefixed by a |
| 271 * sign, the [onError] is called with the [source] as argument, and its return |
| 272 * value is used instead. If no [onError] is provided, a [FormatException] |
| 273 * is thrown. |
| 274 * |
| 275 * The [onError] function is only invoked if [source] is a [String]. It is |
| 276 * not invoked if the [source] is, for example, `null`. |
| 277 */ |
| 243 static int parse(String source, | 278 static int parse(String source, |
| 244 { int radix, | 279 { int radix, |
| 245 int onError(String source) }) { | 280 int onError(String source) }) { |
| 246 return Primitives.parseInt(source, radix, onError); | 281 return Primitives.parseInt(source, radix, onError); |
| 247 } | 282 } |
| 248 } | 283 } |
| OLD | NEW |