Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/lib/core_patch.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Patch file for dart:core classes. 5 // Patch file for dart:core classes.
6 6
7 // Patch for 'print' function. 7 // Patch for 'print' function.
8 patch void print(var object) { 8 patch void print(var object) {
9 if (object is String) { 9 if (object is String) {
10 Primitives.printString(object); 10 Primitives.printString(object);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 return key; 69 return key;
70 } 70 }
71 71
72 static const String _KEY_PROPERTY_NAME = 'expando\$key'; 72 static const String _KEY_PROPERTY_NAME = 'expando\$key';
73 static const String _EXPANDO_PROPERTY_NAME = 'expando\$values'; 73 static const String _EXPANDO_PROPERTY_NAME = 'expando\$values';
74 static int _keyCount = 0; 74 static int _keyCount = 0;
75 } 75 }
76 76
77 patch class int { 77 patch class int {
78 patch static int parse(String source) => Primitives.parseInt(source); 78 patch static int parse(String source,
79 { int radix,
80 int onError(String source) }) {
81 return Primitives.parseInt(source, radix, onError);
82 }
79 } 83 }
80 84
81 patch class double { 85 patch class double {
82 patch static double parse(String source) => Primitives.parseDouble(source); 86 patch static double parse(String source, [int handleError(String source)]) {
87 return Primitives.parseDouble(source, handleError);
88 }
83 } 89 }
84 90
85 patch class Error { 91 patch class Error {
86 patch static String _objectToString(Object object) { 92 patch static String _objectToString(Object object) {
87 return Primitives.objectToString(object); 93 return Primitives.objectToString(object);
88 } 94 }
89 } 95 }
90 96
91 97
92 // Patch for Date implementation. 98 // Patch for Date implementation.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 154
149 // Patch for Stopwatch implementation. 155 // Patch for Stopwatch implementation.
150 patch class _StopwatchImpl { 156 patch class _StopwatchImpl {
151 patch static int _frequency() => 1000000; 157 patch static int _frequency() => 1000000;
152 patch static int _now() => Primitives.numMicroseconds(); 158 patch static int _now() => Primitives.numMicroseconds();
153 } 159 }
154 160
155 161
156 // Patch for List implementation. 162 // Patch for List implementation.
157 patch class List<E> { 163 patch class List<E> {
158 patch factory List([int length]) => Primitives.newList(length); 164 patch factory List([int length = 0]) {
165 if ((length is !int) || (length < 0)) {
166 String lengthString = Error.safeToString(length);
167 throw new ArgumentError(
168 "Length must be a positive integer: $lengthString.");
169 }
170 return Primitives.newGrowableList(length);
171 }
172
173 patch factory List.fixedLength(int length, {E fill: null}) {
174 if ((length is !int) || (length < 0)) {
175 throw new ArgumentError("Length must be a positive integer: $length.");
176 }
177 List result = Primitives.newFixedList(length);
178 if (length != 0 && fill != null) {
179 for (int i = 0; i < result.length; i++) {
180 result[i] = fill;
181 }
182 }
183 return result;
184 }
185
186 /**
187 * Creates an extendable list of the given [length] where each entry is
188 * filled with [fill].
189 */
190 patch factory List.filled(int length, E fill) {
191 if ((length is !int) || (length < 0)) {
192 throw new ArgumentError("Length must be a positive integer: $length.");
193 }
194 List result = Primitives.newGrowableList(length);
195 if (length != 0 && fill != null) {
196 for (int i = 0; i < result.length; i++) {
197 result[i] = fill;
198 }
199 }
200 return result;
201 }
159 } 202 }
160 203
161 204
162 patch class String { 205 patch class String {
163 patch factory String.fromCharCodes(List<int> charCodes) { 206 patch factory String.fromCharCodes(List<int> charCodes) {
164 if (!isJsArray(charCodes)) { 207 if (!isJsArray(charCodes)) {
165 if (charCodes is !List) throw new ArgumentError(charCodes); 208 if (charCodes is !List) throw new ArgumentError(charCodes);
166 charCodes = new List.from(charCodes); 209 charCodes = new List.from(charCodes);
167 } 210 }
168 return Primitives.stringFromCharCodes(charCodes); 211 return Primitives.stringFromCharCodes(charCodes);
169 } 212 }
170 } 213 }
171 214
172 // Patch for String implementation. 215 // Patch for String implementation.
173 patch class Strings { 216 patch class Strings {
174 patch static String join(List<String> strings, String separator) { 217 patch static String join(Iterable<String> strings, String separator) {
175 checkNull(strings); 218 checkNull(strings);
176 if (separator is !String) throw new ArgumentError(separator); 219 if (separator is !String) throw new ArgumentError(separator);
177 return stringJoinUnchecked(_toJsStringArray(strings), separator); 220 return stringJoinUnchecked(_toJsStringArray(strings), separator);
178 } 221 }
179 222
180 patch static String concatAll(List<String> strings) { 223 patch static String concatAll(Iterable<String> strings) {
181 return stringJoinUnchecked(_toJsStringArray(strings), ""); 224 return stringJoinUnchecked(_toJsStringArray(strings), "");
182 } 225 }
183 226
184 static List _toJsStringArray(List<String> strings) { 227 static List _toJsStringArray(Iterable<String> strings) {
185 checkNull(strings); 228 checkNull(strings);
186 var array; 229 var array;
230 if (!isJsArray(strings)) {
231 strings = new List.from(strings);
232 }
187 final length = strings.length; 233 final length = strings.length;
188 if (isJsArray(strings)) { 234 for (int i = 0; i < length; i++) {
189 array = strings; 235 final string = strings[i];
190 for (int i = 0; i < length; i++) { 236 if (string is !String) throw new ArgumentError(string);
191 final string = strings[i];
192 if (string is !String) throw new ArgumentError(string);
193 }
194 } else {
195 array = new List(length);
196 for (int i = 0; i < length; i++) {
197 final string = strings[i];
198 if (string is !String) throw new ArgumentError(string);
199 array[i] = string;
200 }
201 } 237 }
202 return array; 238 return strings;
203 } 239 }
204 } 240 }
205 241
206 patch class RegExp { 242 patch class RegExp {
207 patch factory RegExp(String pattern, 243 patch factory RegExp(String pattern,
208 {bool multiLine: false, 244 {bool multiLine: false,
209 bool ignoreCase: false}) 245 bool caseSensitive: true})
210 => new JSSyntaxRegExp(pattern, 246 => new JSSyntaxRegExp(pattern,
211 multiLine: multiLine, 247 multiLine: multiLine,
212 ignoreCase: ignoreCase); 248 caseSensitive: caseSensitive);
213 } 249 }
214 250
215 // Patch for 'identical' function. 251 // Patch for 'identical' function.
216 patch bool identical(Object a, Object b) { 252 patch bool identical(Object a, Object b) {
217 throw new Error('Should not reach the body of identical'); 253 throw new Error('Should not reach the body of identical');
218 } 254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698