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

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

Issue 10389113: Make a single labeled statement hold all its labels. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 visitCascade(Cascade node); 8 R visitCascade(Cascade node);
9 R visitCascadeReceiver(CascadeReceiver node); 9 R visitCascadeReceiver(CascadeReceiver node);
10 R visitCaseMatch(CaseMatch node); 10 R visitCaseMatch(CaseMatch node);
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 1467
1468 void visitChildren(Visitor visitor) { 1468 void visitChildren(Visitor visitor) {
1469 identifier.accept(visitor); 1469 identifier.accept(visitor);
1470 } 1470 }
1471 1471
1472 Token getBeginToken() => identifier.token; 1472 Token getBeginToken() => identifier.token;
1473 Token getEndToken() => colonToken; 1473 Token getEndToken() => colonToken;
1474 } 1474 }
1475 1475
1476 class LabeledStatement extends Statement { 1476 class LabeledStatement extends Statement {
1477 final Label label; 1477 final NodeList labels;
1478 final Statement statement; 1478 final Statement statement;
1479 1479
1480 LabeledStatement(this.label, this.statement); 1480 LabeledStatement(this.labels, this.statement);
1481 1481
1482 LabeledStatement asLabeledStatement() => this; 1482 LabeledStatement asLabeledStatement() => this;
1483 1483
1484 accept(Visitor visitor) => visitor.visitLabeledStatement(this); 1484 accept(Visitor visitor) => visitor.visitLabeledStatement(this);
1485 1485
1486 visitChildren(Visitor visitor) { 1486 visitChildren(Visitor visitor) {
1487 label.accept(visitor); 1487 labels.accept(visitor);
1488 statement.accept(visitor); 1488 statement.accept(visitor);
1489 } 1489 }
1490 1490
1491 Token getBeginToken() => label.getBeginToken(); 1491 Token getBeginToken() => labels.getBeginToken();
1492 1492
1493 Token getEndToken() => statement.getEndToken(); 1493 Token getEndToken() => statement.getEndToken();
1494 1494
1495 bool isValidContinueTarget() => statement.isValidContinueTarget(); 1495 bool isValidContinueTarget() => statement.isValidContinueTarget();
1496 1496
1497 Node getBody() { 1497 Node getBody() => statement;
1498 if (statement is! LabeledStatement) return statement;
1499 LabeledStatement labeled = statement;
1500 return labeled.getBody();
1501 }
1502 } 1498 }
1503 1499
1504 class ScriptTag extends Node { 1500 class ScriptTag extends Node {
1505 final Identifier tag; 1501 final Identifier tag;
1506 final StringNode argument; 1502 final StringNode argument;
1507 final Identifier prefixIdentifier; 1503 final Identifier prefixIdentifier;
1508 final StringNode prefix; 1504 final StringNode prefix;
1509 1505
1510 final Token beginToken; 1506 final Token beginToken;
1511 final Token endToken; 1507 final Token endToken;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 * argument). 1700 * argument).
1705 * 1701 *
1706 * TODO(ahe): This method is controversial, the team needs to discuss 1702 * TODO(ahe): This method is controversial, the team needs to discuss
1707 * if top-level methods are acceptable and what naming conventions to 1703 * if top-level methods are acceptable and what naming conventions to
1708 * use. 1704 * use.
1709 */ 1705 */
1710 initializerDo(Node node, f(Node node)) { 1706 initializerDo(Node node, f(Node node)) {
1711 SendSet send = node.asSendSet(); 1707 SendSet send = node.asSendSet();
1712 if (send !== null) return f(send.arguments.head); 1708 if (send !== null) return f(send.arguments.head);
1713 } 1709 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698