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

Side by Side Diff: frog/leg/tree/nodes.dart

Issue 9863037: Generate prettier loops. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adressed review comments. A few fixes. Created 8 years, 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 interface Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitBreakStatement(BreakStatement node); 7 R visitBreakStatement(BreakStatement node);
8 R visitCatchBlock(CatchBlock node); 8 R visitCatchBlock(CatchBlock node);
9 R visitClassNode(ClassNode node); 9 R visitClassNode(ClassNode node);
10 R visitConditional(Conditional node); 10 R visitConditional(Conditional node);
11 R visitContinueStatement(ContinueStatement node); 11 R visitContinueStatement(ContinueStatement node);
12 R visitDoWhile(DoWhile node); 12 R visitDoWhile(DoWhile node);
13 R visitEmptyStatement(EmptyStatement node); 13 R visitEmptyStatement(EmptyStatement node);
14 R visitExpressionStatement(ExpressionStatement node); 14 R visitExpressionStatement(ExpressionStatement node);
15 R visitFor(For node); 15 R visitFor(For node);
16 R visitForInStatement(ForInStatement node); 16 R visitForIn(ForIn node);
17 R visitFunctionDeclaration(FunctionDeclaration node); 17 R visitFunctionDeclaration(FunctionDeclaration node);
18 R visitFunctionExpression(FunctionExpression node); 18 R visitFunctionExpression(FunctionExpression node);
19 R visitIdentifier(Identifier node); 19 R visitIdentifier(Identifier node);
20 R visitIf(If node); 20 R visitIf(If node);
21 R visitLabeledStatement(LabeledStatement node); 21 R visitLabeledStatement(LabeledStatement node);
22 R visitLiteralBool(LiteralBool node); 22 R visitLiteralBool(LiteralBool node);
23 R visitLiteralDouble(LiteralDouble node); 23 R visitLiteralDouble(LiteralDouble node);
24 R visitLiteralInt(LiteralInt node); 24 R visitLiteralInt(LiteralInt node);
25 R visitLiteralList(LiteralList node); 25 R visitLiteralList(LiteralList node);
26 R visitLiteralMap(LiteralMap node); 26 R visitLiteralMap(LiteralMap node);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 BreakStatement asBreakStatement() => null; 110 BreakStatement asBreakStatement() => null;
111 CatchBlock asCatchBlock() => null; 111 CatchBlock asCatchBlock() => null;
112 ClassNode asClassNode() => null; 112 ClassNode asClassNode() => null;
113 Conditional asConditional() => null; 113 Conditional asConditional() => null;
114 ContinueStatement asContinueStatement() => null; 114 ContinueStatement asContinueStatement() => null;
115 DoWhile asDoWhile() => null; 115 DoWhile asDoWhile() => null;
116 EmptyStatement asEmptyStatement() => null; 116 EmptyStatement asEmptyStatement() => null;
117 Expression asExpression() => null; 117 Expression asExpression() => null;
118 ExpressionStatement asExpressionStatement() => null; 118 ExpressionStatement asExpressionStatement() => null;
119 For asFor() => null; 119 For asFor() => null;
120 ForInStatement asForInStatement() => null; 120 ForIn asForIn() => null;
121 FunctionDeclaration asFunctionDeclaration() => null; 121 FunctionDeclaration asFunctionDeclaration() => null;
122 FunctionExpression asFunctionExpression() => null; 122 FunctionExpression asFunctionExpression() => null;
123 Identifier asIdentifier() => null; 123 Identifier asIdentifier() => null;
124 If asIf() => null; 124 If asIf() => null;
125 LabeledStatement asLabeledStatement() => null; 125 LabeledStatement asLabeledStatement() => null;
126 LiteralBool asLiteralBool() => null; 126 LiteralBool asLiteralBool() => null;
127 LiteralDouble asLiteralDouble() => null; 127 LiteralDouble asLiteralDouble() => null;
128 LiteralInt asLiteralInt() => null; 128 LiteralInt asLiteralInt() => null;
129 LiteralList asLiteralList() => null; 129 LiteralList asLiteralList() => null;
130 LiteralMap asLiteralMap() => null; 130 LiteralMap asLiteralMap() => null;
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 1402
1403 class ContinueStatement extends GotoStatement { 1403 class ContinueStatement extends GotoStatement {
1404 ContinueStatement(Identifier target, Token keywordToken, Token semicolonToken) 1404 ContinueStatement(Identifier target, Token keywordToken, Token semicolonToken)
1405 : super(target, keywordToken, semicolonToken); 1405 : super(target, keywordToken, semicolonToken);
1406 1406
1407 ContinueStatement asContinueStatement() => this; 1407 ContinueStatement asContinueStatement() => this;
1408 1408
1409 accept(Visitor visitor) => visitor.visitContinueStatement(this); 1409 accept(Visitor visitor) => visitor.visitContinueStatement(this);
1410 } 1410 }
1411 1411
1412 class ForInStatement extends Loop { 1412 class ForIn extends Loop {
1413 final Node declaredIdentifier; 1413 final Node declaredIdentifier;
1414 final Expression expression; 1414 final Expression expression;
1415 1415
1416 final Token forToken; 1416 final Token forToken;
1417 final Token inToken; 1417 final Token inToken;
1418 1418
1419 ForInStatement(this.declaredIdentifier, this.expression, 1419 ForIn(this.declaredIdentifier, this.expression,
1420 Statement body, this.forToken, this.inToken) : super(body); 1420 Statement body, this.forToken, this.inToken) : super(body);
1421 1421
1422 Expression get condition() => null; 1422 Expression get condition() => null;
1423 1423
1424 ForInStatement asForInStatement() => this; 1424 ForIn asForIn() => this;
1425 1425
1426 accept(Visitor visitor) => visitor.visitForInStatement(this); 1426 accept(Visitor visitor) => visitor.visitForIn(this);
1427 1427
1428 visitChildren(Visitor visitor) { 1428 visitChildren(Visitor visitor) {
1429 declaredIdentifier.accept(visitor); 1429 declaredIdentifier.accept(visitor);
1430 expression.accept(visitor); 1430 expression.accept(visitor);
1431 body.accept(visitor); 1431 body.accept(visitor);
1432 } 1432 }
1433 1433
1434 Token getBeginToken() => forToken; 1434 Token getBeginToken() => forToken;
1435 1435
1436 Token getEndToken() => body.getEndToken(); 1436 Token getEndToken() => body.getEndToken();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 * argument). 1635 * argument).
1636 * 1636 *
1637 * TODO(ahe): This method is controversial, the team needs to discuss 1637 * TODO(ahe): This method is controversial, the team needs to discuss
1638 * if top-level methods are acceptable and what naming conventions to 1638 * if top-level methods are acceptable and what naming conventions to
1639 * use. 1639 * use.
1640 */ 1640 */
1641 initializerDo(Node node, f(Node node)) { 1641 initializerDo(Node node, f(Node node)) {
1642 SendSet send = node.asSendSet(); 1642 SendSet send = node.asSendSet();
1643 if (send !== null) return f(send.arguments.head); 1643 if (send !== null) return f(send.arguments.head);
1644 } 1644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698