Chromium Code Reviews| Index: lib/compiler/implementation/lib/core_patch.dart |
| diff --git a/lib/compiler/implementation/lib/core_patch.dart b/lib/compiler/implementation/lib/core_patch.dart |
| index 31c94d74510e86b72be3baa6b33d59b46199bea1..58536c74e91f5035f85e164e113d8ed82247542c 100644 |
| --- a/lib/compiler/implementation/lib/core_patch.dart |
| +++ b/lib/compiler/implementation/lib/core_patch.dart |
| @@ -162,3 +162,50 @@ patch class _ListImpl<E> { |
| return result; |
| } |
| } |
| + |
| + |
| +// Patch for String implementation. |
| +patch class _StringImpl { |
| + patch factory String.fromCharCodes(List<int> charCodes) { |
| + checkNull(charCodes); |
| + if (!isJsArray(charCodes)) { |
| + if (charCodes is !List) throw new ArgumentError(charCodes); |
| + charCodes = new List.from(charCodes); |
| + } |
| + return Primitives.stringFromCharCodes(charCodes); |
| + } |
| + |
| + patch String join(List<String> strings, String separator) { |
|
floitsch
2012/10/30 13:53:05
should be static.
Anders Johnsen
2012/10/30 14:19:31
Done.
|
| + checkNull(strings); |
| + checkNull(separator); |
| + if (separator is !String) throw new ArgumentError(separator); |
| + return stringJoinUnchecked(_toJsStringArray(strings), separator); |
| + } |
| + |
| + patch String concatAll(List<String> strings) { |
|
floitsch
2012/10/30 13:53:05
should be static.
Anders Johnsen
2012/10/30 14:19:31
Done.
|
| + return stringJoinUnchecked(_toJsStringArray(strings), ""); |
| + } |
| + |
| + static List _toJsStringArray(List<String> strings) { |
| + checkNull(strings); |
| + var array; |
| + final length = strings.length; |
| + if (isJsArray(strings)) { |
| + array = strings; |
| + for (int i = 0; i < length; i++) { |
| + final string = strings[i]; |
| + checkNull(string); |
| + if (string is !String) throw new ArgumentError(string); |
| + } |
| + } else { |
| + array = new List(length); |
| + for (int i = 0; i < length; i++) { |
| + final string = strings[i]; |
| + checkNull(string); |
| + if (string is !String) throw new ArgumentError(string); |
| + array[i] = string; |
| + } |
| + } |
| + return array; |
| + } |
| +} |