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); |
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 return statements.getEndToken(); | 1365 return statements.getEndToken(); |
1366 } | 1366 } |
1367 } | 1367 } |
1368 | 1368 |
1369 Link<Token> caseKeywords() { | 1369 Link<Token> caseKeywords() { |
1370 Token token = startToken; | 1370 Token token = startToken; |
1371 if (label !== null) { | 1371 if (label !== null) { |
1372 // Skip past the label: <Identifier> ':'. | 1372 // Skip past the label: <Identifier> ':'. |
1373 token = token.next.next; | 1373 token = token.next.next; |
1374 } | 1374 } |
1375 Link<Token> recursiveGetCases(Token token, Link<Expression> expressions) { | 1375 LinkBuilder<Token> builder = new LinkBuilder<Token>(); |
1376 if (token.stringValue === 'case') { | 1376 Link<Expression> link = expressions.nodes; |
1377 Token colon = expressions.head.getEndToken().next; | 1377 while (token.stringValue === 'case') { |
1378 return new Link<Token>(token, | 1378 assert(token.next === link.head.getBeginToken(0)); |
1379 recursiveGetCases(colon.next, expressions.tail)); | 1379 builder.addLast(token); |
1380 } | 1380 Token colon = link.head.getEndToken().next; |
1381 return const EmptyLink<Token>(); | 1381 token = colon.next; |
| 1382 link = link.tail; |
1382 } | 1383 } |
1383 return recursiveGetCases(token, expressions.nodes); | 1384 return builder.toLink(); |
1384 } | 1385 } |
1385 } | 1386 } |
1386 | 1387 |
1387 class GotoStatement extends Statement { | 1388 class GotoStatement extends Statement { |
1388 final Identifier target; | 1389 final Identifier target; |
1389 final Token keywordToken; | 1390 final Token keywordToken; |
1390 final Token semicolonToken; | 1391 final Token semicolonToken; |
1391 | 1392 |
1392 GotoStatement(this.target, this.keywordToken, this.semicolonToken); | 1393 GotoStatement(this.target, this.keywordToken, this.semicolonToken); |
1393 | 1394 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1561 | 1562 |
1562 Token getBeginToken() => tryKeyword; | 1563 Token getBeginToken() => tryKeyword; |
1563 | 1564 |
1564 Token getEndToken() { | 1565 Token getEndToken() { |
1565 if (finallyBlock !== null) return finallyBlock.getEndToken(); | 1566 if (finallyBlock !== null) return finallyBlock.getEndToken(); |
1566 if (!catchBlocks.isEmpty()) return catchBlocks.getEndToken(); | 1567 if (!catchBlocks.isEmpty()) return catchBlocks.getEndToken(); |
1567 return tryBlock.getEndToken(); | 1568 return tryBlock.getEndToken(); |
1568 } | 1569 } |
1569 } | 1570 } |
1570 | 1571 |
1571 class Cascade extends Node { | 1572 class Cascade extends Expression { |
1572 final Node expression; | 1573 final Expression expression; |
1573 Cascade(this.expression); | 1574 Cascade(this.expression); |
1574 | 1575 |
1575 Cascade asCascade() => this; | 1576 Cascade asCascade() => this; |
1576 accept(Visitor visitor) => visitor.visitCascade(this); | 1577 accept(Visitor visitor) => visitor.visitCascade(this); |
1577 | 1578 |
1578 void visitChildren(Visitor visitor) { | 1579 void visitChildren(Visitor visitor) { |
1579 expression.accept(visitor); | 1580 expression.accept(visitor); |
1580 } | 1581 } |
1581 | 1582 |
1582 Token getBeginToken() => expression.getBeginToken(); | 1583 Token getBeginToken() => expression.getBeginToken(); |
1583 | 1584 |
1584 Token getEndToken() => expression.getEndToken(); | 1585 Token getEndToken() => expression.getEndToken(); |
1585 } | 1586 } |
1586 | 1587 |
1587 class CascadeReceiver extends Node { | 1588 class CascadeReceiver extends Expression { |
1588 final Node expression; | 1589 final Expression expression; |
1589 final Token cascadeOperator; | 1590 final Token cascadeOperator; |
1590 CascadeReceiver(this.expression, this.cascadeOperator); | 1591 CascadeReceiver(this.expression, this.cascadeOperator); |
1591 | 1592 |
1592 CascadeReceiver asCascadeReceiver() => this; | 1593 CascadeReceiver asCascadeReceiver() => this; |
1593 accept(Visitor visitor) => visitor.visitCascadeReceiver(this); | 1594 accept(Visitor visitor) => visitor.visitCascadeReceiver(this); |
1594 | 1595 |
1595 void visitChildren(Visitor visitor) { | 1596 void visitChildren(Visitor visitor) { |
1596 expression.accept(visitor); | 1597 expression.accept(visitor); |
1597 } | 1598 } |
1598 | 1599 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 * argument). | 1681 * argument). |
1681 * | 1682 * |
1682 * TODO(ahe): This method is controversial, the team needs to discuss | 1683 * TODO(ahe): This method is controversial, the team needs to discuss |
1683 * if top-level methods are acceptable and what naming conventions to | 1684 * if top-level methods are acceptable and what naming conventions to |
1684 * use. | 1685 * use. |
1685 */ | 1686 */ |
1686 initializerDo(Node node, f(Node node)) { | 1687 initializerDo(Node node, f(Node node)) { |
1687 SendSet send = node.asSendSet(); | 1688 SendSet send = node.asSendSet(); |
1688 if (send !== null) return f(send.arguments.head); | 1689 if (send !== null) return f(send.arguments.head); |
1689 } | 1690 } |
OLD | NEW |