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 visitCaseMatch(CaseMatch node); | 10 R visitCaseMatch(CaseMatch node); |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 class LiteralInt extends Literal<int> { | 655 class LiteralInt extends Literal<int> { |
656 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); | 656 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); |
657 | 657 |
658 LiteralInt asLiteralInt() => this; | 658 LiteralInt asLiteralInt() => this; |
659 | 659 |
660 int get value() { | 660 int get value() { |
661 try { | 661 try { |
662 Token valueToken = token; | 662 Token valueToken = token; |
663 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; | 663 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; |
664 return Math.parseInt(valueToken.value.slowToString()); | 664 return Math.parseInt(valueToken.value.slowToString()); |
665 } catch (BadNumberFormatException ex) { | 665 } catch (FormatException ex) { |
666 (this.handler)(token, ex); | 666 (this.handler)(token, ex); |
667 } | 667 } |
668 } | 668 } |
669 | 669 |
670 accept(Visitor visitor) => visitor.visitLiteralInt(this); | 670 accept(Visitor visitor) => visitor.visitLiteralInt(this); |
671 } | 671 } |
672 | 672 |
673 class LiteralDouble extends Literal<double> { | 673 class LiteralDouble extends Literal<double> { |
674 LiteralDouble(Token token, DecodeErrorHandler handler) | 674 LiteralDouble(Token token, DecodeErrorHandler handler) |
675 : super(token, handler); | 675 : super(token, handler); |
676 | 676 |
677 LiteralDouble asLiteralDouble() => this; | 677 LiteralDouble asLiteralDouble() => this; |
678 | 678 |
679 double get value() { | 679 double get value() { |
680 try { | 680 try { |
681 Token valueToken = token; | 681 Token valueToken = token; |
682 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; | 682 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; |
683 return Math.parseDouble(valueToken.value.slowToString()); | 683 return Math.parseDouble(valueToken.value.slowToString()); |
684 } catch (BadNumberFormatException ex) { | 684 } catch (FormatException ex) { |
685 (this.handler)(token, ex); | 685 (this.handler)(token, ex); |
686 } | 686 } |
687 } | 687 } |
688 | 688 |
689 accept(Visitor visitor) => visitor.visitLiteralDouble(this); | 689 accept(Visitor visitor) => visitor.visitLiteralDouble(this); |
690 } | 690 } |
691 | 691 |
692 class LiteralBool extends Literal<bool> { | 692 class LiteralBool extends Literal<bool> { |
693 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); | 693 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); |
694 | 694 |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 * argument). | 1749 * argument). |
1750 * | 1750 * |
1751 * TODO(ahe): This method is controversial, the team needs to discuss | 1751 * TODO(ahe): This method is controversial, the team needs to discuss |
1752 * if top-level methods are acceptable and what naming conventions to | 1752 * if top-level methods are acceptable and what naming conventions to |
1753 * use. | 1753 * use. |
1754 */ | 1754 */ |
1755 initializerDo(Node node, f(Node node)) { | 1755 initializerDo(Node node, f(Node node)) { |
1756 SendSet send = node.asSendSet(); | 1756 SendSet send = node.asSendSet(); |
1757 if (send !== null) return f(send.arguments.head); | 1757 if (send !== null) return f(send.arguments.head); |
1758 } | 1758 } |
OLD | NEW |