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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
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 8f463f828bf1d9f94430f081cce4f9c7ef7880a6..8099a56c4306542c52c68f827fc6e3056918bf13 100644
--- a/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
+++ b/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
@@ -288,7 +288,7 @@ class Send extends Expression {
if (argumentsNode != null) argumentsNode.accept(visitor);
}
- int argumentCount() => (argumentsNode == null) ? -1 : argumentsNode.length();
+ int argumentCount() => (argumentsNode == null) ? -1 : argumentsNode.length;
bool get isSuperCall {
return receiver != null &&
@@ -419,14 +419,14 @@ class NodeList extends Node implements Iterable<Node> {
NodeList([this.beginToken, this.nodes, this.endToken, this.delimiter]);
- Iterator<Node> iterator() => nodes.iterator();
+ Iterator<Node> get iterator => nodes.iterator;
NodeList.singleton(Node node) : this(null, const Link<Node>().prepend(node));
NodeList.empty() : this(null, const Link<Node>());
NodeList asNodeList() => this;
- int length() {
+ int get length {
int result = 0;
for (Link<Node> cursor = nodes; !cursor.isEmpty; cursor = cursor.tail) {
result++;
@@ -469,6 +469,97 @@ class NodeList extends Node implements Iterable<Node> {
}
return beginToken;
}
+
+ // ------------------- Iterable methods -------------------------------------
+ //
+ // TODO(floitsch): these functions should be pulled in through a mixin
+ // mechanism.
+ Iterable mappedBy(f(Node element)) => new MappedIterable(this, f);
+
+ Iterable<Node> where(bool f(Node element))
+ => new WhereIterable<Node>(this, f);
+
+ 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);
+ }
+
+ String join([String separator]) => Collections.join(this, separator);
+
+ 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 any(bool f(Node element)) {
+ for (Node element in this) {
+ if (f(element)) return true;
+ }
+ return false;
+ }
+
+ List<Node> toList() => new List<Node>.from(this);
+
+ Set<Node> toSet() => new Set<Node>.from(this);
+
+ Iterable<Node> take(int n) => new TakeIterable<Node>(this, n);
+
+ Iterable<Node> takeWhile(bool test(Node value)) {
+ return new TakeWhileIterable<Node>(this, test);
+ }
+
+ Iterable<Node> skip(int n) => new SkipIterable<Node>(this, n);
+
+ Iterable<Node> skipWhile(bool test(Node value)) {
+ return new SkipWhileIterable<Node>(this, test);
+ }
+
+ Node get first {
+ return Collections.first(this);
+ }
+
+ Node get last {
+ return Collections.last(this);
+ }
+
+ Node get single {
+ return Collections.single(this);
+ }
+
+ Node min([int compare(Node a, Node b)]) => Collections.min(this, compare);
+
+ Node max([int compare(Node a, Node b)]) => Collections.max(this, compare);
+
+ Node firstMatching(bool test(Node value), {Node orElse()}) {
+ return Collections.firstMatching(this, test, orElse);
+ }
+
+ Node lastMatching(bool test(Node value), {Node orElse()}) {
+ return Collections.lastMatching(this, test, orElse);
+ }
+
+ Node singleMatching(bool test(Node value)) {
+ return Collections.singleMatching(this, test);
+ }
+
+ Node elementAt(int index) {
+ return Collections.elementAt(this, index);
+ }
}
class Block extends Statement {
@@ -686,7 +777,7 @@ class LiteralInt extends Literal<int> {
try {
Token valueToken = token;
if (identical(valueToken.kind, PLUS_TOKEN)) valueToken = valueToken.next;
- return parseInt(valueToken.value.slowToString());
+ return int.parse(valueToken.value.slowToString());
} on FormatException catch (ex) {
(this.handler)(token, ex);
}
@@ -705,7 +796,7 @@ class LiteralDouble extends Literal<double> {
try {
Token valueToken = token;
if (identical(valueToken.kind, PLUS_TOKEN)) valueToken = valueToken.next;
- return parseDouble(valueToken.value.slowToString());
+ return double.parse(valueToken.value.slowToString());
} on FormatException catch (ex) {
(this.handler)(token, ex);
}

Powered by Google App Engine
This is Rietveld 408576698