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

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

Issue 1201983002: Implement try/finally by inlining the finally code. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Merge, rebase test expectations. Created 5 years, 6 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
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 422 }
423 ir.Primitive value = visit(node.expression); 423 ir.Primitive value = visit(node.expression);
424 JumpTarget target = elements.getTargetDefinition(node); 424 JumpTarget target = elements.getTargetDefinition(node);
425 Element error = 425 Element error =
426 (compiler.backend as JavaScriptBackend).getFallThroughError(); 426 (compiler.backend as JavaScriptBackend).getFallThroughError();
427 irBuilder.buildSimpleSwitch(target, value, cases, defaultCase, error, 427 irBuilder.buildSimpleSwitch(target, value, cases, defaultCase, error,
428 sourceInformationBuilder.buildGeneric(node)); 428 sourceInformationBuilder.buildGeneric(node));
429 } 429 }
430 430
431 visitTryStatement(ast.TryStatement node) { 431 visitTryStatement(ast.TryStatement node) {
432 // Finally blocks are not yet implemented. 432 // Try/catch/finally is not yet implemented.
433 if (node.finallyBlock != null) { 433 if (!node.catchBlocks.isEmpty && node.finallyBlock != null) {
434 return giveup(node, 'try/finally'); 434 return giveup(node, 'try/catch/finally');
435 } 435 }
436 436
437 List<CatchClauseInfo> catchClauseInfos = <CatchClauseInfo>[]; 437 List<CatchClauseInfo> catchClauseInfos = <CatchClauseInfo>[];
438 for (ast.CatchBlock catchClause in node.catchBlocks.nodes) { 438 for (ast.CatchBlock catchClause in node.catchBlocks.nodes) {
439 assert(catchClause.exception != null); 439 assert(catchClause.exception != null);
440 LocalVariableElement exceptionVariable = elements[catchClause.exception]; 440 LocalVariableElement exceptionVariable = elements[catchClause.exception];
441 LocalVariableElement stackTraceVariable; 441 LocalVariableElement stackTraceVariable;
442 if (catchClause.trace != null) { 442 if (catchClause.trace != null) {
443 stackTraceVariable = elements[catchClause.trace]; 443 stackTraceVariable = elements[catchClause.trace];
444 } 444 }
445 DartType type; 445 DartType type;
446 if (catchClause.onKeyword != null) { 446 if (catchClause.onKeyword != null) {
447 type = elements.getType(catchClause.type); 447 type = elements.getType(catchClause.type);
448 } 448 }
449 catchClauseInfos.add(new CatchClauseInfo( 449 catchClauseInfos.add(new CatchClauseInfo(
450 type: type, 450 type: type,
451 exceptionVariable: exceptionVariable, 451 exceptionVariable: exceptionVariable,
452 stackTraceVariable: stackTraceVariable, 452 stackTraceVariable: stackTraceVariable,
453 buildCatchBlock: subbuild(catchClause.block))); 453 buildCatchBlock: subbuild(catchClause.block)));
454 } 454 }
455 455
456 SubbuildFunction buildFinallyBlock =
457 node.finallyBlock == null ? null : subbuild(node.finallyBlock);
456 irBuilder.buildTry( 458 irBuilder.buildTry(
457 tryStatementInfo: tryStatements[node], 459 tryStatementInfo: tryStatements[node],
458 buildTryBlock: subbuild(node.tryBlock), 460 buildTryBlock: subbuild(node.tryBlock),
459 catchClauseInfos: catchClauseInfos, 461 catchClauseInfos: catchClauseInfos,
462 buildFinallyBlock: buildFinallyBlock,
460 closureClassMap: closureClassMap); 463 closureClassMap: closureClassMap);
461 } 464 }
462 465
463 // ## Expressions ## 466 // ## Expressions ##
464 ir.Primitive visitConditional(ast.Conditional node) { 467 ir.Primitive visitConditional(ast.Conditional node) {
465 return irBuilder.buildConditional( 468 return irBuilder.buildConditional(
466 build(node.condition), 469 build(node.condition),
467 subbuild(node.thenExpression), 470 subbuild(node.thenExpression),
468 subbuild(node.elseExpression)); 471 subbuild(node.elseExpression));
469 } 472 }
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 } 3189 }
3187 3190
3188 processSetStatic(ir.SetStatic node) { 3191 processSetStatic(ir.SetStatic node) {
3189 node.body = replacementFor(node.body); 3192 node.body = replacementFor(node.body);
3190 } 3193 }
3191 3194
3192 processContinuation(ir.Continuation node) { 3195 processContinuation(ir.Continuation node) {
3193 node.body = replacementFor(node.body); 3196 node.body = replacementFor(node.body);
3194 } 3197 }
3195 } 3198 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698