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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/tree/nodes.dart

Issue 11414069: Make mappedBy lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload due to error. Created 8 years, 1 month 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 part of tree; 5 part of tree;
6 6
7 abstract class Visitor<R> { 7 abstract class Visitor<R> {
8 const Visitor(); 8 const Visitor();
9 9
10 R visitNode(Node node); 10 R visitNode(Node node);
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 if (link.head.getEndToken() != null) return link.head.getEndToken(); 464 if (link.head.getEndToken() != null) return link.head.getEndToken();
465 if (link.head.getBeginToken() != null) return link.head.getBeginToken(); 465 if (link.head.getBeginToken() != null) return link.head.getBeginToken();
466 } 466 }
467 return beginToken; 467 return beginToken;
468 } 468 }
469 469
470 // ------------------- Iterable methods ------------------------------------- 470 // ------------------- Iterable methods -------------------------------------
471 // 471 //
472 // TODO(floitsch): these functions should be pulled in through a mixin 472 // TODO(floitsch): these functions should be pulled in through a mixin
473 // mechanism. 473 // mechanism.
474 Collection mappedBy(f(Node element)) { 474 Iterable mappedBy(f(Node element)) => new MappedIterable(this, f);
475 List result = [];
476 for (Node element in this) result.add(f(element));
477 return result;
478 }
479 475
480 Collection<Node> where(bool f(Node element)) { 476 Collection<Node> where(bool f(Node element)) {
481 List result = <Node>[]; 477 List result = <Node>[];
482 for (Node element in this) if (f(element)) result.add(element); 478 for (Node element in this) if (f(element)) result.add(element);
483 return result; 479 return result;
484 } 480 }
485 481
486 bool contains(Node element) { 482 bool contains(Node element) {
487 for (Node e in this) { 483 for (Node e in this) {
488 if (e == element) return true; 484 if (e == element) return true;
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 * argument). 2042 * argument).
2047 * 2043 *
2048 * TODO(ahe): This method is controversial, the team needs to discuss 2044 * TODO(ahe): This method is controversial, the team needs to discuss
2049 * if top-level methods are acceptable and what naming conventions to 2045 * if top-level methods are acceptable and what naming conventions to
2050 * use. 2046 * use.
2051 */ 2047 */
2052 initializerDo(Node node, f(Node node)) { 2048 initializerDo(Node node, f(Node node)) {
2053 SendSet send = node.asSendSet(); 2049 SendSet send = node.asSendSet();
2054 if (send != null) return f(send.arguments.head); 2050 if (send != null) return f(send.arguments.head);
2055 } 2051 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698