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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1125813004: Support 'on T' catch clauses and multiple clauses. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 // 496 //
497 // Return without a subexpression is translated as if it were return null. 497 // Return without a subexpression is translated as if it were return null.
498 ir.Primitive visitReturn(ast.Return node) { 498 ir.Primitive visitReturn(ast.Return node) {
499 assert(irBuilder.isOpen); 499 assert(irBuilder.isOpen);
500 assert(invariant(node, node.beginToken.value != 'native')); 500 assert(invariant(node, node.beginToken.value != 'native'));
501 irBuilder.buildReturn(build(node.expression)); 501 irBuilder.buildReturn(build(node.expression));
502 return null; 502 return null;
503 } 503 }
504 504
505 visitTryStatement(ast.TryStatement node) { 505 visitTryStatement(ast.TryStatement node) {
506 // Multiple catch blocks are not yet implemented.
507 if (node.catchBlocks.isEmpty ||
508 !node.catchBlocks.nodes.tail.isEmpty) {
509 return giveup(node, 'not exactly one catch block');
510 }
511 // 'on T' catch blocks are not yet implemented.
512 if ((node.catchBlocks.nodes.head as ast.CatchBlock).onKeyword != null) {
513 return giveup(node, '"on T" catch block');
514 }
515 // Finally blocks are not yet implemented. 506 // Finally blocks are not yet implemented.
516 if (node.finallyBlock != null) { 507 if (node.finallyBlock != null) {
517 return giveup(node, 'try/finally'); 508 return giveup(node, 'try/finally');
518 } 509 }
519 510
520 List<CatchClauseInfo> catchClauseInfos = <CatchClauseInfo>[]; 511 List<CatchClauseInfo> catchClauseInfos = <CatchClauseInfo>[];
521 for (ast.CatchBlock catchClause in node.catchBlocks.nodes) { 512 for (ast.CatchBlock catchClause in node.catchBlocks.nodes) {
522 assert(catchClause.exception != null); 513 assert(catchClause.exception != null);
523 LocalVariableElement exceptionVariable = elements[catchClause.exception]; 514 LocalVariableElement exceptionVariable = elements[catchClause.exception];
524 LocalVariableElement stackTraceVariable; 515 LocalVariableElement stackTraceVariable;
525 if (catchClause.trace != null) { 516 if (catchClause.trace != null) {
526 stackTraceVariable = elements[catchClause.trace]; 517 stackTraceVariable = elements[catchClause.trace];
527 } 518 }
519 DartType type;
520 if (catchClause.onKeyword != null) {
521 type = elements.getType(catchClause.type);
522 }
528 catchClauseInfos.add(new CatchClauseInfo( 523 catchClauseInfos.add(new CatchClauseInfo(
524 type: type,
529 exceptionVariable: exceptionVariable, 525 exceptionVariable: exceptionVariable,
530 stackTraceVariable: stackTraceVariable, 526 stackTraceVariable: stackTraceVariable,
531 buildCatchBlock: subbuild(catchClause.block))); 527 buildCatchBlock: subbuild(catchClause.block)));
532 } 528 }
533 529
534 irBuilder.buildTry( 530 irBuilder.buildTry(
535 tryStatementInfo: tryStatements[node], 531 tryStatementInfo: tryStatements[node],
536 buildTryBlock: subbuild(node.tryBlock), 532 buildTryBlock: subbuild(node.tryBlock),
537 catchClauseInfos: catchClauseInfos); 533 catchClauseInfos: catchClauseInfos);
538 } 534 }
(...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 node.body = replacementFor(node.body); 2902 node.body = replacementFor(node.body);
2907 } 2903 }
2908 } 2904 }
2909 2905
2910 /// Visit a just-deleted subterm and unlink all [Reference]s in it. 2906 /// Visit a just-deleted subterm and unlink all [Reference]s in it.
2911 class RemovalVisitor extends ir.RecursiveVisitor { 2907 class RemovalVisitor extends ir.RecursiveVisitor {
2912 processReference(ir.Reference reference) { 2908 processReference(ir.Reference reference) {
2913 reference.unlink(); 2909 reference.unlink();
2914 } 2910 }
2915 } 2911 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698