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

Side by Side Diff: lib/compiler/implementation/lib/coreimpl_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
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:coreimpl classes. 5 // Patch file for dart:coreimpl classes.
6 6
7 // Patch for String implementation.
8 // TODO(ager): Split out into date_patch.dart and allow #source
9 // in patch files?
10 patch class StringImplementation {
11 patch static _fromCharCodes(List<int> charCodes) {
12 checkNull(charCodes);
13 if (!isJsArray(charCodes)) {
14 if (charCodes is !List) throw new ArgumentError(charCodes);
15 charCodes = new List.from(charCodes);
16 }
17 return Primitives.stringFromCharCodes(charCodes);
18 }
19
20 patch String join(List<String> strings, String separator) {
21 checkNull(strings);
22 checkNull(separator);
23 if (separator is !String) throw new ArgumentError(separator);
24 return stringJoinUnchecked(_toJsStringArray(strings), separator);
25 }
26
27 patch String concatAll(List<String> strings) {
28 return stringJoinUnchecked(_toJsStringArray(strings), "");
29 }
30
31 static List _toJsStringArray(List<String> strings) {
32 checkNull(strings);
33 var array;
34 final length = strings.length;
35 if (isJsArray(strings)) {
36 array = strings;
37 for (int i = 0; i < length; i++) {
38 final string = strings[i];
39 checkNull(string);
40 if (string is !String) throw new ArgumentError(string);
41 }
42 } else {
43 array = new List(length);
44 for (int i = 0; i < length; i++) {
45 final string = strings[i];
46 checkNull(string);
47 if (string is !String) throw new ArgumentError(string);
48 array[i] = string;
49 }
50 }
51 return array;
52 }
53 }
54
55
56 // Patch for List implementation.
57 // TODO(ager): Split out into date_patch.dart and allow #source
58 // in patch files?
59 patch class ListImplementation<E> {
60 patch factory List([int length]) => Primitives.newList(length);
61
62 patch static List _from(Iterable other) {
63 List result = new List();
64 for (var element in other) {
65 result.add(element);
66 }
67 return result;
68 }
69 }
70
71
72 // Patch for Date implementation. 7 // Patch for Date implementation.
73 // TODO(ager): Split out into date_patch.dart and allow #source 8 // TODO(ager): Split out into date_patch.dart and allow #source
74 // in patch files? 9 // in patch files?
75 patch class DateImplementation { 10 patch class DateImplementation {
76 patch DateImplementation(int year, 11 patch DateImplementation(int year,
77 [int month = 1, 12 [int month = 1,
78 int day = 1, 13 int day = 1,
79 int hour = 0, 14 int hour = 0,
80 int minute = 0, 15 int minute = 0,
81 int second = 0, 16 int second = 0,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // hidden global flag. 192 // hidden global flag.
258 _next = _re.firstMatch(_str); 193 _next = _re.firstMatch(_str);
259 if (_next == null) { 194 if (_next == null) {
260 _done = true; 195 _done = true;
261 return false; 196 return false;
262 } else { 197 } else {
263 return true; 198 return true;
264 } 199 }
265 } 200 }
266 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698