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

Unified Diff: lib/compiler/implementation/lib/core_patch.dart

Issue 11085003: Convert String to a class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove left-over List change in comment. Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
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 f47c27b840561e48ef14845cb5d63c9289a49fa5..a4844096bb9ae5b01f92ec2cca66b35259697b3e 100644
--- a/lib/compiler/implementation/lib/core_patch.dart
+++ b/lib/compiler/implementation/lib/core_patch.dart
@@ -83,3 +83,54 @@ patch class NoSuchMethodError {
return Primitives.objectToString(object);
}
}
+
+
+// Patch for String implementation.
+// TODO(ager): Split out into date_patch.dart and allow #source
ahe 2012/10/08 14:06:11 How is this related to date?
Lasse Reichstein Nielsen 2012/10/09 11:53:22 Another cut-n-paste propagation of the original ty
+// in patch files?
+patch class String {
+ patch factory String.fromCharCodes(List<int> charCodes) {
+ checkNull(charCodes);
+ if (!isJsArray(charCodes)) {
+ if (charCodes is !List) throw new IllegalArgumentException(charCodes);
+ charCodes = new List.from(charCodes);
+ }
+ return Primitives.stringFromCharCodes(charCodes);
+ }
+}
+
+patch class Strings {
+ patch static String join(List<String> strings, String separator) {
+ checkNull(strings);
+ checkNull(separator);
+ if (separator is !String) throw new IllegalArgumentException(separator);
+ return stringJoinUnchecked(_toJsStringArray(strings), separator);
+ }
+
+ patch static String concatAll(List<String> strings) {
+ 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 IllegalArgumentException(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 IllegalArgumentException(string);
+ array[i] = string;
+ }
+ }
+ return array;
+ }
+}
« no previous file with comments | « no previous file | lib/compiler/implementation/lib/coreimpl_patch.dart » ('j') | tests/co19/co19-dart2dart.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698