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

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

Issue 422483002: Mix in [TreeElementMixin] only on nodes that need it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 4 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 6b94a2692275635ffed76c7867689d86cf5bc3af..c00d7b19df7276d2b4ba3e2eacf0f16185d7d27d 100644
--- a/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
+++ b/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
@@ -65,6 +65,9 @@ abstract class Visitor<R> {
R visitPartOf(PartOf node) => visitNode(node);
R visitPostfix(Postfix node) => visitNodeList(node);
R visitPrefix(Prefix node) => visitNodeList(node);
+ R visitRedirectingFactoryBody(RedirectingFactoryBody node) {
+ return visitStatement(node);
+ }
R visitRethrow(Rethrow node) => visitStatement(node);
R visitReturn(Return node) => visitStatement(node);
R visitSend(Send node) => visitExpression(node);
@@ -110,7 +113,7 @@ Token firstBeginToken(Node first, Node second) {
* token stream. These references are stored in fields ending with
* "Token".
*/
-abstract class Node extends TreeElementMixin implements Spannable {
+abstract class Node extends NullTreeElementMixin implements Spannable {
final int hashCode;
static int _HASH_COUNTER = 0;
@@ -185,6 +188,7 @@ abstract class Node extends TreeElementMixin implements Spannable {
ParenthesizedExpression asParenthesizedExpression() => null;
Part asPart() => null;
PartOf asPartOf() => null;
+ RedirectingFactoryBody asRedirectingFactoryBody() => null;
Rethrow asRethrow() => null;
Return asReturn() => null;
Send asSend() => null;
@@ -338,7 +342,7 @@ class ErrorExpression extends LiteralNull {
* property access, assignment, operators, and method calls with this
* one node.
*/
-class Send extends Expression {
+class Send extends Expression with StoredTreeElementMixin {
final Node receiver;
final Node selector;
final NodeList argumentsNode;
@@ -701,7 +705,7 @@ class FunctionDeclaration extends Statement {
Token getEndToken() => function.getEndToken();
}
-class FunctionExpression extends Expression {
+class FunctionExpression extends Expression with StoredTreeElementMixin {
final Node name;
/**
@@ -728,8 +732,7 @@ class FunctionExpression extends Expression {
accept(Visitor visitor) => visitor.visitFunctionExpression(this);
bool get isRedirectingFactory {
- return body != null && body.asReturn() != null &&
- body.asReturn().isRedirectingFactoryBody;
+ return body != null && body.asRedirectingFactoryBody() != null;
}
visitChildren(Visitor visitor) {
@@ -975,7 +978,7 @@ class LiteralSymbol extends Expression {
}
}
-class Identifier extends Expression {
+class Identifier extends Expression with StoredTreeElementMixin {
final Token token;
String get source => token.value;
@@ -1022,8 +1025,6 @@ class Return extends Statement {
bool get hasExpression => expression != null;
- bool get isRedirectingFactoryBody => beginToken.stringValue == '=';
-
accept(Visitor visitor) => visitor.visitReturn(this);
visitChildren(Visitor visitor) {
@@ -1038,6 +1039,27 @@ class Return extends Statement {
}
}
+class RedirectingFactoryBody extends Statement with StoredTreeElementMixin {
+ final Node constructorReference;
+ final Token beginToken;
+ final Token endToken;
+
+ RedirectingFactoryBody(this.beginToken, this.endToken,
+ this.constructorReference);
+
+ RedirectingFactoryBody asRedirectingFactoryBody() => this;
+
+ accept(Visitor visitor) => visitor.visitRedirectingFactoryBody(this);
+
+ visitChildren(Visitor visitor) {
+ constructorReference.accept(visitor);
+ }
+
+ Token getBeginToken() => beginToken;
+
+ Token getEndToken() => endToken;
+}
+
class ExpressionStatement extends Statement {
final Expression expression;
final Token endToken;
@@ -1665,7 +1687,7 @@ class ContinueStatement extends GotoStatement {
accept(Visitor visitor) => visitor.visitContinueStatement(this);
}
-class ForIn extends Loop {
+class ForIn extends Loop with StoredTreeElementMixin {
final Node declaredIdentifier;
final Expression expression;

Powered by Google App Engine
This is Rietveld 408576698