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

Side by Side Diff: dart/lib/compiler/implementation/tree/visitors.dart

Issue 10982089: Remove AbstractVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class AbstractVisitor<R> implements Visitor<R> {
6 const AbstractVisitor();
7
8 abstract R visitNode(Node node);
9
10 R visitBlock(Block node) => visitStatement(node);
11 R visitBreakStatement(BreakStatement node) => visitGotoStatement(node);
12 R visitCascade(Cascade node) => visitExpression(node);
13 R visitCascadeReceiver(CascadeReceiver node) => visitExpression(node);
14 R visitCaseMatch(CaseMatch node) => visitNode(node);
15 R visitCatchBlock(CatchBlock node) => visitNode(node);
16 R visitClassNode(ClassNode node) => visitNode(node);
17 R visitConditional(Conditional node) => visitExpression(node);
18 R visitContinueStatement(ContinueStatement node) => visitGotoStatement(node);
19 R visitDoWhile(DoWhile node) => visitLoop(node);
20 R visitEmptyStatement(EmptyStatement node) => visitStatement(node);
21 R visitExpression(Expression node) => visitNode(node);
22 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node);
23 R visitFor(For node) => visitLoop(node);
24 R visitForIn(ForIn node) => visitLoop(node);
25 R visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node);
26 R visitFunctionExpression(FunctionExpression node) => visitExpression(node);
27 R visitGotoStatement(GotoStatement node) => visitStatement(node);
28 R visitIdentifier(Identifier node) => visitExpression(node);
29 R visitIf(If node) => visitStatement(node);
30 R visitLabel(Label node) => visitNode(node);
31 R visitLabeledStatement(LabeledStatement node) => visitStatement(node);
32 R visitLiteral(Literal node) => visitExpression(node);
33 R visitLiteralBool(LiteralBool node) => visitLiteral(node);
34 R visitLiteralDouble(LiteralDouble node) => visitLiteral(node);
35 R visitLiteralInt(LiteralInt node) => visitLiteral(node);
36 R visitLiteralList(LiteralList node) => visitExpression(node);
37 R visitLiteralMap(LiteralMap node) => visitExpression(node);
38 R visitLiteralMapEntry(LiteralMapEntry node) => visitNode(node);
39 R visitLiteralNull(LiteralNull node) => visitLiteral(node);
40 R visitLiteralString(LiteralString node) => visitStringNode(node);
41 R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node);
42 R visitLoop(Loop node) => visitStatement(node);
43 R visitModifiers(Modifiers node) => visitNode(node);
44 R visitNamedArgument(NamedArgument node) => visitExpression(node);
45 R visitNewExpression(NewExpression node) => visitExpression(node);
46 R visitNodeList(NodeList node) => visitNode(node);
47 R visitOperator(Operator node) => visitIdentifier(node);
48 R visitParenthesizedExpression(ParenthesizedExpression node) {
49 return visitExpression(node);
50 }
51 R visitPostfix(Postfix node) => visitNodeList(node);
52 R visitPrefix(Prefix node) => visitNodeList(node);
53 R visitReturn(Return node) => visitStatement(node);
54 R visitScriptTag(ScriptTag node) => visitNode(node);
55 R visitSend(Send node) => visitExpression(node);
56 R visitSendSet(SendSet node) => visitSend(node);
57 R visitStatement(Statement node) => visitNode(node);
58 R visitStringNode(StringNode node) => visitExpression(node);
59 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node);
60 R visitStringInterpolationPart(StringInterpolationPart node) {
61 return visitNode(node);
62 }
63 R visitSwitchCase(SwitchCase node) => visitNode(node);
64 R visitSwitchStatement(SwitchStatement node) => visitStatement(node);
65 R visitThrow(Throw node) => visitStatement(node);
66 R visitTryStatement(TryStatement node) => visitStatement(node);
67 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node);
68 R visitTypedef(Typedef node) => visitNode(node);
69 R visitTypeVariable(TypeVariable node) => visitNode(node);
70 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node);
71 R visitWhile(While node) => visitLoop(node);
72 }
73
74 /** 5 /**
75 * This visitor takes another visitor and applies it to every 6 * This visitor takes another visitor and applies it to every
76 * node in the tree. There is currently no way to control the 7 * node in the tree. There is currently no way to control the
77 * traversal. 8 * traversal.
78 */ 9 */
79 class TraversingVisitor extends AbstractVisitor { 10 class TraversingVisitor extends Visitor {
80 final Visitor visitor; 11 final Visitor visitor;
81 12
82 TraversingVisitor(Visitor this.visitor); 13 TraversingVisitor(Visitor this.visitor);
83 14
84 visitNode(Node node) { 15 visitNode(Node node) {
85 node.accept(visitor); 16 node.accept(visitor);
86 node.visitChildren(this); 17 node.visitChildren(this);
87 } 18 }
88 } 19 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/tree/prettyprint.dart ('k') | dart/lib/compiler/implementation/tree_validator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698