| 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 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 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 void visitChildren(Visitor visitor) { | 1664 void visitChildren(Visitor visitor) { |
| 1665 expression.accept(visitor); | 1665 expression.accept(visitor); |
| 1666 } | 1666 } |
| 1667 | 1667 |
| 1668 Token getBeginToken() => expression.getBeginToken(); | 1668 Token getBeginToken() => expression.getBeginToken(); |
| 1669 | 1669 |
| 1670 Token getEndToken() => expression.getEndToken(); | 1670 Token getEndToken() => expression.getEndToken(); |
| 1671 } | 1671 } |
| 1672 | 1672 |
| 1673 class CatchBlock extends Node { | 1673 class CatchBlock extends Node { |
| 1674 final TypeAnnotation type; |
| 1674 final NodeList formals; | 1675 final NodeList formals; |
| 1675 final Block block; | 1676 final Block block; |
| 1676 | 1677 |
| 1677 final catchKeyword; | 1678 final Token onKeyword; |
| 1679 final Token catchKeyword; |
| 1678 | 1680 |
| 1679 CatchBlock(this.formals, this.block, this.catchKeyword); | 1681 CatchBlock(this.type, this.formals, this.block, |
| 1682 this.onKeyword, this.catchKeyword); |
| 1680 | 1683 |
| 1681 CatchBlock asCatchBlock() => this; | 1684 CatchBlock asCatchBlock() => this; |
| 1682 | 1685 |
| 1683 accept(Visitor visitor) => visitor.visitCatchBlock(this); | 1686 accept(Visitor visitor) => visitor.visitCatchBlock(this); |
| 1684 | 1687 |
| 1685 Node get exception() { | 1688 Node get exception() { |
| 1686 if (formals.nodes.isEmpty()) return null; | 1689 if (formals.nodes.isEmpty()) return null; |
| 1687 VariableDefinitions declarations = formals.nodes.head; | 1690 VariableDefinitions declarations = formals.nodes.head; |
| 1688 return declarations.definitions.nodes.head; | 1691 return declarations.definitions.nodes.head; |
| 1689 } | 1692 } |
| 1690 | 1693 |
| 1691 Node get trace() { | 1694 Node get trace() { |
| 1692 if (formals.nodes.isEmpty()) return null; | 1695 if (formals.nodes.isEmpty()) return null; |
| 1693 Link<Node> declarations = formals.nodes.tail; | 1696 Link<Node> declarations = formals.nodes.tail; |
| 1694 if (declarations.isEmpty()) return null; | 1697 if (declarations.isEmpty()) return null; |
| 1695 VariableDefinitions head = declarations.head; | 1698 VariableDefinitions head = declarations.head; |
| 1696 return head.definitions.nodes.head; | 1699 return head.definitions.nodes.head; |
| 1697 } | 1700 } |
| 1698 | 1701 |
| 1699 visitChildren(Visitor visitor) { | 1702 visitChildren(Visitor visitor) { |
| 1703 if (type != null) type.accept(visitor); |
| 1700 formals.accept(visitor); | 1704 formals.accept(visitor); |
| 1701 block.accept(visitor); | 1705 block.accept(visitor); |
| 1702 } | 1706 } |
| 1703 | 1707 |
| 1704 Token getBeginToken() => catchKeyword; | 1708 Token getBeginToken() => onKeyword != null ? onKeyword : catchKeyword; |
| 1705 | 1709 |
| 1706 Token getEndToken() => block.getEndToken(); | 1710 Token getEndToken() => block.getEndToken(); |
| 1707 } | 1711 } |
| 1708 | 1712 |
| 1709 class Initializers { | 1713 class Initializers { |
| 1710 static bool isSuperConstructorCall(Send node) { | 1714 static bool isSuperConstructorCall(Send node) { |
| 1711 return (node.receiver === null && | 1715 return (node.receiver === null && |
| 1712 node.selector.asIdentifier() !== null && | 1716 node.selector.asIdentifier() !== null && |
| 1713 node.selector.asIdentifier().isSuper()) || | 1717 node.selector.asIdentifier().isSuper()) || |
| 1714 (node.receiver !== null && | 1718 (node.receiver !== null && |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1749 * argument). | 1753 * argument). |
| 1750 * | 1754 * |
| 1751 * TODO(ahe): This method is controversial, the team needs to discuss | 1755 * TODO(ahe): This method is controversial, the team needs to discuss |
| 1752 * if top-level methods are acceptable and what naming conventions to | 1756 * if top-level methods are acceptable and what naming conventions to |
| 1753 * use. | 1757 * use. |
| 1754 */ | 1758 */ |
| 1755 initializerDo(Node node, f(Node node)) { | 1759 initializerDo(Node node, f(Node node)) { |
| 1756 SendSet send = node.asSendSet(); | 1760 SendSet send = node.asSendSet(); |
| 1757 if (send !== null) return f(send.arguments.head); | 1761 if (send !== null) return f(send.arguments.head); |
| 1758 } | 1762 } |
| OLD | NEW |