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

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

Issue 10942025: Convert String and List to abstract classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated to tip-of-tree. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/compiler/implementation/lib/coreimpl.dart » ('j') | lib/core/collection.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 obj) { 8 patch void print(var obj) {
9 if (obj is String) { 9 if (obj is String) {
10 Primitives.printString(obj); 10 Primitives.printString(obj);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 patch class double { 69 patch class double {
70 patch static double parse(String string) => Primitives.parseDouble(string); 70 patch static double parse(String string) => Primitives.parseDouble(string);
71 } 71 }
72 72
73 patch class NoSuchMethodError { 73 patch class NoSuchMethodError {
74 patch static String _objectToString(Object object) { 74 patch static String _objectToString(Object object) {
75 return Primitives.objectToString(object); 75 return Primitives.objectToString(object);
76 } 76 }
77 } 77 }
78
79
80 // Patch for List implementation.
81 patch class List<E> {
82 patch factory List([int length]) => Primitives.newList(length);
83 }
84
85 // Patch for String implementation.
86 // TODO(ager): Split out into date_patch.dart and allow #source
87 // in patch files?
88 patch class String {
89 patch factory String.fromCharCodes(List<int> charCodes) {
90 checkNull(charCodes);
91 if (!isJsArray(charCodes)) {
92 if (charCodes is !List) throw new IllegalArgumentException(charCodes);
93 charCodes = new List.from(charCodes);
94 }
95 return Primitives.stringFromCharCodes(charCodes);
96 }
97 }
98
99 patch class Strings {
100 patch static String join(List<String> strings, String separator) {
101 checkNull(strings);
102 checkNull(separator);
103 if (separator is !String) throw new IllegalArgumentException(separator);
104 return stringJoinUnchecked(_toJsStringArray(strings), separator);
105 }
106
107 patch static String concatAll(List<String> strings) {
108 return stringJoinUnchecked(_toJsStringArray(strings), "");
109 }
110
111 static List _toJsStringArray(List<String> strings) {
112 checkNull(strings);
113 var array;
114 final length = strings.length;
115 if (isJsArray(strings)) {
116 array = strings;
117 for (int i = 0; i < length; i++) {
118 final string = strings[i];
119 checkNull(string);
120 if (string is !String) throw new IllegalArgumentException(string);
121 }
122 } else {
123 array = new List(length);
124 for (int i = 0; i < length; i++) {
125 final string = strings[i];
126 checkNull(string);
127 if (string is !String) throw new IllegalArgumentException(string);
128 array[i] = string;
129 }
130 }
131 return array;
132 }
133 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/lib/coreimpl.dart » ('j') | lib/core/collection.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698