| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * | |
| 7 * Built-in types, collections, | |
| 8 * and other core functionality for every Dart program. | |
| 9 * | |
| 10 * This library is automatically imported. | |
| 11 * | |
| 12 * Some classes in this library, | |
| 13 * such as [String] and [num], | |
| 14 * support Dart's built-in data types. | |
| 15 * Other classes, such as [List] and [Map], provide data structures | |
| 16 * for managing collections of objects. | |
| 17 * And still other classes represent commonly used types of data | |
| 18 * such as URIs, dates and times, and errors. | |
| 19 * | |
| 20 * ## Numbers and booleans | |
| 21 * | |
| 22 * [int] and [double] provide support for Dart's built-in numerical data types: | |
| 23 * integers and double-precision floating point numbers, respectively. | |
| 24 * An object of type [bool] is either true or false. | |
| 25 * Variables of these types can be constructed from literals: | |
| 26 * | |
| 27 * int meaningOfLife = 42; | |
| 28 * double valueOfPi = 3.141592; | |
| 29 * bool visible = true; | |
| 30 * | |
| 31 * ## Strings and regular expressions | |
| 32 * | |
| 33 * A [String] is immutable and represents a sequence of characters. | |
| 34 * | |
| 35 * String shakespeareQuote = "All the world's a stage, ..."; | |
| 36 * | |
| 37 * [StringBuffer] provides a way to construct strings efficiently. | |
| 38 * | |
| 39 * StringBuffer moreShakespeare = new StringBuffer(); | |
| 40 * moreShakespeare.write('And all the men and women '); | |
| 41 * moreShakespeare.write('merely players; ...'); | |
| 42 * | |
| 43 * The String and StringBuffer classes implement string concatenation, | |
| 44 * interpolation, and other string manipulation features. | |
| 45 * | |
| 46 * String philosophy = 'Live on '; | |
| 47 * String get palindrome => philosophy + philosophy.split('').reversed.join(
); | |
| 48 * | |
| 49 * [RegExp] implements Dart regular expressions, | |
| 50 * which provide a grammar for matching patterns within text. | |
| 51 * For example, here's a regular expression that matches | |
| 52 * a string of one or more digits: | |
| 53 * | |
| 54 * var numbers = new RegExp(r'\d+'); | |
| 55 * | |
| 56 * Dart regular expressions have the same syntax and semantics as | |
| 57 * JavaScript regular expressions. See | |
| 58 * <http://ecma-international.org/ecma-262/5.1/#sec-15.10> | |
| 59 * for the specification of JavaScript regular expressions. | |
| 60 * | |
| 61 * ## Collections | |
| 62 * | |
| 63 * The dart:core library provides basic collections, | |
| 64 * such as [List], [Map], and [Set]. | |
| 65 * | |
| 66 * A List is an ordered collection of objects, with a length. | |
| 67 * Lists are sometimes called arrays. | |
| 68 * Use a List when you need to access objects by index. | |
| 69 * | |
| 70 * List superheroes = [ 'Batman', 'Superman', 'Harry Potter' ]; | |
| 71 * | |
| 72 * A Set is an unordered collection of unique objects. | |
| 73 * You cannot get an item by index (position). | |
| 74 * Adding a duplicate item has no effect. | |
| 75 * | |
| 76 * Set villains = new Set(); | |
| 77 * villains.add('Joker'); | |
| 78 * villains.addAll( ['Lex Luther', 'Voldemort'] ); | |
| 79 * | |
| 80 * A Map is an unordered collection of key-value pairs. | |
| 81 * Maps are sometimes called associative arrays because | |
| 82 * maps associate a key to some value for easy retrieval. | |
| 83 * Keys are unique. | |
| 84 * Use a Map when you need to access objects | |
| 85 * by a unique identifier. | |
| 86 * | |
| 87 * Map sidekicks = { 'Batman': 'Robin', | |
| 88 * 'Superman': 'Lois Lane', | |
| 89 * 'Harry Potter': 'Ron and Hermione' }; | |
| 90 * | |
| 91 * In addition to these classes, | |
| 92 * dart:core contains [Iterable], | |
| 93 * an interface that defines functionality | |
| 94 * common in collections of objects. | |
| 95 * Examples include the ability | |
| 96 * to run a function on each element in the collection, | |
| 97 * to apply a test to each element, | |
| 98 * to retrieve an object, and to determine length. | |
| 99 * | |
| 100 * Iterable is implemented by List and Set, | |
| 101 * and used by Map for its keys and values. | |
| 102 * | |
| 103 * For other kinds of collections, check out the | |
| 104 * [dart:collection](#dart-collection) library. | |
| 105 * | |
| 106 * ## Date and time | |
| 107 * | |
| 108 * Use [DateTime] to represent a point in time | |
| 109 * and [Duration] to represent a span of time. | |
| 110 * | |
| 111 * You can create DateTime objects with constructors | |
| 112 * or by parsing a correctly formatted string. | |
| 113 * | |
| 114 * DateTime now = new DateTime.now(); | |
| 115 * DateTime berlinWallFell = new DateTime(1989, 11, 9); | |
| 116 * DateTime moonLanding = DateTime.parse("1969-07-20"); | |
| 117 * | |
| 118 * Create a Duration object specifying the individual time units. | |
| 119 * | |
| 120 * Duration timeRemaining = new Duration(hours:56, minutes:14); | |
| 121 * | |
| 122 * In addition to DateTime and Duration, | |
| 123 * dart:core contains the [Stopwatch] class for measuring elapsed time. | |
| 124 * | |
| 125 * ## Uri | |
| 126 * | |
| 127 * A [Uri] object represents a uniform resource identifier, | |
| 128 * which identifies a resource on the web. | |
| 129 * | |
| 130 * Uri dartlang = Uri.parse('http://dartlang.org/'); | |
| 131 * | |
| 132 * ## Errors | |
| 133 * | |
| 134 * The [Error] class represents the occurrence of an error | |
| 135 * during runtime. | |
| 136 * Subclasses of this class represent specific kinds of errors. | |
| 137 * | |
| 138 * ## Other documentation | |
| 139 * | |
| 140 * For more information about how to use the built-in types, refer to | |
| 141 * [Built-in Types](http://www.dartlang.org/docs/dart-up-and-running/contents/ch
02.html#built-in-types) | |
| 142 * in Chapter 2 of | |
| 143 * [Dart: Up and Running](http://www.dartlang.org/docs/dart-up-and-running/). | |
| 144 * | |
| 145 * Also, see | |
| 146 * [dart:core - Numbers, Collections, Strings, and More](http://www.dartlang.org
/docs/dart-up-and-running/contents/ch03.html#ch03-dartcore---strings-collections
-and-more) | |
| 147 * for more coverage of classes in this package. | |
| 148 * | |
| 149 * The | |
| 150 * [Dart Language Specification](http://www.dartlang.org/docs/spec/) | |
| 151 * provides technical details. | |
| 152 */ | |
| 153 library dart.core; | |
| 154 | |
| 155 import "dart:collection"; | |
| 156 import "dart:_internal" hide Symbol; | |
| 157 import "dart:_internal" as internal show Symbol; | |
| 158 import "dart:convert" show UTF8, LATIN1, Encoding; | |
| 159 import "dart:math" show Random; | |
| 160 import "dart:_internal" as _symbol_dev; | |
| 161 import 'dart:_interceptors'; | |
| 162 import 'dart:_js_helper' show patch, | |
| 163 checkInt, | |
| 164 getRuntimeType, | |
| 165 jsonEncodeNative, | |
| 166 JSSyntaxRegExp, | |
| 167 Primitives, | |
| 168 stringJoinUnchecked, | |
| 169 objectHashCode; | |
| 170 import 'dart:_foreign_helper' show JS; // Used by List.shuffle. | |
| 171 | |
| 172 part "annotations.dart"; | |
| 173 part "bool.dart"; | |
| 174 part "comparable.dart"; | |
| 175 part "date_time.dart"; | |
| 176 part "double.dart"; | |
| 177 part "duration.dart"; | |
| 178 part "errors.dart"; | |
| 179 part "exceptions.dart"; | |
| 180 part "expando.dart"; | |
| 181 part "function.dart"; | |
| 182 part "identical.dart"; | |
| 183 part "int.dart"; | |
| 184 part "invocation.dart"; | |
| 185 part "iterable.dart"; | |
| 186 part "iterator.dart"; | |
| 187 part "list.dart"; | |
| 188 part "map.dart"; | |
| 189 part "null.dart"; | |
| 190 part "num.dart"; | |
| 191 part "object.dart"; | |
| 192 part "pattern.dart"; | |
| 193 part "print.dart"; | |
| 194 part "regexp.dart"; | |
| 195 part "set.dart"; | |
| 196 part "sink.dart"; | |
| 197 part "stacktrace.dart"; | |
| 198 part "stopwatch.dart"; | |
| 199 part "string.dart"; | |
| 200 part "string_buffer.dart"; | |
| 201 part "string_sink.dart"; | |
| 202 part "symbol.dart"; | |
| 203 part "type.dart"; | |
| 204 part "uri.dart"; | |
| 205 | |
| 206 String _symbolToString(Symbol symbol) => _symbol_dev.Symbol.getName(symbol); | |
| 207 _symbolMapToStringMap(Map<Symbol, dynamic> map) { | |
| 208 if (map == null) return null; | |
| 209 var result = new Map<String, dynamic>(); | |
| 210 map.forEach((Symbol key, value) { | |
| 211 result[_symbolToString(key)] = value; | |
| 212 }); | |
| 213 return result; | |
| 214 } | |
| 215 class SupportJsExtensionMethods { | |
| 216 const SupportJsExtensionMethods(); | |
| 217 } | |
| 218 class _ListConstructorSentinel { | |
| 219 const _ListConstructorSentinel(); | |
| 220 } | |
| OLD | NEW |