| 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:coreimpl classes. | 5 // Patch file for dart:coreimpl classes. |
| 6 | 6 |
| 7 // Patch for String implementation. | 7 // Patch for String implementation. |
| 8 // TODO(ager): Split out into date_patch.dart and allow #source | 8 // TODO(ager): Split out into date_patch.dart and allow #source |
| 9 // in patch files? | 9 // in patch files? |
| 10 patch class StringImplementation { | 10 patch class StringImplementation { |
| 11 patch static _fromCharCodes(List<int> charCodes) { | 11 patch static _fromCharCodes(List<int> charCodes) { |
| 12 checkNull(charCodes); | 12 checkNull(charCodes); |
| 13 if (!isJsArray(charCodes)) { | 13 if (!isJsArray(charCodes)) { |
| 14 if (charCodes is !List) throw new IllegalArgumentException(charCodes); | 14 if (charCodes is !List) throw new ArgumentError(charCodes); |
| 15 charCodes = new List.from(charCodes); | 15 charCodes = new List.from(charCodes); |
| 16 } | 16 } |
| 17 return Primitives.stringFromCharCodes(charCodes); | 17 return Primitives.stringFromCharCodes(charCodes); |
| 18 } | 18 } |
| 19 | 19 |
| 20 patch String join(List<String> strings, String separator) { | 20 patch String join(List<String> strings, String separator) { |
| 21 checkNull(strings); | 21 checkNull(strings); |
| 22 checkNull(separator); | 22 checkNull(separator); |
| 23 if (separator is !String) throw new IllegalArgumentException(separator); | 23 if (separator is !String) throw new ArgumentError(separator); |
| 24 return stringJoinUnchecked(_toJsStringArray(strings), separator); | 24 return stringJoinUnchecked(_toJsStringArray(strings), separator); |
| 25 } | 25 } |
| 26 | 26 |
| 27 patch String concatAll(List<String> strings) { | 27 patch String concatAll(List<String> strings) { |
| 28 return stringJoinUnchecked(_toJsStringArray(strings), ""); | 28 return stringJoinUnchecked(_toJsStringArray(strings), ""); |
| 29 } | 29 } |
| 30 | 30 |
| 31 static List _toJsStringArray(List<String> strings) { | 31 static List _toJsStringArray(List<String> strings) { |
| 32 checkNull(strings); | 32 checkNull(strings); |
| 33 var array; | 33 var array; |
| 34 final length = strings.length; | 34 final length = strings.length; |
| 35 if (isJsArray(strings)) { | 35 if (isJsArray(strings)) { |
| 36 array = strings; | 36 array = strings; |
| 37 for (int i = 0; i < length; i++) { | 37 for (int i = 0; i < length; i++) { |
| 38 final string = strings[i]; | 38 final string = strings[i]; |
| 39 checkNull(string); | 39 checkNull(string); |
| 40 if (string is !String) throw new IllegalArgumentException(string); | 40 if (string is !String) throw new ArgumentError(string); |
| 41 } | 41 } |
| 42 } else { | 42 } else { |
| 43 array = new List(length); | 43 array = new List(length); |
| 44 for (int i = 0; i < length; i++) { | 44 for (int i = 0; i < length; i++) { |
| 45 final string = strings[i]; | 45 final string = strings[i]; |
| 46 checkNull(string); | 46 checkNull(string); |
| 47 if (string is !String) throw new IllegalArgumentException(string); | 47 if (string is !String) throw new ArgumentError(string); |
| 48 array[i] = string; | 48 array[i] = string; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 return array; | 51 return array; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 // Patch for List implementation. | 56 // Patch for List implementation. |
| 57 // TODO(ager): Split out into date_patch.dart and allow #source | 57 // TODO(ager): Split out into date_patch.dart and allow #source |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // hidden global flag. | 257 // hidden global flag. |
| 258 _next = _re.firstMatch(_str); | 258 _next = _re.firstMatch(_str); |
| 259 if (_next == null) { | 259 if (_next == null) { |
| 260 _done = true; | 260 _done = true; |
| 261 return false; | 261 return false; |
| 262 } else { | 262 } else { |
| 263 return true; | 263 return true; |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 } | 266 } |
| OLD | NEW |