| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 R visitOperator(Operator node) => visitIdentifier(node); | 59 R visitOperator(Operator node) => visitIdentifier(node); |
| 60 R visitParenthesizedExpression(ParenthesizedExpression node) { | 60 R visitParenthesizedExpression(ParenthesizedExpression node) { |
| 61 return visitExpression(node); | 61 return visitExpression(node); |
| 62 } | 62 } |
| 63 R visitPart(Part node) => visitLibraryTag(node); | 63 R visitPart(Part node) => visitLibraryTag(node); |
| 64 R visitPartOf(PartOf node) => visitNode(node); | 64 R visitPartOf(PartOf node) => visitNode(node); |
| 65 R visitPostfix(Postfix node) => visitNodeList(node); | 65 R visitPostfix(Postfix node) => visitNodeList(node); |
| 66 R visitPrefix(Prefix node) => visitNodeList(node); | 66 R visitPrefix(Prefix node) => visitNodeList(node); |
| 67 R visitRethrow(Rethrow node) => visitStatement(node); | 67 R visitRethrow(Rethrow node) => visitStatement(node); |
| 68 R visitReturn(Return node) => visitStatement(node); | 68 R visitReturn(Return node) => visitStatement(node); |
| 69 R visitScriptTag(ScriptTag node) => visitNode(node); | |
| 70 R visitSend(Send node) => visitExpression(node); | 69 R visitSend(Send node) => visitExpression(node); |
| 71 R visitSendSet(SendSet node) => visitSend(node); | 70 R visitSendSet(SendSet node) => visitSend(node); |
| 72 R visitStatement(Statement node) => visitNode(node); | 71 R visitStatement(Statement node) => visitNode(node); |
| 73 R visitStringNode(StringNode node) => visitExpression(node); | 72 R visitStringNode(StringNode node) => visitExpression(node); |
| 74 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); | 73 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); |
| 75 R visitStringInterpolationPart(StringInterpolationPart node) { | 74 R visitStringInterpolationPart(StringInterpolationPart node) { |
| 76 return visitNode(node); | 75 return visitNode(node); |
| 77 } | 76 } |
| 78 R visitSwitchCase(SwitchCase node) => visitNode(node); | 77 R visitSwitchCase(SwitchCase node) => visitNode(node); |
| 79 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); | 78 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 Modifiers asModifiers() => null; | 173 Modifiers asModifiers() => null; |
| 175 NamedArgument asNamedArgument() => null; | 174 NamedArgument asNamedArgument() => null; |
| 176 NamedMixinApplication asNamedMixinApplication() => null; | 175 NamedMixinApplication asNamedMixinApplication() => null; |
| 177 NodeList asNodeList() => null; | 176 NodeList asNodeList() => null; |
| 178 Operator asOperator() => null; | 177 Operator asOperator() => null; |
| 179 ParenthesizedExpression asParenthesizedExpression() => null; | 178 ParenthesizedExpression asParenthesizedExpression() => null; |
| 180 Part asPart() => null; | 179 Part asPart() => null; |
| 181 PartOf asPartOf() => null; | 180 PartOf asPartOf() => null; |
| 182 Rethrow asRethrow() => null; | 181 Rethrow asRethrow() => null; |
| 183 Return asReturn() => null; | 182 Return asReturn() => null; |
| 184 ScriptTag asScriptTag() => null; | |
| 185 Send asSend() => null; | 183 Send asSend() => null; |
| 186 SendSet asSendSet() => null; | 184 SendSet asSendSet() => null; |
| 187 Statement asStatement() => null; | 185 Statement asStatement() => null; |
| 188 StringInterpolation asStringInterpolation() => null; | 186 StringInterpolation asStringInterpolation() => null; |
| 189 StringInterpolationPart asStringInterpolationPart() => null; | 187 StringInterpolationPart asStringInterpolationPart() => null; |
| 190 StringJuxtaposition asStringJuxtaposition() => null; | 188 StringJuxtaposition asStringJuxtaposition() => null; |
| 191 StringNode asStringNode() => null; | 189 StringNode asStringNode() => null; |
| 192 SwitchCase asSwitchCase() => null; | 190 SwitchCase asSwitchCase() => null; |
| 193 SwitchStatement asSwitchStatement() => null; | 191 SwitchStatement asSwitchStatement() => null; |
| 194 Throw asThrow() => null; | 192 Throw asThrow() => null; |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 | 1686 |
| 1689 Token getBeginToken() => labels.getBeginToken(); | 1687 Token getBeginToken() => labels.getBeginToken(); |
| 1690 | 1688 |
| 1691 Token getEndToken() => statement.getEndToken(); | 1689 Token getEndToken() => statement.getEndToken(); |
| 1692 | 1690 |
| 1693 bool isValidContinueTarget() => statement.isValidContinueTarget(); | 1691 bool isValidContinueTarget() => statement.isValidContinueTarget(); |
| 1694 | 1692 |
| 1695 Node getBody() => statement; | 1693 Node getBody() => statement; |
| 1696 } | 1694 } |
| 1697 | 1695 |
| 1698 class ScriptTag extends Node { | |
| 1699 final Identifier tag; | |
| 1700 final StringNode argument; | |
| 1701 final Identifier prefixIdentifier; | |
| 1702 final StringNode prefix; | |
| 1703 | |
| 1704 final Token beginToken; | |
| 1705 final Token endToken; | |
| 1706 | |
| 1707 ScriptTag(this.tag, this.argument, this.prefixIdentifier, this.prefix, | |
| 1708 this.beginToken, this.endToken); | |
| 1709 | |
| 1710 bool isImport() => tag.source == const SourceString("import"); | |
| 1711 bool isSource() => tag.source == const SourceString("source"); | |
| 1712 bool isLibrary() => tag.source == const SourceString("library"); | |
| 1713 | |
| 1714 ScriptTag asScriptTag() => this; | |
| 1715 | |
| 1716 accept(Visitor visitor) => visitor.visitScriptTag(this); | |
| 1717 | |
| 1718 visitChildren(Visitor visitor) { | |
| 1719 tag.accept(visitor); | |
| 1720 argument.accept(visitor); | |
| 1721 if (prefixIdentifier != null) prefixIdentifier.accept(visitor); | |
| 1722 if (prefix != null) prefix.accept(visitor); | |
| 1723 } | |
| 1724 | |
| 1725 Token getBeginToken() => beginToken; | |
| 1726 | |
| 1727 Token getEndToken() => endToken; | |
| 1728 | |
| 1729 LibraryTag toLibraryTag() { | |
| 1730 if (isImport()) { | |
| 1731 Identifier prefixNode; | |
| 1732 if (prefix != null) { | |
| 1733 SourceString source = prefix.dartString.source; | |
| 1734 Token prefixToken = prefix.getBeginToken(); | |
| 1735 Token token = new StringToken.fromSource(IDENTIFIER_INFO, source, | |
| 1736 prefixToken.charOffset); | |
| 1737 token.next = prefixToken.next; | |
| 1738 prefixNode = new Identifier(token); | |
| 1739 } | |
| 1740 return new Import(tag.token, argument, prefixNode, null, null); | |
| 1741 } else if (isLibrary()) { | |
| 1742 return new LibraryName(tag.token, argument, null); | |
| 1743 } else if (isSource()) { | |
| 1744 return new Part(tag.token, argument, null); | |
| 1745 } else { | |
| 1746 throw 'Unknown script tag ${tag.token.slowToString()}'; | |
| 1747 } | |
| 1748 } | |
| 1749 } | |
| 1750 | |
| 1751 abstract class LibraryTag extends Node { | 1696 abstract class LibraryTag extends Node { |
| 1752 final Link<MetadataAnnotation> metadata; | 1697 final Link<MetadataAnnotation> metadata; |
| 1753 | 1698 |
| 1754 LibraryTag(this.metadata); | 1699 LibraryTag(this.metadata); |
| 1755 | 1700 |
| 1756 bool get isLibraryName => false; | 1701 bool get isLibraryName => false; |
| 1757 bool get isImport => false; | 1702 bool get isImport => false; |
| 1758 bool get isExport => false; | 1703 bool get isExport => false; |
| 1759 bool get isPart => false; | 1704 bool get isPart => false; |
| 1760 bool get isPartOf => false; | 1705 bool get isPartOf => false; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2107 * argument). | 2052 * argument). |
| 2108 * | 2053 * |
| 2109 * TODO(ahe): This method is controversial, the team needs to discuss | 2054 * TODO(ahe): This method is controversial, the team needs to discuss |
| 2110 * if top-level methods are acceptable and what naming conventions to | 2055 * if top-level methods are acceptable and what naming conventions to |
| 2111 * use. | 2056 * use. |
| 2112 */ | 2057 */ |
| 2113 initializerDo(Node node, f(Node node)) { | 2058 initializerDo(Node node, f(Node node)) { |
| 2114 SendSet send = node.asSendSet(); | 2059 SendSet send = node.asSendSet(); |
| 2115 if (send != null) return f(send.arguments.head); | 2060 if (send != null) return f(send.arguments.head); |
| 2116 } | 2061 } |
| OLD | NEW |