| 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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 Token getEndToken() => token; | 619 Token getEndToken() => token; |
| 620 } | 620 } |
| 621 | 621 |
| 622 class LiteralInt extends Literal<int> { | 622 class LiteralInt extends Literal<int> { |
| 623 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); | 623 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); |
| 624 | 624 |
| 625 LiteralInt asLiteralInt() => this; | 625 LiteralInt asLiteralInt() => this; |
| 626 | 626 |
| 627 int get value() { | 627 int get value() { |
| 628 try { | 628 try { |
| 629 Token token = this.token; | 629 Token valueToken = token; |
| 630 if (token.kind === PLUS_TOKEN) token = token.next; | 630 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; |
| 631 return Math.parseInt(token.value.slowToString()); | 631 return Math.parseInt(valueToken.value.slowToString()); |
| 632 } catch (BadNumberFormatException ex) { | 632 } catch (BadNumberFormatException ex) { |
| 633 (this.handler)(token, ex); | 633 (this.handler)(token, ex); |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 | 636 |
| 637 accept(Visitor visitor) => visitor.visitLiteralInt(this); | 637 accept(Visitor visitor) => visitor.visitLiteralInt(this); |
| 638 } | 638 } |
| 639 | 639 |
| 640 class LiteralDouble extends Literal<double> { | 640 class LiteralDouble extends Literal<double> { |
| 641 LiteralDouble(Token token, DecodeErrorHandler handler) | 641 LiteralDouble(Token token, DecodeErrorHandler handler) |
| 642 : super(token, handler); | 642 : super(token, handler); |
| 643 | 643 |
| 644 LiteralDouble asLiteralDouble() => this; | 644 LiteralDouble asLiteralDouble() => this; |
| 645 | 645 |
| 646 double get value() { | 646 double get value() { |
| 647 try { | 647 try { |
| 648 Token token = this.token; | 648 Token valueToken = token; |
| 649 if (token.kind === PLUS_TOKEN) token = token.next; | 649 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; |
| 650 return Math.parseDouble(token.value.slowToString()); | 650 return Math.parseDouble(valueToken.value.slowToString()); |
| 651 } catch (BadNumberFormatException ex) { | 651 } catch (BadNumberFormatException ex) { |
| 652 (this.handler)(token, ex); | 652 (this.handler)(token, ex); |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 | 655 |
| 656 accept(Visitor visitor) => visitor.visitLiteralDouble(this); | 656 accept(Visitor visitor) => visitor.visitLiteralDouble(this); |
| 657 } | 657 } |
| 658 | 658 |
| 659 class LiteralBool extends Literal<bool> { | 659 class LiteralBool extends Literal<bool> { |
| 660 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); | 660 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 token = token.next.next; | 1373 token = token.next.next; |
| 1374 } | 1374 } |
| 1375 Link<Token> recursiveGetCases(Token token, Link<Expression> expressions) { | 1375 Link<Token> recursiveGetCases(Token token, Link<Expression> expressions) { |
| 1376 if (token.stringValue === 'case') { | 1376 if (token.stringValue === 'case') { |
| 1377 Token colon = expressions.head.getEndToken().next; | 1377 Token colon = expressions.head.getEndToken().next; |
| 1378 return new Link<Token>(token, | 1378 return new Link<Token>(token, |
| 1379 recursiveGetCases(colon.next, expressions.tail)); | 1379 recursiveGetCases(colon.next, expressions.tail)); |
| 1380 } | 1380 } |
| 1381 return const EmptyLink<Token>(); | 1381 return const EmptyLink<Token>(); |
| 1382 } | 1382 } |
| 1383 return recursiveGetCases(token, expressions); | 1383 return recursiveGetCases(token, expressions.nodes); |
| 1384 } | 1384 } |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 class GotoStatement extends Statement { | 1387 class GotoStatement extends Statement { |
| 1388 final Identifier target; | 1388 final Identifier target; |
| 1389 final Token keywordToken; | 1389 final Token keywordToken; |
| 1390 final Token semicolonToken; | 1390 final Token semicolonToken; |
| 1391 | 1391 |
| 1392 GotoStatement(this.target, this.keywordToken, this.semicolonToken); | 1392 GotoStatement(this.target, this.keywordToken, this.semicolonToken); |
| 1393 | 1393 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 * argument). | 1680 * argument). |
| 1681 * | 1681 * |
| 1682 * TODO(ahe): This method is controversial, the team needs to discuss | 1682 * TODO(ahe): This method is controversial, the team needs to discuss |
| 1683 * if top-level methods are acceptable and what naming conventions to | 1683 * if top-level methods are acceptable and what naming conventions to |
| 1684 * use. | 1684 * use. |
| 1685 */ | 1685 */ |
| 1686 initializerDo(Node node, f(Node node)) { | 1686 initializerDo(Node node, f(Node node)) { |
| 1687 SendSet send = node.asSendSet(); | 1687 SendSet send = node.asSendSet(); |
| 1688 if (send !== null) return f(send.arguments.head); | 1688 if (send !== null) return f(send.arguments.head); |
| 1689 } | 1689 } |
| OLD | NEW |