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

Side by Side Diff: frog/lib/corelib_impl.dart

Issue 9431015: Wrote functions to convert collections and maps to strings and invoked (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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 | « frog/lib/collections.dart ('k') | frog/lib/frog_coreimpl_sources.gypi » ('j') | no next file with comments »
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 #library("dart:coreimpl"); 5 #library("dart:coreimpl");
6 6
7 #source("../../corelib/src/implementation/dual_pivot_quicksort.dart"); 7 #source("../../corelib/src/implementation/dual_pivot_quicksort.dart");
8 #source("../../corelib/src/implementation/duration_implementation.dart"); 8 #source("../../corelib/src/implementation/duration_implementation.dart");
9 #source("../../corelib/src/implementation/exceptions.dart"); 9 #source("../../corelib/src/implementation/exceptions.dart");
10 #source("../../corelib/src/implementation/collections.dart");
10 #source("../../corelib/src/implementation/future_implementation.dart"); 11 #source("../../corelib/src/implementation/future_implementation.dart");
11 #source("../../corelib/src/implementation/hash_map_set.dart"); 12 #source("../../corelib/src/implementation/hash_map_set.dart");
12 // TODO(jimhug): Re-explore tradeoffs with using builtin JS maps. 13 // TODO(jimhug): Re-explore tradeoffs with using builtin JS maps.
13 #source("../../corelib/src/implementation/linked_hash_map.dart"); 14 #source("../../corelib/src/implementation/linked_hash_map.dart");
14 #source("../../corelib/src/implementation/maps.dart"); 15 #source("../../corelib/src/implementation/maps.dart");
15 #source("../../corelib/src/implementation/options.dart"); 16 #source("../../corelib/src/implementation/options.dart");
16 #source("../../corelib/src/implementation/queue.dart"); 17 #source("../../corelib/src/implementation/queue.dart");
17 #source("../../corelib/src/implementation/stopwatch_implementation.dart"); 18 #source("../../corelib/src/implementation/stopwatch_implementation.dart");
18 #source("../../corelib/src/implementation/splay_tree.dart"); 19 #source("../../corelib/src/implementation/splay_tree.dart");
19 20
20 #source("string_buffer.dart"); 21 #source("string_buffer.dart");
21 #source("string_base.dart"); 22 #source("string_base.dart");
22 #source("string_implementation.dart"); 23 #source("string_implementation.dart");
23 #source("arrays.dart"); 24 #source("arrays.dart");
24 #source("collections.dart");
25 #source("date_implementation.dart"); 25 #source("date_implementation.dart");
26 26
27 #source("isolate.dart"); 27 #source("isolate.dart");
28 #source("isolate_serialization.dart"); 28 #source("isolate_serialization.dart");
29 29
30 #source("function_implementation.dart"); 30 #source("function_implementation.dart");
31 31
32 /** 32 /**
33 * The default implementation of the [List<E>] interface. Essentially a growable 33 * The default implementation of the [List<E>] interface. Essentially a growable
34 * array that will expand automatically as more elements are added. 34 * array that will expand automatically as more elements are added.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // Collection<E> members: 126 // Collection<E> members:
127 void forEach(void f(E element)) native; 127 void forEach(void f(E element)) native;
128 Collection<E> filter(bool f(E element)) native; 128 Collection<E> filter(bool f(E element)) native;
129 Collection map(f(E element)) native; 129 Collection map(f(E element)) native;
130 bool every(bool f(E element)) native; 130 bool every(bool f(E element)) native;
131 bool some(bool f(E element)) native; 131 bool some(bool f(E element)) native;
132 bool isEmpty() => length == 0; 132 bool isEmpty() => length == 0;
133 133
134 // Iterable<E> members: 134 // Iterable<E> members:
135 Iterator<E> iterator() => new ListIterator(this); 135 Iterator<E> iterator() => new ListIterator(this);
136
137 String toString() => Collections.collectionToString(this);
136 } 138 }
137 139
138 // Iterator for lists. 140 // Iterator for lists.
139 class ListIterator<T> implements Iterator<T> { 141 class ListIterator<T> implements Iterator<T> {
140 ListIterator(List<T> array) 142 ListIterator(List<T> array)
141 : _array = array, 143 : _array = array,
142 _pos = 0 { 144 _pos = 0 {
143 } 145 }
144 146
145 bool hasNext() { 147 bool hasNext() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 221 }
220 222
221 void clear() { 223 void clear() {
222 throw const IllegalAccessException(); 224 throw const IllegalAccessException();
223 } 225 }
224 226
225 E removeLast() { 227 E removeLast() {
226 throw const IllegalAccessException(); 228 throw const IllegalAccessException();
227 } 229 }
228 230
229 231 String toString() => Collections.collectionToString(this);
230 // The base Array.prototype.toString does not like getting derived arrays,
231 // so copy the array if needed.
232 // TODO(jmesserly): this is not the right long term fix because it only works
233 // for ImmutableList, but all derived types of ListFactory have this problem.
234 // We need to implment ListFactory.toString in Dart. However, the
235 // mplmentation needs correct handling of cycles (isolate tests depend on
236 // this), so it's not trivial.
237 String toString() => new List.from(this).toString();
238 } 232 }
239 233
240 234
241 LinkedHashMapImplementation _map(List itemsAndKeys) { 235 LinkedHashMapImplementation _map(List itemsAndKeys) {
242 LinkedHashMapImplementation ret = new LinkedHashMapImplementation(); 236 LinkedHashMapImplementation ret = new LinkedHashMapImplementation();
243 for (int i=0; i < itemsAndKeys.length;) { 237 for (int i=0; i < itemsAndKeys.length;) {
244 ret[itemsAndKeys[i++]] = itemsAndKeys[i++]; 238 ret[itemsAndKeys[i++]] = itemsAndKeys[i++];
245 } 239 }
246 return ret; 240 return ret;
247 } 241 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 throw const IllegalAccessException(); 276 throw const IllegalAccessException();
283 } 277 }
284 278
285 void clear() { 279 void clear() {
286 throw const IllegalAccessException(); 280 throw const IllegalAccessException();
287 } 281 }
288 282
289 V remove(K key) { 283 V remove(K key) {
290 throw const IllegalAccessException(); 284 throw const IllegalAccessException();
291 } 285 }
286
287 String toString() => Maps.mapToString(this);
292 } 288 }
293 289
294 290
295 // TODO(jmesserly): this should wrap real RegExp when we can 291 // TODO(jmesserly): this should wrap real RegExp when we can
296 // We can't do it yet because we'd need a way to redirect the const 292 // We can't do it yet because we'd need a way to redirect the const
297 // default constructor. 293 // default constructor.
298 // TODO(jimhug): One way to resolve this is to make the const constructor 294 // TODO(jimhug): One way to resolve this is to make the const constructor
299 // very special in order for it to generate JS regex literals into the code 295 // very special in order for it to generate JS regex literals into the code
300 // and then treat the constructor as a factory. 296 // and then treat the constructor as a factory.
301 class JSSyntaxRegExp implements RegExp { 297 class JSSyntaxRegExp implements RegExp {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } else if (isNaN()) { 519 } else if (isNaN()) {
524 if (other.isNaN()) { 520 if (other.isNaN()) {
525 return 0; 521 return 0;
526 } 522 }
527 return 1; 523 return 1;
528 } else { 524 } else {
529 return -1; 525 return -1;
530 } 526 }
531 } 527 }
532 } 528 }
OLDNEW
« no previous file with comments | « frog/lib/collections.dart ('k') | frog/lib/frog_coreimpl_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698