| 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 visitCatchBlock(CatchBlock node); | 10 R visitCatchBlock(CatchBlock node); |
| 11 R visitClassNode(ClassNode node); | 11 R visitClassNode(ClassNode node); |
| 12 R visitConditional(Conditional node); | 12 R visitConditional(Conditional node); |
| 13 R visitContinueStatement(ContinueStatement node); | 13 R visitContinueStatement(ContinueStatement node); |
| 14 R visitDoWhile(DoWhile node); | 14 R visitDoWhile(DoWhile node); |
| 15 R visitEmptyStatement(EmptyStatement node); | 15 R visitEmptyStatement(EmptyStatement node); |
| 16 R visitExpressionStatement(ExpressionStatement node); | 16 R visitExpressionStatement(ExpressionStatement node); |
| 17 R visitFor(For node); | 17 R visitFor(For node); |
| 18 R visitForIn(ForIn node); | 18 R visitForIn(ForIn node); |
| 19 R visitFunctionDeclaration(FunctionDeclaration node); | 19 R visitFunctionDeclaration(FunctionDeclaration node); |
| 20 R visitFunctionExpression(FunctionExpression node); | 20 R visitFunctionExpression(FunctionExpression node); |
| 21 R visitIdentifier(Identifier node); | 21 R visitIdentifier(Identifier node); |
| 22 R visitIf(If node); | 22 R visitIf(If node); |
| 23 R visitLabel(Label node); |
| 23 R visitLabeledStatement(LabeledStatement node); | 24 R visitLabeledStatement(LabeledStatement node); |
| 24 R visitLiteralBool(LiteralBool node); | 25 R visitLiteralBool(LiteralBool node); |
| 25 R visitLiteralDouble(LiteralDouble node); | 26 R visitLiteralDouble(LiteralDouble node); |
| 26 R visitLiteralInt(LiteralInt node); | 27 R visitLiteralInt(LiteralInt node); |
| 27 R visitLiteralList(LiteralList node); | 28 R visitLiteralList(LiteralList node); |
| 28 R visitLiteralMap(LiteralMap node); | 29 R visitLiteralMap(LiteralMap node); |
| 29 R visitLiteralMapEntry(LiteralMapEntry node); | 30 R visitLiteralMapEntry(LiteralMapEntry node); |
| 30 R visitLiteralNull(LiteralNull node); | 31 R visitLiteralNull(LiteralNull node); |
| 31 R visitLiteralString(LiteralString node); | 32 R visitLiteralString(LiteralString node); |
| 32 R visitStringJuxtaposition(StringJuxtaposition node); | 33 R visitStringJuxtaposition(StringJuxtaposition node); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 DoWhile asDoWhile() => null; | 120 DoWhile asDoWhile() => null; |
| 120 EmptyStatement asEmptyStatement() => null; | 121 EmptyStatement asEmptyStatement() => null; |
| 121 Expression asExpression() => null; | 122 Expression asExpression() => null; |
| 122 ExpressionStatement asExpressionStatement() => null; | 123 ExpressionStatement asExpressionStatement() => null; |
| 123 For asFor() => null; | 124 For asFor() => null; |
| 124 ForIn asForIn() => null; | 125 ForIn asForIn() => null; |
| 125 FunctionDeclaration asFunctionDeclaration() => null; | 126 FunctionDeclaration asFunctionDeclaration() => null; |
| 126 FunctionExpression asFunctionExpression() => null; | 127 FunctionExpression asFunctionExpression() => null; |
| 127 Identifier asIdentifier() => null; | 128 Identifier asIdentifier() => null; |
| 128 If asIf() => null; | 129 If asIf() => null; |
| 130 Label asLabel() => null; |
| 129 LabeledStatement asLabeledStatement() => null; | 131 LabeledStatement asLabeledStatement() => null; |
| 130 LiteralBool asLiteralBool() => null; | 132 LiteralBool asLiteralBool() => null; |
| 131 LiteralDouble asLiteralDouble() => null; | 133 LiteralDouble asLiteralDouble() => null; |
| 132 LiteralInt asLiteralInt() => null; | 134 LiteralInt asLiteralInt() => null; |
| 133 LiteralList asLiteralList() => null; | 135 LiteralList asLiteralList() => null; |
| 134 LiteralMap asLiteralMap() => null; | 136 LiteralMap asLiteralMap() => null; |
| 135 LiteralMapEntry asLiteralMapEntry() => null; | 137 LiteralMapEntry asLiteralMapEntry() => null; |
| 136 LiteralNull asLiteralNull() => null; | 138 LiteralNull asLiteralNull() => null; |
| 137 LiteralString asLiteralString() => null; | 139 LiteralString asLiteralString() => null; |
| 138 Modifiers asModifiers() => null; | 140 Modifiers asModifiers() => null; |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 Token getEndToken() => cases.getEndToken(); | 1321 Token getEndToken() => cases.getEndToken(); |
| 1320 } | 1322 } |
| 1321 | 1323 |
| 1322 class SwitchCase extends Node { | 1324 class SwitchCase extends Node { |
| 1323 // Represents the grammar: | 1325 // Represents the grammar: |
| 1324 // label? ('case' expression ':')* ('default' ':')? statement* | 1326 // label? ('case' expression ':')* ('default' ':')? statement* |
| 1325 // Each expression is collected in [expressions]. | 1327 // Each expression is collected in [expressions]. |
| 1326 // The 'case' keywords can be obtained using [caseKeywords()]. | 1328 // The 'case' keywords can be obtained using [caseKeywords()]. |
| 1327 // Any actual switch case must have at least one 'case' or 'default' | 1329 // Any actual switch case must have at least one 'case' or 'default' |
| 1328 // clause. | 1330 // clause. |
| 1329 final Identifier label; | 1331 final Label label; |
| 1330 final NodeList expressions; | 1332 final NodeList expressions; |
| 1331 final Token defaultKeyword; | 1333 final Token defaultKeyword; |
| 1332 final NodeList statements; | 1334 final NodeList statements; |
| 1333 | 1335 |
| 1334 final Token startToken; | 1336 final Token startToken; |
| 1335 | 1337 |
| 1336 SwitchCase(this.label, this.expressions, this.defaultKeyword, | 1338 SwitchCase(this.label, this.expressions, this.defaultKeyword, |
| 1337 this.statements, this.startToken); | 1339 this.statements, this.startToken); |
| 1338 | 1340 |
| 1339 SwitchCase asSwitchCase() => this; | 1341 SwitchCase asSwitchCase() => this; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 declaredIdentifier.accept(visitor); | 1444 declaredIdentifier.accept(visitor); |
| 1443 expression.accept(visitor); | 1445 expression.accept(visitor); |
| 1444 body.accept(visitor); | 1446 body.accept(visitor); |
| 1445 } | 1447 } |
| 1446 | 1448 |
| 1447 Token getBeginToken() => forToken; | 1449 Token getBeginToken() => forToken; |
| 1448 | 1450 |
| 1449 Token getEndToken() => body.getEndToken(); | 1451 Token getEndToken() => body.getEndToken(); |
| 1450 } | 1452 } |
| 1451 | 1453 |
| 1454 class Label extends Node { |
| 1455 final Identifier identifier; |
| 1456 final Token colonToken; |
| 1457 |
| 1458 Label(this.identifier, this.colonToken); |
| 1459 |
| 1460 String slowToString() => identifier.source.slowToString(); |
| 1461 |
| 1462 Label asLabel() => this; |
| 1463 |
| 1464 accept(Visitor visitor) => visitor.visitLabel(this); |
| 1465 |
| 1466 void visitChildren(Visitor visitor) { |
| 1467 identifier.accept(visitor); |
| 1468 } |
| 1469 |
| 1470 Token getBeginToken() => identifier.token; |
| 1471 Token getEndToken() => colonToken; |
| 1472 } |
| 1473 |
| 1452 class LabeledStatement extends Statement { | 1474 class LabeledStatement extends Statement { |
| 1453 final Identifier label; | 1475 final Label label; |
| 1454 final Token colonToken; | |
| 1455 final Statement statement; | 1476 final Statement statement; |
| 1456 | 1477 |
| 1457 LabeledStatement(this.label, this.colonToken, this.statement); | 1478 LabeledStatement(this.label, this.statement); |
| 1458 | 1479 |
| 1459 LabeledStatement asLabeledStatement() => this; | 1480 LabeledStatement asLabeledStatement() => this; |
| 1460 | 1481 |
| 1461 accept(Visitor visitor) => visitor.visitLabeledStatement(this); | 1482 accept(Visitor visitor) => visitor.visitLabeledStatement(this); |
| 1462 | 1483 |
| 1463 visitChildren(Visitor visitor) { | 1484 visitChildren(Visitor visitor) { |
| 1464 label.accept(visitor); | 1485 label.accept(visitor); |
| 1465 statement.accept(visitor); | 1486 statement.accept(visitor); |
| 1466 } | 1487 } |
| 1467 | 1488 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 * argument). | 1702 * argument). |
| 1682 * | 1703 * |
| 1683 * TODO(ahe): This method is controversial, the team needs to discuss | 1704 * TODO(ahe): This method is controversial, the team needs to discuss |
| 1684 * if top-level methods are acceptable and what naming conventions to | 1705 * if top-level methods are acceptable and what naming conventions to |
| 1685 * use. | 1706 * use. |
| 1686 */ | 1707 */ |
| 1687 initializerDo(Node node, f(Node node)) { | 1708 initializerDo(Node node, f(Node node)) { |
| 1688 SendSet send = node.asSendSet(); | 1709 SendSet send = node.asSendSet(); |
| 1689 if (send !== null) return f(send.arguments.head); | 1710 if (send !== null) return f(send.arguments.head); |
| 1690 } | 1711 } |
| OLD | NEW |