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