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 library dart._internal; | 5 library dart._internal; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'dart:core' hide Symbol; | 9 import 'dart:core' hide Symbol; |
10 import 'dart:core' as core; | 10 import 'dart:core' as core; |
11 import 'dart:math' show Random; | 11 import 'dart:math' show Random; |
12 | 12 |
13 part 'iterable.dart'; | 13 part 'iterable.dart'; |
14 part 'list.dart'; | 14 part 'list.dart'; |
15 part 'print.dart'; | 15 part 'print.dart'; |
16 part 'sort.dart'; | 16 part 'sort.dart'; |
17 part 'symbol.dart'; | 17 part 'symbol.dart'; |
18 | 18 |
19 // Powers of 10 up to 10^22 are representable as doubles. | 19 // Powers of 10 up to 10^22 are representable as doubles. |
20 // Powers of 10 above that are only approximate due to lack of precission. | 20 // Powers of 10 above that are only approximate due to lack of precission. |
21 // Used by double-parsing. | 21 // Used by double-parsing. |
22 const POWERS_OF_TEN = const [ | 22 const POWERS_OF_TEN = const [ |
23 1.0, /* 0 */ | 23 1.0, // 0 |
24 10.0, | 24 10.0, |
25 100.0, | 25 100.0, |
26 1000.0, | 26 1000.0, |
27 10000.0, | 27 10000.0, |
28 100000.0, /* 5 */ | 28 100000.0, // 5 |
29 1000000.0, | 29 1000000.0, |
30 10000000.0, | 30 10000000.0, |
31 100000000.0, | 31 100000000.0, |
32 1000000000.0, | 32 1000000000.0, |
33 10000000000.0, /* 10 */ | 33 10000000000.0, // 10 |
34 100000000000.0, | 34 100000000000.0, |
35 1000000000000.0, | 35 1000000000000.0, |
36 10000000000000.0, | 36 10000000000000.0, |
37 100000000000000.0, | 37 100000000000000.0, |
38 1000000000000000.0, /* 15 */ | 38 1000000000000000.0, // 15 |
39 10000000000000000.0, | 39 10000000000000000.0, |
40 100000000000000000.0, | 40 100000000000000000.0, |
41 1000000000000000000.0, | 41 1000000000000000000.0, |
42 10000000000000000000.0, | 42 10000000000000000000.0, |
43 100000000000000000000.0, /* 20 */ | 43 100000000000000000000.0, // 20 |
44 1000000000000000000000.0, | 44 1000000000000000000000.0, |
45 10000000000000000000000.0, | 45 10000000000000000000000.0, |
46 ]; | 46 ]; |
47 | 47 |
48 /** | 48 /** |
49 * An [Iterable] of the UTF-16 code units of a [String] in index order. | 49 * An [Iterable] of the UTF-16 code units of a [String] in index order. |
50 */ | 50 */ |
51 class CodeUnits extends UnmodifiableListBase<int> { | 51 class CodeUnits extends UnmodifiableListBase<int> { |
52 /** The string that this is the code units of. */ | 52 /** The string that this is the code units of. */ |
53 final String _string; | 53 final String _string; |
54 | 54 |
55 CodeUnits(this._string); | 55 CodeUnits(this._string); |
56 | 56 |
57 int get length => _string.length; | 57 int get length => _string.length; |
58 int operator[](int i) => _string.codeUnitAt(i); | 58 int operator [](int i) => _string.codeUnitAt(i); |
59 | 59 |
60 static String stringOf(CodeUnits u) => u._string; | 60 static String stringOf(CodeUnits u) => u._string; |
61 } | 61 } |
62 | 62 |
63 /// Marks a function as an external implementation ("native" in the Dart VM). | 63 /// Marks a function as an external implementation ("native" in the Dart VM). |
64 /// | 64 /// |
65 /// Provides a backend-specific String that can be used to identify the | 65 /// Provides a backend-specific String that can be used to identify the |
66 /// function's implementation. | 66 /// function's implementation. |
67 class ExternalName { | 67 class ExternalName { |
68 final String name; | 68 final String name; |
(...skipping 19 matching lines...) Expand all Loading... |
88 | 88 |
89 /// Parses two hex digits in a string. | 89 /// Parses two hex digits in a string. |
90 /// | 90 /// |
91 /// Returns a negative value if either digit isn't valid. | 91 /// Returns a negative value if either digit isn't valid. |
92 int parseHexByte(String source, int index) { | 92 int parseHexByte(String source, int index) { |
93 assert(index + 2 <= source.length); | 93 assert(index + 2 <= source.length); |
94 int digit1 = hexDigitValue(source.codeUnitAt(index)); | 94 int digit1 = hexDigitValue(source.codeUnitAt(index)); |
95 int digit2 = hexDigitValue(source.codeUnitAt(index + 1)); | 95 int digit2 = hexDigitValue(source.codeUnitAt(index + 1)); |
96 return digit1 * 16 + digit2 - (digit2 & 256); | 96 return digit1 * 16 + digit2 - (digit2 & 256); |
97 } | 97 } |
OLD | NEW |