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

Unified Diff: pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart

Issue 1047673002: Add SemanticDeclVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Correct long lines Created 5 years, 9 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: pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart
diff --git a/pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart b/pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart
index f1951bf84d1f260704bd6dce82aeaf7dce233316..f2aacc2dc407929f0d56ecf9833d1ca07409b15d 100644
--- a/pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart
+++ b/pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart
@@ -2296,7 +2296,7 @@ class BulkVisitor<R, A> extends SemanticSendVisitor<R, A>
}
/// [SemanticSendVisitor] that visits subnodes.
-class TraversalMixin<R, A> implements SemanticSendVisitor<R, A> {
+class TraversalSendMixin<R, A> implements SemanticSendVisitor<R, A> {
@override
R apply(Node node, A arg) {
throw new UnimplementedError("TraversalMixin.apply unimplemented");
@@ -4142,7 +4142,6 @@ class TraversalMixin<R, A> implements SemanticSendVisitor<R, A> {
return null;
}
- @override
R visitConstConstructorInvoke(
NewExpression node,
ConstructedConstantExpression constant,
@@ -4173,6 +4172,8 @@ class TraversalMixin<R, A> implements SemanticSendVisitor<R, A> {
apply(arguments, arg);
return null;
}
+
+ @override
R visitFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
@@ -4247,51 +4248,473 @@ class TraversalMixin<R, A> implements SemanticSendVisitor<R, A> {
}
}
-/// AST visitor that visits all normal [Send] and [SendSet] nodes using the
-/// [SemanticVisitor].
-class TraversalVisitor<R, A> extends SemanticVisitor<R, A>
- with TraversalMixin<R, A> {
- TraversalVisitor(TreeElements elements) : super(elements);
+/// [SemanticDeclVisitor] that visits subnodes.
+class TraversalDeclMixin<R, A> implements SemanticDeclVisitor<R, A> {
+ @override
+ R apply(Node node, A arg) {
+ throw new UnimplementedError("TraversalMixin.apply unimplemented");
+ }
- SemanticSendVisitor<R, A> get sendVisitor => this;
+ @override
+ applyInitializers(NodeList initializers, A arg) {
+ throw new UnimplementedError(
+ "TraversalMixin.applyInitializers unimplemented");
+ }
- R apply(Node node, A arg) {
- node.accept(this);
+ @override
+ applyParameters(NodeList parameters, A arg) {
+ throw new UnimplementedError(
+ "TraversalMixin.applyParameters unimplemented");
+ }
+
+ @override
+ R visitAbstractMethodDecl(
+ FunctionExpression node,
+ MethodElement method,
+ NodeList parameters,
+ A arg) {
+ applyParameters(parameters, arg);
return null;
}
@override
- internalError(Spannable spannable, String message) {
- throw new SpannableAssertionFailure(spannable, message);
+ R visitClosureDecl(
+ FunctionExpression node,
+ LocalFunctionElement function,
+ NodeList parameters,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ apply(body, arg);
+ return null;
}
@override
- R visitNode(Node node) {
- node.visitChildren(this);
+ R visitFactoryConstructorDecl(
+ FunctionExpression node,
+ ConstructorElement constructor,
+ NodeList parameters,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ apply(body, arg);
return null;
}
- void visitParameters(NodeList parameters) {
+ @override
+ R visitFieldInitializer(
+ SendSet node,
+ FieldElement field,
+ Node initializer,
+ A arg) {
+ apply(initializer, arg);
+ return null;
+ }
+
+ @override
+ R visitGenerativeConstructorDecl(
+ FunctionExpression node,
+ ConstructorElement constructor,
+ NodeList parameters,
+ NodeList initializers,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ applyInitializers(initializers, arg);
+ apply(body, arg);
+ return null;
+ }
+ @override
+ R visitInstanceMethodDecl(
+ FunctionExpression node,
+ MethodElement method,
+ NodeList parameters,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ apply(body, arg);
+ }
+
+ @override
+ R visitLocalFunctionDecl(
+ FunctionExpression node,
+ LocalFunctionElement function,
+ NodeList parameters,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ apply(body, arg);
}
- void visitInitializers(NodeList initializers) {
- // TODO(johnniwinther): Visit subnodes of initializers.
+ @override
+ R visitRedirectingFactoryConstructorDecl(
+ FunctionExpression node,
+ ConstructorElement constructor,
+ NodeList parameters,
+ InterfaceType redirectionType,
+ ConstructorElement redirectionTarget,
+ A arg) {
+ applyParameters(parameters, arg);
+ return null;
+ }
+
+ @override
+ R visitRedirectingGenerativeConstructorDecl(
+ FunctionExpression node,
+ ConstructorElement constructor,
+ NodeList parameters,
+ NodeList initializers,
+ A arg) {
+ applyParameters(parameters, arg);
+ applyInitializers(initializers, arg);
+ return null;
+ }
+
+ @override
+ R visitStaticFunctionDecl(
+ FunctionExpression node,
+ MethodElement function,
+ NodeList parameters,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ apply(body, arg);
+ return null;
}
@override
- R visitFunctionExpression(FunctionExpression node) {
- if (node.parameters != null) {
- visitParameters(node.parameters);
+ R visitSuperConstructorInvoke(
+ Send node,
+ ConstructorElement superConstructor,
+ InterfaceType type,
+ NodeList arguments,
+ Selector selector,
+ A arg) {
+ apply(arguments, arg);
+ return null;
+ }
+
+ @override
+ R visitThisConstructorInvoke(
+ Send node,
+ ConstructorElement thisConstructor,
+ NodeList arguments,
+ Selector selector,
+ A arg) {
+ apply(arguments, arg);
+ return null;
+ }
+
+ @override
+ R visitTopLevelFunctionDecl(
+ FunctionExpression node,
+ MethodElement function,
+ NodeList parameters,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ apply(body, arg);
+ return null;
+ }
+
+ @override
+ R errorUnresolvedFieldInitializer(
+ SendSet node,
+ Element element,
+ Node initializer,
+ A arg) {
+ apply(initializer, arg);
+ return null;
+ }
+
+ @override
+ R errorUnresolvedSuperConstructorInvoke(
+ Send node,
+ Element element,
+ NodeList arguments,
+ Selector selector,
+ A arg) {
+ apply(arguments, arg);
+ return null;
+ }
+
+ @override
+ R errorUnresolvedThisConstructorInvoke(
+ Send node,
+ Element element,
+ NodeList arguments,
+ Selector selector,
+ A arg) {
+ apply(arguments, arg);
+ return null;
+ }
+
+ @override
+ R visitLocalVariableDecl(
+ VariableDefinitions node,
+ Node definition,
+ LocalVariableElement variable,
+ Node initializer,
+ A arg) {
+ if (initializer != null) {
+ apply(initializer, arg);
}
- if (node.initializers != null) {
- visitInitializers(node.initializers);
+ return null;
+ }
+
+ @override
+ R visitOptionalParameterDecl(
+ VariableDefinitions node,
+ Node definition,
+ ParameterElement parameter,
+ ConstantExpression defaultValue,
+ int index,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitParameterDecl(
+ VariableDefinitions node,
+ Node definition,
+ ParameterElement parameter,
+ int index,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitInitializingFormalDecl(
+ VariableDefinitions node,
+ Node definition,
+ InitializingFormalElement initializingFormal,
+ int index,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitLocalConstantDecl(
+ VariableDefinitions node,
+ Node definition,
+ LocalVariableElement variable,
+ ConstantExpression constant,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitNamedInitializingFormalDecl(
+ VariableDefinitions node,
+ Node definition,
+ InitializingFormalElement initializingFormal,
+ ConstantExpression defaultValue,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitNamedParameterDecl(
+ VariableDefinitions node,
+ Node definition,
+ ParameterElement parameter,
+ ConstantExpression defaultValue,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitOptionalInitializingFormalDecl(
+ VariableDefinitions node,
+ Node definition,
+ InitializingFormalElement initializingFormal,
+ ConstantExpression defaultValue,
+ int index,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitInstanceFieldDecl(
+ VariableDefinitions node,
+ Node definition,
+ FieldElement field,
+ Node initializer,
+ A arg) {
+ if (initializer != null) {
+ apply(initializer, arg);
}
- if (node.body != null) {
- apply(node.body, null);
+ return null;
+ }
+
+ @override
+ R visitStaticConstantDecl(
+ VariableDefinitions node,
+ Node definition,
+ FieldElement field,
+ ConstantExpression constant,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitStaticFieldDecl(
+ VariableDefinitions node,
+ Node definition,
+ FieldElement field,
+ Node initializer,
+ A arg) {
+ if (initializer != null) {
+ apply(initializer, arg);
}
return null;
}
+
+ @override
+ R visitTopLevelConstantDecl(
+ VariableDefinitions node,
+ Node definition,
+ FieldElement field,
+ ConstantExpression constant,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitTopLevelFieldDecl(
+ VariableDefinitions node,
+ Node definition,
+ FieldElement field,
+ Node initializer,
+ A arg) {
+ if (initializer != null) {
+ apply(initializer, arg);
+ }
+ return null;
+ }
+
+ @override
+ R visitAbstractGetterDecl(
+ FunctionExpression node,
+ MethodElement getter,
+ A arg) {
+ return null;
+ }
+
+ @override
+ R visitAbstractSetterDecl(
+ FunctionExpression node,
+ MethodElement setter,
+ NodeList parameters,
+ A arg) {
+ applyParameters(parameters, arg);
+ return null;
+ }
+
+ @override
+ R visitInstanceGetterDecl(
+ FunctionExpression node,
+ MethodElement getter,
+ Node body,
+ A arg) {
+ apply(body, arg);
+ return null;
+ }
+
+ @override
+ R visitInstanceSetterDecl(
+ FunctionExpression node,
+ MethodElement setter,
+ NodeList parameters,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ apply(body, arg);
+ return null;
+ }
+
+ @override
+ R visitStaticGetterDecl(
+ FunctionExpression node,
+ MethodElement getter,
+ Node body,
+ A arg) {
+ apply(body, arg);
+ return null;
+ }
+
+ @override
+ R visitStaticSetterDecl(
+ FunctionExpression node,
+ MethodElement setter,
+ NodeList parameters,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ apply(body, arg);
+ return null;
+ }
+
+ @override
+ R visitTopLevelGetterDecl(
+ FunctionExpression node,
+ MethodElement getter,
+ Node body,
+ A arg) {
+ apply(body, arg);
+ return null;
+ }
+
+ @override
+ R visitTopLevelSetterDecl(
+ FunctionExpression node,
+ MethodElement setter,
+ NodeList parameters,
+ Node body,
+ A arg) {
+ applyParameters(parameters, arg);
+ apply(body, arg);
+ return null;
+ }
+}
+
+/// AST visitor that visits all normal [Send] and [SendSet] nodes using the
+/// [SemanticVisitor].
+class TraversalVisitor<R, A> extends SemanticVisitor<R, A>
+ with TraversalSendMixin<R, A>,
+ TraversalDeclMixin<R, A> {
+ TraversalVisitor(TreeElements elements) : super(elements);
+
+ SemanticSendVisitor<R, A> get sendVisitor => this;
+
+ SemanticDeclVisitor<R, A> get declVisitor => this;
+
+ R apply(Node node, A arg) {
+ node.accept(this);
+ return null;
+ }
+
+ @override
+ applyInitializers(NodeList initializers, A arg) {
+ visitInitializers(initializers, arg);
+ }
+
+ @override
+ applyParameters(NodeList parameters, A arg) {
+ visitParameters(parameters, arg);
+ }
+
+ @override
+ internalError(Spannable spannable, String message) {
+ throw new SpannableAssertionFailure(spannable, message);
+ }
+
+ @override
+ R visitNode(Node node) {
+ node.visitChildren(this);
+ return null;
+ }
}
/// Mixin that groups all `visitStaticX` and `visitTopLevelX` method by

Powered by Google App Engine
This is Rietveld 408576698