Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: lib/compiler/implementation/tree/nodes.dart

Issue 10891022: Update corelib/ and lib/ to use the new try-catch syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 toDebugString() { 107 toDebugString() {
108 return PrettyPrinter.prettyPrint(this); 108 return PrettyPrinter.prettyPrint(this);
109 } 109 }
110 110
111 String getObjectDescription() => super.toString(); 111 String getObjectDescription() => super.toString();
112 112
113 String unparse() { 113 String unparse() {
114 Unparser unparser = new Unparser(); 114 Unparser unparser = new Unparser();
115 try { 115 try {
116 return unparser.unparse(this); 116 return unparser.unparse(this);
117 } catch (var e, var trace) { 117 } catch (e, trace) {
118 print(trace); 118 print(trace);
119 return '<<unparse error: ${getObjectDescription()}: ${unparser.sb}>>'; 119 return '<<unparse error: ${getObjectDescription()}: ${unparser.sb}>>';
120 } 120 }
121 } 121 }
122 122
123 abstract Token getBeginToken(); 123 abstract Token getBeginToken();
124 124
125 abstract Token getEndToken(); 125 abstract Token getEndToken();
126 126
127 Block asBlock() => null; 127 Block asBlock() => null;
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 class LiteralInt extends Literal<int> { 658 class LiteralInt extends Literal<int> {
659 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); 659 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler);
660 660
661 LiteralInt asLiteralInt() => this; 661 LiteralInt asLiteralInt() => this;
662 662
663 int get value { 663 int get value {
664 try { 664 try {
665 Token valueToken = token; 665 Token valueToken = token;
666 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; 666 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next;
667 return parseInt(valueToken.value.slowToString()); 667 return parseInt(valueToken.value.slowToString());
668 } catch (FormatException ex) { 668 } on FormatException catch (ex) {
669 (this.handler)(token, ex); 669 (this.handler)(token, ex);
670 } 670 }
671 } 671 }
672 672
673 accept(Visitor visitor) => visitor.visitLiteralInt(this); 673 accept(Visitor visitor) => visitor.visitLiteralInt(this);
674 } 674 }
675 675
676 class LiteralDouble extends Literal<double> { 676 class LiteralDouble extends Literal<double> {
677 LiteralDouble(Token token, DecodeErrorHandler handler) 677 LiteralDouble(Token token, DecodeErrorHandler handler)
678 : super(token, handler); 678 : super(token, handler);
679 679
680 LiteralDouble asLiteralDouble() => this; 680 LiteralDouble asLiteralDouble() => this;
681 681
682 double get value { 682 double get value {
683 try { 683 try {
684 Token valueToken = token; 684 Token valueToken = token;
685 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; 685 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next;
686 return parseDouble(valueToken.value.slowToString()); 686 return parseDouble(valueToken.value.slowToString());
687 } catch (FormatException ex) { 687 } on FormatException catch (ex) {
688 (this.handler)(token, ex); 688 (this.handler)(token, ex);
689 } 689 }
690 } 690 }
691 691
692 accept(Visitor visitor) => visitor.visitLiteralDouble(this); 692 accept(Visitor visitor) => visitor.visitLiteralDouble(this);
693 } 693 }
694 694
695 class LiteralBool extends Literal<bool> { 695 class LiteralBool extends Literal<bool> {
696 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); 696 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler);
697 697
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 * argument). 1761 * argument).
1762 * 1762 *
1763 * TODO(ahe): This method is controversial, the team needs to discuss 1763 * TODO(ahe): This method is controversial, the team needs to discuss
1764 * if top-level methods are acceptable and what naming conventions to 1764 * if top-level methods are acceptable and what naming conventions to
1765 * use. 1765 * use.
1766 */ 1766 */
1767 initializerDo(Node node, f(Node node)) { 1767 initializerDo(Node node, f(Node node)) {
1768 SendSet send = node.asSendSet(); 1768 SendSet send = node.asSendSet();
1769 if (send !== null) return f(send.arguments.head); 1769 if (send !== null) return f(send.arguments.head);
1770 } 1770 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/tools/mini_parser.dart ('k') | lib/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698