| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 Cascade asCascade() => null; | 142 Cascade asCascade() => null; |
| 143 CascadeReceiver asCascadeReceiver() => null; | 143 CascadeReceiver asCascadeReceiver() => null; |
| 144 CaseMatch asCaseMatch() => null; | 144 CaseMatch asCaseMatch() => null; |
| 145 CatchBlock asCatchBlock() => null; | 145 CatchBlock asCatchBlock() => null; |
| 146 ClassNode asClassNode() => null; | 146 ClassNode asClassNode() => null; |
| 147 Combinator asCombinator() => null; | 147 Combinator asCombinator() => null; |
| 148 Conditional asConditional() => null; | 148 Conditional asConditional() => null; |
| 149 ContinueStatement asContinueStatement() => null; | 149 ContinueStatement asContinueStatement() => null; |
| 150 DoWhile asDoWhile() => null; | 150 DoWhile asDoWhile() => null; |
| 151 EmptyStatement asEmptyStatement() => null; | 151 EmptyStatement asEmptyStatement() => null; |
| 152 ErrorExpression asErrorExpression() => null; |
| 152 Export asExport() => null; | 153 Export asExport() => null; |
| 153 Expression asExpression() => null; | 154 Expression asExpression() => null; |
| 154 ExpressionStatement asExpressionStatement() => null; | 155 ExpressionStatement asExpressionStatement() => null; |
| 155 For asFor() => null; | 156 For asFor() => null; |
| 156 ForIn asForIn() => null; | 157 ForIn asForIn() => null; |
| 157 FunctionDeclaration asFunctionDeclaration() => null; | 158 FunctionDeclaration asFunctionDeclaration() => null; |
| 158 FunctionExpression asFunctionExpression() => null; | 159 FunctionExpression asFunctionExpression() => null; |
| 159 Identifier asIdentifier() => null; | 160 Identifier asIdentifier() => null; |
| 160 If asIf() => null; | 161 If asIf() => null; |
| 161 Import asImport() => null; | 162 Import asImport() => null; |
| 162 Label asLabel() => null; | 163 Label asLabel() => null; |
| 163 LabeledStatement asLabeledStatement() => null; | 164 LabeledStatement asLabeledStatement() => null; |
| 164 LibraryName asLibraryName() => null; | 165 LibraryName asLibraryName() => null; |
| 165 LibraryDependency asLibraryDependency() => null; | 166 LibraryDependency asLibraryDependency() => null; |
| 166 LiteralBool asLiteralBool() => null; | 167 LiteralBool asLiteralBool() => null; |
| 167 LiteralDouble asLiteralDouble() => null; | 168 LiteralDouble asLiteralDouble() => null; |
| 168 LiteralInt asLiteralInt() => null; | 169 LiteralInt asLiteralInt() => null; |
| 169 LiteralList asLiteralList() => null; | 170 LiteralList asLiteralList() => null; |
| 170 LiteralMap asLiteralMap() => null; | 171 LiteralMap asLiteralMap() => null; |
| 171 LiteralMapEntry asLiteralMapEntry() => null; | 172 LiteralMapEntry asLiteralMapEntry() => null; |
| 172 LiteralNull asLiteralNull() => null; | 173 LiteralNull asLiteralNull() => null; |
| 173 LiteralString asLiteralString() => null; | 174 LiteralString asLiteralString() => null; |
| 175 LiteralSymbol asLiteralSymbol() => null; |
| 174 MixinApplication asMixinApplication() => null; | 176 MixinApplication asMixinApplication() => null; |
| 175 Modifiers asModifiers() => null; | 177 Modifiers asModifiers() => null; |
| 176 NamedArgument asNamedArgument() => null; | 178 NamedArgument asNamedArgument() => null; |
| 177 NamedMixinApplication asNamedMixinApplication() => null; | 179 NamedMixinApplication asNamedMixinApplication() => null; |
| 178 NewExpression asNewExpression() => null; | 180 NewExpression asNewExpression() => null; |
| 179 NodeList asNodeList() => null; | 181 NodeList asNodeList() => null; |
| 180 Operator asOperator() => null; | 182 Operator asOperator() => null; |
| 181 ParenthesizedExpression asParenthesizedExpression() => null; | 183 ParenthesizedExpression asParenthesizedExpression() => null; |
| 182 Part asPart() => null; | 184 Part asPart() => null; |
| 183 PartOf asPartOf() => null; | 185 PartOf asPartOf() => null; |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 final Token ifToken; | 592 final Token ifToken; |
| 591 final Token elseToken; | 593 final Token elseToken; |
| 592 | 594 |
| 593 If(this.condition, this.thenPart, this.elsePart, | 595 If(this.condition, this.thenPart, this.elsePart, |
| 594 this.ifToken, this.elseToken); | 596 this.ifToken, this.elseToken); |
| 595 | 597 |
| 596 If asIf() => this; | 598 If asIf() => this; |
| 597 | 599 |
| 598 bool get hasElsePart => elsePart != null; | 600 bool get hasElsePart => elsePart != null; |
| 599 | 601 |
| 600 void validate() { | |
| 601 // TODO(ahe): Check that condition has size one. | |
| 602 } | |
| 603 | |
| 604 accept(Visitor visitor) => visitor.visitIf(this); | 602 accept(Visitor visitor) => visitor.visitIf(this); |
| 605 | 603 |
| 606 visitChildren(Visitor visitor) { | 604 visitChildren(Visitor visitor) { |
| 607 if (condition != null) condition.accept(visitor); | 605 if (condition != null) condition.accept(visitor); |
| 608 if (thenPart != null) thenPart.accept(visitor); | 606 if (thenPart != null) thenPart.accept(visitor); |
| 609 if (elsePart != null) elsePart.accept(visitor); | 607 if (elsePart != null) elsePart.accept(visitor); |
| 610 } | 608 } |
| 611 | 609 |
| 612 Token getBeginToken() => ifToken; | 610 Token getBeginToken() => ifToken; |
| 613 | 611 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 /** Non-null on validated string literals. */ | 909 /** Non-null on validated string literals. */ |
| 912 final DartString dartString; | 910 final DartString dartString; |
| 913 | 911 |
| 914 LiteralString(this.token, this.dartString); | 912 LiteralString(this.token, this.dartString); |
| 915 | 913 |
| 916 LiteralString asLiteralString() => this; | 914 LiteralString asLiteralString() => this; |
| 917 | 915 |
| 918 void visitChildren(Visitor visitor) {} | 916 void visitChildren(Visitor visitor) {} |
| 919 | 917 |
| 920 bool get isInterpolation => false; | 918 bool get isInterpolation => false; |
| 921 bool isValidated() => dartString != null; | |
| 922 | 919 |
| 923 Token getBeginToken() => token; | 920 Token getBeginToken() => token; |
| 924 Token getEndToken() => token; | 921 Token getEndToken() => token; |
| 925 | 922 |
| 926 accept(Visitor visitor) => visitor.visitLiteralString(this); | 923 accept(Visitor visitor) => visitor.visitLiteralString(this); |
| 927 } | 924 } |
| 928 | 925 |
| 929 class LiteralNull extends Literal<String> { | 926 class LiteralNull extends Literal<String> { |
| 930 LiteralNull(Token token) : super(token, null); | 927 LiteralNull(Token token) : super(token, null); |
| 931 | 928 |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1718 visitChildren(Visitor visitor) { | 1715 visitChildren(Visitor visitor) { |
| 1719 labels.accept(visitor); | 1716 labels.accept(visitor); |
| 1720 statement.accept(visitor); | 1717 statement.accept(visitor); |
| 1721 } | 1718 } |
| 1722 | 1719 |
| 1723 Token getBeginToken() => labels.getBeginToken(); | 1720 Token getBeginToken() => labels.getBeginToken(); |
| 1724 | 1721 |
| 1725 Token getEndToken() => statement.getEndToken(); | 1722 Token getEndToken() => statement.getEndToken(); |
| 1726 | 1723 |
| 1727 bool isValidContinueTarget() => statement.isValidContinueTarget(); | 1724 bool isValidContinueTarget() => statement.isValidContinueTarget(); |
| 1728 | |
| 1729 Node getBody() => statement; | |
| 1730 } | 1725 } |
| 1731 | 1726 |
| 1732 abstract class LibraryTag extends Node { | 1727 abstract class LibraryTag extends Node { |
| 1733 final Link<MetadataAnnotation> metadata; | 1728 final Link<MetadataAnnotation> metadata; |
| 1734 | 1729 |
| 1735 LibraryTag(this.metadata); | 1730 LibraryTag(this.metadata); |
| 1736 | 1731 |
| 1737 bool get isLibraryName => false; | 1732 bool get isLibraryName => false; |
| 1738 bool get isImport => false; | 1733 bool get isImport => false; |
| 1739 bool get isExport => false; | 1734 bool get isExport => false; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2090 * argument). | 2085 * argument). |
| 2091 * | 2086 * |
| 2092 * TODO(ahe): This method is controversial, the team needs to discuss | 2087 * TODO(ahe): This method is controversial, the team needs to discuss |
| 2093 * if top-level methods are acceptable and what naming conventions to | 2088 * if top-level methods are acceptable and what naming conventions to |
| 2094 * use. | 2089 * use. |
| 2095 */ | 2090 */ |
| 2096 initializerDo(Node node, f(Node node)) { | 2091 initializerDo(Node node, f(Node node)) { |
| 2097 SendSet send = node.asSendSet(); | 2092 SendSet send = node.asSendSet(); |
| 2098 if (send != null) return f(send.arguments.head); | 2093 if (send != null) return f(send.arguments.head); |
| 2099 } | 2094 } |
| OLD | NEW |