| 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 30 matching lines...) Expand all Loading... |
| 41 R visitLiteralBool(LiteralBool node) => visitLiteral(node); | 41 R visitLiteralBool(LiteralBool node) => visitLiteral(node); |
| 42 R visitLiteralDouble(LiteralDouble node) => visitLiteral(node); | 42 R visitLiteralDouble(LiteralDouble node) => visitLiteral(node); |
| 43 R visitLiteralInt(LiteralInt node) => visitLiteral(node); | 43 R visitLiteralInt(LiteralInt node) => visitLiteral(node); |
| 44 R visitLiteralList(LiteralList node) => visitExpression(node); | 44 R visitLiteralList(LiteralList node) => visitExpression(node); |
| 45 R visitLiteralMap(LiteralMap node) => visitExpression(node); | 45 R visitLiteralMap(LiteralMap node) => visitExpression(node); |
| 46 R visitLiteralMapEntry(LiteralMapEntry node) => visitNode(node); | 46 R visitLiteralMapEntry(LiteralMapEntry node) => visitNode(node); |
| 47 R visitLiteralNull(LiteralNull node) => visitLiteral(node); | 47 R visitLiteralNull(LiteralNull node) => visitLiteral(node); |
| 48 R visitLiteralString(LiteralString node) => visitStringNode(node); | 48 R visitLiteralString(LiteralString node) => visitStringNode(node); |
| 49 R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node); | 49 R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node); |
| 50 R visitLoop(Loop node) => visitStatement(node); | 50 R visitLoop(Loop node) => visitStatement(node); |
| 51 R visitMixinApplication(MixinApplication node) => visitNode(node); |
| 51 R visitModifiers(Modifiers node) => visitNode(node); | 52 R visitModifiers(Modifiers node) => visitNode(node); |
| 52 R visitNamedArgument(NamedArgument node) => visitExpression(node); | 53 R visitNamedArgument(NamedArgument node) => visitExpression(node); |
| 54 R visitNamedMixinApplication(NamedMixinApplication node) => visitNode(node); |
| 53 R visitNewExpression(NewExpression node) => visitExpression(node); | 55 R visitNewExpression(NewExpression node) => visitExpression(node); |
| 54 R visitNodeList(NodeList node) => visitNode(node); | 56 R visitNodeList(NodeList node) => visitNode(node); |
| 55 R visitOperator(Operator node) => visitIdentifier(node); | 57 R visitOperator(Operator node) => visitIdentifier(node); |
| 56 R visitParenthesizedExpression(ParenthesizedExpression node) { | 58 R visitParenthesizedExpression(ParenthesizedExpression node) { |
| 57 return visitExpression(node); | 59 return visitExpression(node); |
| 58 } | 60 } |
| 59 R visitPart(Part node) => visitLibraryTag(node); | 61 R visitPart(Part node) => visitLibraryTag(node); |
| 60 R visitPartOf(PartOf node) => visitNode(node); | 62 R visitPartOf(PartOf node) => visitNode(node); |
| 61 R visitPostfix(Postfix node) => visitNodeList(node); | 63 R visitPostfix(Postfix node) => visitNodeList(node); |
| 62 R visitPrefix(Prefix node) => visitNodeList(node); | 64 R visitPrefix(Prefix node) => visitNodeList(node); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 Cascade asCascade() => null; | 139 Cascade asCascade() => null; |
| 138 CascadeReceiver asCascadeReceiver() => null; | 140 CascadeReceiver asCascadeReceiver() => null; |
| 139 CaseMatch asCaseMatch() => null; | 141 CaseMatch asCaseMatch() => null; |
| 140 CatchBlock asCatchBlock() => null; | 142 CatchBlock asCatchBlock() => null; |
| 141 ClassNode asClassNode() => null; | 143 ClassNode asClassNode() => null; |
| 142 Combinator asCombinator() => null; | 144 Combinator asCombinator() => null; |
| 143 Conditional asConditional() => null; | 145 Conditional asConditional() => null; |
| 144 ContinueStatement asContinueStatement() => null; | 146 ContinueStatement asContinueStatement() => null; |
| 145 DoWhile asDoWhile() => null; | 147 DoWhile asDoWhile() => null; |
| 146 EmptyStatement asEmptyStatement() => null; | 148 EmptyStatement asEmptyStatement() => null; |
| 147 Export AsExport() => null; | 149 Export asExport() => null; |
| 148 Expression asExpression() => null; | 150 Expression asExpression() => null; |
| 149 ExpressionStatement asExpressionStatement() => null; | 151 ExpressionStatement asExpressionStatement() => null; |
| 150 For asFor() => null; | 152 For asFor() => null; |
| 151 ForIn asForIn() => null; | 153 ForIn asForIn() => null; |
| 152 FunctionDeclaration asFunctionDeclaration() => null; | 154 FunctionDeclaration asFunctionDeclaration() => null; |
| 153 FunctionExpression asFunctionExpression() => null; | 155 FunctionExpression asFunctionExpression() => null; |
| 154 Identifier asIdentifier() => null; | 156 Identifier asIdentifier() => null; |
| 155 If asIf() => null; | 157 If asIf() => null; |
| 156 Import AsImport() => null; | 158 Import asImport() => null; |
| 157 Label asLabel() => null; | 159 Label asLabel() => null; |
| 158 LabeledStatement asLabeledStatement() => null; | 160 LabeledStatement asLabeledStatement() => null; |
| 159 LibraryName AsLibraryName() => null; | 161 LibraryName asLibraryName() => null; |
| 160 LiteralBool asLiteralBool() => null; | 162 LiteralBool asLiteralBool() => null; |
| 161 LiteralDouble asLiteralDouble() => null; | 163 LiteralDouble asLiteralDouble() => null; |
| 162 LiteralInt asLiteralInt() => null; | 164 LiteralInt asLiteralInt() => null; |
| 163 LiteralList asLiteralList() => null; | 165 LiteralList asLiteralList() => null; |
| 164 LiteralMap asLiteralMap() => null; | 166 LiteralMap asLiteralMap() => null; |
| 165 LiteralMapEntry asLiteralMapEntry() => null; | 167 LiteralMapEntry asLiteralMapEntry() => null; |
| 166 LiteralNull asLiteralNull() => null; | 168 LiteralNull asLiteralNull() => null; |
| 167 LiteralString asLiteralString() => null; | 169 LiteralString asLiteralString() => null; |
| 170 MixinApplication asMixinApplication() => null; |
| 168 Modifiers asModifiers() => null; | 171 Modifiers asModifiers() => null; |
| 169 NamedArgument asNamedArgument() => null; | 172 NamedArgument asNamedArgument() => null; |
| 170 NodeList asNodeList() => null; | 173 NodeList asNodeList() => null; |
| 171 Operator asOperator() => null; | 174 Operator asOperator() => null; |
| 172 ParenthesizedExpression asParenthesizedExpression() => null; | 175 ParenthesizedExpression asParenthesizedExpression() => null; |
| 173 Part AsPart() => null; | 176 Part asPart() => null; |
| 174 PartOf AsPartOf() => null; | 177 PartOf asPartOf() => null; |
| 175 Return asReturn() => null; | 178 Return asReturn() => null; |
| 176 ScriptTag asScriptTag() => null; | 179 ScriptTag asScriptTag() => null; |
| 177 Send asSend() => null; | 180 Send asSend() => null; |
| 178 SendSet asSendSet() => null; | 181 SendSet asSendSet() => null; |
| 179 Statement asStatement() => null; | 182 Statement asStatement() => null; |
| 180 StringInterpolation asStringInterpolation() => null; | 183 StringInterpolation asStringInterpolation() => null; |
| 181 StringInterpolationPart asStringInterpolationPart() => null; | 184 StringInterpolationPart asStringInterpolationPart() => null; |
| 182 StringJuxtaposition asStringJuxtaposition() => null; | 185 StringJuxtaposition asStringJuxtaposition() => null; |
| 183 StringNode asStringNode() => null; | 186 StringNode asStringNode() => null; |
| 184 SwitchCase asSwitchCase() => null; | 187 SwitchCase asSwitchCase() => null; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 231 |
| 229 bool get isInterface => identical(beginToken.stringValue, 'interface'); | 232 bool get isInterface => identical(beginToken.stringValue, 'interface'); |
| 230 | 233 |
| 231 bool get isClass => !isInterface; | 234 bool get isClass => !isInterface; |
| 232 | 235 |
| 233 Token getBeginToken() => beginToken; | 236 Token getBeginToken() => beginToken; |
| 234 | 237 |
| 235 Token getEndToken() => endToken; | 238 Token getEndToken() => endToken; |
| 236 } | 239 } |
| 237 | 240 |
| 241 class MixinApplication extends Node { |
| 242 final Modifiers modifiers; |
| 243 final TypeAnnotation superclass; |
| 244 final NodeList mixins; |
| 245 |
| 246 MixinApplication(this.modifiers, this.superclass, this.mixins); |
| 247 |
| 248 MixinApplication asMixinApplication() => this; |
| 249 |
| 250 accept(Visitor visitor) => visitor.visitMixinApplication(this); |
| 251 |
| 252 visitChildren(Visitor visitor) { |
| 253 if (modifiers != null) modifiers.accept(visitor); |
| 254 if (superclass != null) superclass.accept(visitor); |
| 255 if (mixins != null) mixins.accept(visitor); |
| 256 } |
| 257 |
| 258 Token getBeginToken() => superclass.getBeginToken(); |
| 259 Token getEndToken() => mixins.getEndToken(); |
| 260 } |
| 261 |
| 262 // TODO(kasperl): Let this share some structure with the typedef for function |
| 263 // type aliases? |
| 264 class NamedMixinApplication extends Node { |
| 265 final Identifier name; |
| 266 final NodeList typeParameters; |
| 267 final MixinApplication mixinApplication; |
| 268 |
| 269 final Token typedefKeyword; |
| 270 final Token endToken; |
| 271 |
| 272 NamedMixinApplication(this.name, this.typeParameters, this.mixinApplication, |
| 273 this.typedefKeyword, this.endToken); |
| 274 |
| 275 NamedMixinApplication asNamedMixinApplication() => this; |
| 276 |
| 277 accept(Visitor visitor) => visitor.visitNamedMixinApplication(this); |
| 278 |
| 279 visitChildren(Visitor visitor) { |
| 280 name.accept(visitor); |
| 281 if (typeParameters != null) typeParameters.accept(visitor); |
| 282 mixinApplication.accept(visitor); |
| 283 } |
| 284 |
| 285 Token getBeginToken() => typedefKeyword; |
| 286 Token getEndToken() => endToken; |
| 287 } |
| 288 |
| 238 abstract class Expression extends Node { | 289 abstract class Expression extends Node { |
| 239 Expression(); | 290 Expression(); |
| 240 | 291 |
| 241 Expression asExpression() => this; | 292 Expression asExpression() => this; |
| 242 | 293 |
| 243 // TODO(ahe): make class abstract instead of adding an abstract method. | 294 // TODO(ahe): make class abstract instead of adding an abstract method. |
| 244 accept(Visitor visitor); | 295 accept(Visitor visitor); |
| 245 } | 296 } |
| 246 | 297 |
| 247 abstract class Statement extends Node { | 298 abstract class Statement extends Node { |
| (...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2000 * argument). | 2051 * argument). |
| 2001 * | 2052 * |
| 2002 * TODO(ahe): This method is controversial, the team needs to discuss | 2053 * TODO(ahe): This method is controversial, the team needs to discuss |
| 2003 * if top-level methods are acceptable and what naming conventions to | 2054 * if top-level methods are acceptable and what naming conventions to |
| 2004 * use. | 2055 * use. |
| 2005 */ | 2056 */ |
| 2006 initializerDo(Node node, f(Node node)) { | 2057 initializerDo(Node node, f(Node node)) { |
| 2007 SendSet send = node.asSendSet(); | 2058 SendSet send = node.asSendSet(); |
| 2008 if (send != null) return f(send.arguments.head); | 2059 if (send != null) return f(send.arguments.head); |
| 2009 } | 2060 } |
| OLD | NEW |