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

Side by Side Diff: pkg/compiler/lib/src/dart_backend/backend_ast_nodes.dart

Issue 923013002: dart2dart: Implementation of simple try/catch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed break/continue, incorporated comments. Created 5 years, 9 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library backend_ast_nodes; 5 library backend_ast_nodes;
6 6
7 import '../constants/values.dart' as values; 7 import '../constants/values.dart' as values;
8 import '../dart_types.dart' as types; 8 import '../dart_types.dart' as types;
9 import '../elements/elements.dart' as elements; 9 import '../elements/elements.dart' as elements;
10 import '../tree/tree.dart' as tree; 10 import '../tree/tree.dart' as tree;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 final List<CatchBlock> catchBlocks; 200 final List<CatchBlock> catchBlocks;
201 final Statement finallyBlock; 201 final Statement finallyBlock;
202 202
203 Try(this.tryBlock, this.catchBlocks, [this.finallyBlock]) { 203 Try(this.tryBlock, this.catchBlocks, [this.finallyBlock]) {
204 assert(catchBlocks.length > 0 || finallyBlock != null); 204 assert(catchBlocks.length > 0 || finallyBlock != null);
205 } 205 }
206 } 206 }
207 207
208 class CatchBlock extends Node { 208 class CatchBlock extends Node {
209 final TypeAnnotation onType; 209 final TypeAnnotation onType;
210 final String exceptionVar; 210 final VariableDeclaration exceptionVar;
211 final String stackVar; 211 final VariableDeclaration stackVar;
212 final Statement body; 212 final Statement body;
213 213
214 /// At least onType or exceptionVar must be given. 214 /// At least onType or exceptionVar must be given.
215 /// stackVar may only be given if exceptionVar is also given. 215 /// stackVar may only be given if exceptionVar is also given.
216 CatchBlock(this.body, {this.onType, this.exceptionVar, this.stackVar}) { 216 CatchBlock(this.body, {this.onType, this.exceptionVar, this.stackVar}) {
217 // Must specify at least a type or an exception binding. 217 // Must specify at least a type or an exception binding.
218 assert(onType != null || exceptionVar != null); 218 assert(onType != null || exceptionVar != null);
219 219
220 // We cannot bind the stack trace without binding the exception too. 220 // We cannot bind the stack trace without binding the exception too.
221 assert(stackVar == null || exceptionVar != null); 221 assert(stackVar == null || exceptionVar != null);
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 } else if (stmt is Try) { 1203 } else if (stmt is Try) {
1204 write('try'); 1204 write('try');
1205 writeBlock(stmt.tryBlock); 1205 writeBlock(stmt.tryBlock);
1206 for (CatchBlock block in stmt.catchBlocks) { 1206 for (CatchBlock block in stmt.catchBlocks) {
1207 if (block.onType != null) { 1207 if (block.onType != null) {
1208 write('on '); 1208 write('on ');
1209 writeType(block.onType); 1209 writeType(block.onType);
1210 } 1210 }
1211 if (block.exceptionVar != null) { 1211 if (block.exceptionVar != null) {
1212 write('catch('); 1212 write('catch(');
1213 write(block.exceptionVar); 1213 write(block.exceptionVar.name);
1214 if (block.stackVar != null) { 1214 if (block.stackVar != null) {
1215 write(','); 1215 write(',');
1216 write(block.stackVar); 1216 write(block.stackVar.name);
1217 } 1217 }
1218 write(')'); 1218 write(')');
1219 } 1219 }
1220 writeBlock(block.body); 1220 writeBlock(block.body);
1221 } 1221 }
1222 if (stmt.finallyBlock != null) { 1222 if (stmt.finallyBlock != null) {
1223 write('finally'); 1223 write('finally');
1224 writeBlock(stmt.finallyBlock); 1224 writeBlock(stmt.finallyBlock);
1225 } 1225 }
1226 } else if (stmt is VariableDeclarations) { 1226 } else if (stmt is VariableDeclarations) {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 final StringChunk previous; 1570 final StringChunk previous;
1571 final tree.StringQuoting quoting; 1571 final tree.StringQuoting quoting;
1572 num cost; 1572 num cost;
1573 1573
1574 OpenStringChunk(this.previous, this.quoting, this.cost); 1574 OpenStringChunk(this.previous, this.quoting, this.cost);
1575 1575
1576 StringChunk end(int endIndex) { 1576 StringChunk end(int endIndex) {
1577 return new StringChunk(previous, quoting, endIndex); 1577 return new StringChunk(previous, quoting, endIndex);
1578 } 1578 }
1579 } 1579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698