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 // Patch file for dart:core classes. | 5 // Patch file for dart:core classes. |
6 | 6 |
7 import 'dart:_interceptors'; | 7 import 'dart:_interceptors'; |
8 import 'dart:_js_helper' show checkNull, | 8 import 'dart:_js_helper' show checkNull, |
9 getRuntimeTypeString, | 9 getRuntimeTypeString, |
10 isJsArray, | 10 isJsArray, |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 patch class String { | 195 patch class String { |
196 patch factory String.fromCharCodes(List<int> charCodes) { | 196 patch factory String.fromCharCodes(List<int> charCodes) { |
197 if (!isJsArray(charCodes)) { | 197 if (!isJsArray(charCodes)) { |
198 if (charCodes is !List) throw new ArgumentError(charCodes); | 198 if (charCodes is !List) throw new ArgumentError(charCodes); |
199 charCodes = new List.from(charCodes); | 199 charCodes = new List.from(charCodes); |
200 } | 200 } |
201 return Primitives.stringFromCharCodes(charCodes); | 201 return Primitives.stringFromCharCodes(charCodes); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 // Patch for String implementation. | |
206 patch class Strings { | |
207 patch static String join(Iterable<String> strings, String separator) { | |
208 checkNull(strings); | |
209 if (separator is !String) throw new ArgumentError(separator); | |
210 return stringJoinUnchecked(_toJsStringArray(strings), separator); | |
211 } | |
212 | |
213 patch static String concatAll(Iterable<String> strings) { | |
214 return stringJoinUnchecked(_toJsStringArray(strings), ""); | |
215 } | |
216 | |
217 static List _toJsStringArray(Iterable<String> strings) { | |
218 checkNull(strings); | |
219 var array; | |
220 if (!isJsArray(strings)) { | |
221 strings = new List.from(strings); | |
222 } | |
223 final length = strings.length; | |
224 for (int i = 0; i < length; i++) { | |
225 final string = strings[i]; | |
226 if (string is !String) throw new ArgumentError(string); | |
227 } | |
228 return strings; | |
229 } | |
230 } | |
231 | |
232 patch class RegExp { | 205 patch class RegExp { |
233 patch factory RegExp(String pattern, | 206 patch factory RegExp(String pattern, |
234 {bool multiLine: false, | 207 {bool multiLine: false, |
235 bool caseSensitive: true}) | 208 bool caseSensitive: true}) |
236 => new JSSyntaxRegExp(pattern, | 209 => new JSSyntaxRegExp(pattern, |
237 multiLine: multiLine, | 210 multiLine: multiLine, |
238 caseSensitive: caseSensitive); | 211 caseSensitive: caseSensitive); |
239 } | 212 } |
240 | 213 |
241 // Patch for 'identical' function. | 214 // Patch for 'identical' function. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 String formalParameters = sb.toString(); | 280 String formalParameters = sb.toString(); |
308 return "NoSuchMethodError: incorrect number of arguments passed to " | 281 return "NoSuchMethodError: incorrect number of arguments passed to " |
309 "method named '$_memberName'\n" | 282 "method named '$_memberName'\n" |
310 "Receiver: ${Error.safeToString(_receiver)}\n" | 283 "Receiver: ${Error.safeToString(_receiver)}\n" |
311 "Tried calling: $_memberName($actualParameters)\n" | 284 "Tried calling: $_memberName($actualParameters)\n" |
312 "Found: $_memberName($formalParameters)"; | 285 "Found: $_memberName($formalParameters)"; |
313 } | 286 } |
314 } | 287 } |
315 } | 288 } |
316 | 289 |
OLD | NEW |