Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/tree/nodes.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/tree/nodes.dart b/sdk/lib/_internal/compiler/implementation/tree/nodes.dart |
| index 99d3a88876f3758fd7586a1f1e29827a5afd3189..ae8d9b43d6547d92d330325810f60e35cdc27cbf 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/tree/nodes.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/tree/nodes.dart |
| @@ -466,6 +466,54 @@ class NodeList extends Node implements Iterable<Node> { |
| } |
| return beginToken; |
| } |
| + |
| + // ------------------- Iterable methods ------------------------------------- |
| + // |
| + // TODO(floitsch): these functions should be pulled in through a mixin |
| + // mechanism. |
| + Collection mappedBy(f(Node element)) { |
| + List result = new List(); |
|
sra1
2012/11/15 01:02:18
new List() -> []
floitsch
2012/11/15 01:27:27
Done.
|
| + for (Node element in this) result.add(f(element)); |
| + return result; |
| + } |
| + |
| + Collection<Node> where(bool f(Node element)) { |
| + List result = new List<Node>(); |
| + for (Node element in this) if (f(element)) result.add(element); |
| + return result; |
| + } |
| + |
| + bool contains(Node element) { |
| + for (Node e in this) { |
| + if (e == element) return true; |
| + } |
| + return false; |
| + } |
| + |
| + void forEach(void f(Node element)) { |
| + for (Node element in this) f(element); |
| + } |
| + |
| + dynamic reduce(var initialValue, |
| + dynamic combine(var previousValue, Node element)) { |
| + var value = initialValue; |
| + for (Node element in this) value = combine(value, element); |
| + return value; |
| + } |
| + |
| + bool every(bool f(Node element)) { |
| + for (Node element in this) { |
| + if (!f(element)) return false; |
| + } |
| + return true; |
| + } |
| + |
| + bool some(bool f(Node element)) { |
| + for (Node element in this) { |
| + if (f(element)) return true; |
| + } |
| + return false; |
| + } |
| } |
| class Block extends Statement { |