Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 part of tree; | 5 part of tree; |
| 6 | 6 |
| 7 abstract class Visitor<R> { | 7 abstract class Visitor<R> { |
| 8 const Visitor(); | 8 const Visitor(); |
| 9 | 9 |
| 10 R visitNode(Node node); | 10 R visitNode(Node node); |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 while (!link.tail.isEmpty) link = link.tail; | 548 while (!link.tail.isEmpty) link = link.tail; |
| 549 if (link.head.getEndToken() != null) return link.head.getEndToken(); | 549 if (link.head.getEndToken() != null) return link.head.getEndToken(); |
| 550 if (link.head.getBeginToken() != null) return link.head.getBeginToken(); | 550 if (link.head.getBeginToken() != null) return link.head.getBeginToken(); |
| 551 } | 551 } |
| 552 return beginToken; | 552 return beginToken; |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 | 555 |
| 556 class Block extends Statement { | 556 class Block extends Statement { |
| 557 final NodeList statements; | 557 final NodeList statements; |
| 558 final Link<VariableDefinitions> declarations; | |
|
ahe
2013/09/26 07:48:07
I'm not sure this is a good place for this informa
ngeoffray
2013/09/26 07:48:38
This seems off. Can't you handle during resolution
karlklose
2013/09/27 07:07:43
We do not really have a place to store it in the m
| |
| 558 | 559 |
| 559 Block(this.statements); | 560 Block(this.statements, this.declarations); |
| 560 | 561 |
| 561 Block asBlock() => this; | 562 Block asBlock() => this; |
| 562 | 563 |
| 563 accept(Visitor visitor) => visitor.visitBlock(this); | 564 accept(Visitor visitor) => visitor.visitBlock(this); |
| 564 | 565 |
| 565 visitChildren(Visitor visitor) { | 566 visitChildren(Visitor visitor) { |
| 566 if (statements != null) statements.accept(visitor); | 567 if (statements != null) statements.accept(visitor); |
| 567 } | 568 } |
| 568 | 569 |
| 569 Token getBeginToken() => statements.getBeginToken(); | 570 Token getBeginToken() => statements.getBeginToken(); |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1559 | 1560 |
| 1560 class SwitchCase extends Node { | 1561 class SwitchCase extends Node { |
| 1561 // The labels and case patterns are collected in [labelsAndCases]. | 1562 // The labels and case patterns are collected in [labelsAndCases]. |
| 1562 // The default keyword, if present, is collected in [defaultKeyword]. | 1563 // The default keyword, if present, is collected in [defaultKeyword]. |
| 1563 // Any actual switch case must have at least one 'case' or 'default' | 1564 // Any actual switch case must have at least one 'case' or 'default' |
| 1564 // clause. | 1565 // clause. |
| 1565 // Notice: The labels and cases can occur interleaved in the source. | 1566 // Notice: The labels and cases can occur interleaved in the source. |
| 1566 // They are separated here, since the order is irrelevant to the meaning | 1567 // They are separated here, since the order is irrelevant to the meaning |
| 1567 // of the switch. | 1568 // of the switch. |
| 1568 | 1569 |
| 1570 final Link<VariableDefinitions> declarations; | |
|
ahe
2013/09/26 07:48:07
This doesn't feel like a part of a switch case.
karlklose
2013/09/27 07:07:43
They are part of the statements, that's why I adde
| |
| 1571 | |
| 1569 /** List of [Label] and [CaseMatch] nodes. */ | 1572 /** List of [Label] and [CaseMatch] nodes. */ |
| 1570 final NodeList labelsAndCases; | 1573 final NodeList labelsAndCases; |
| 1571 /** A "default" keyword token, if applicable. */ | 1574 /** A "default" keyword token, if applicable. */ |
| 1572 final Token defaultKeyword; | 1575 final Token defaultKeyword; |
| 1573 /** List of statements, the body of the case. */ | 1576 /** List of statements, the body of the case. */ |
| 1574 final NodeList statements; | 1577 final NodeList statements; |
| 1575 | 1578 |
| 1576 final Token startToken; | 1579 final Token startToken; |
| 1577 | 1580 |
| 1578 SwitchCase(this.labelsAndCases, this.defaultKeyword, | 1581 SwitchCase(this.labelsAndCases, this.defaultKeyword, this.statements, |
| 1579 this.statements, this.startToken); | 1582 this.startToken, this.declarations); |
|
ngeoffray
2013/09/26 07:48:38
indentation.
| |
| 1580 | 1583 |
| 1581 SwitchCase asSwitchCase() => this; | 1584 SwitchCase asSwitchCase() => this; |
| 1582 | 1585 |
| 1583 bool get isDefaultCase => defaultKeyword != null; | 1586 bool get isDefaultCase => defaultKeyword != null; |
| 1584 | 1587 |
| 1585 bool isValidContinueTarget() => true; | 1588 bool isValidContinueTarget() => true; |
| 1586 | 1589 |
| 1587 accept(Visitor visitor) => visitor.visitSwitchCase(this); | 1590 accept(Visitor visitor) => visitor.visitSwitchCase(this); |
| 1588 | 1591 |
| 1589 visitChildren(Visitor visitor) { | 1592 visitChildren(Visitor visitor) { |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2077 * argument). | 2080 * argument). |
| 2078 * | 2081 * |
| 2079 * TODO(ahe): This method is controversial, the team needs to discuss | 2082 * TODO(ahe): This method is controversial, the team needs to discuss |
| 2080 * if top-level methods are acceptable and what naming conventions to | 2083 * if top-level methods are acceptable and what naming conventions to |
| 2081 * use. | 2084 * use. |
| 2082 */ | 2085 */ |
| 2083 initializerDo(Node node, f(Node node)) { | 2086 initializerDo(Node node, f(Node node)) { |
| 2084 SendSet send = node.asSendSet(); | 2087 SendSet send = node.asSendSet(); |
| 2085 if (send != null) return f(send.arguments.head); | 2088 if (send != null) return f(send.arguments.head); |
| 2086 } | 2089 } |
| OLD | NEW |