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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 12220011: Handle malformed types in catch-on. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 10 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
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.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) 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 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 4456 matching lines...) Expand 10 before | Expand all | Expand 10 after
4467 pushInvokeHelper1( 4467 pushInvokeHelper1(
4468 backend.getExceptionUnwrapper(), exception, HType.UNKNOWN); 4468 backend.getExceptionUnwrapper(), exception, HType.UNKNOWN);
4469 HInvokeStatic unwrappedException = pop(); 4469 HInvokeStatic unwrappedException = pop();
4470 tryInstruction.exception = exception; 4470 tryInstruction.exception = exception;
4471 Link<Node> link = node.catchBlocks.nodes; 4471 Link<Node> link = node.catchBlocks.nodes;
4472 4472
4473 void pushCondition(CatchBlock catchBlock) { 4473 void pushCondition(CatchBlock catchBlock) {
4474 if (catchBlock.onKeyword != null) { 4474 if (catchBlock.onKeyword != null) {
4475 DartType type = elements.getType(catchBlock.type); 4475 DartType type = elements.getType(catchBlock.type);
4476 if (type == null) { 4476 if (type == null) {
4477 compiler.cancel('On with unresolved type', 4477 compiler.internalError('On with no type', node: catchBlock.type);
4478 node: catchBlock.type);
4479 } 4478 }
4480 HInstruction condition = 4479 if (type.isMalformed) {
4481 new HIs(type, <HInstruction>[unwrappedException]); 4480 // TODO(johnniwinther): Handle malformed types in [HIs] instead.
4482 push(condition); 4481 HInstruction condition =
4483 } 4482 graph.addConstantBool(true, constantSystem);
4484 else { 4483 stack.add(condition);
4484 } else {
4485 HInstruction condition =
4486 new HIs(type, <HInstruction>[unwrappedException]);
4487 push(condition);
4488 }
4489 } else {
4485 VariableDefinitions declaration = catchBlock.formals.nodes.head; 4490 VariableDefinitions declaration = catchBlock.formals.nodes.head;
4486 HInstruction condition = null; 4491 HInstruction condition = null;
4487 if (declaration.type == null) { 4492 if (declaration.type == null) {
4488 condition = graph.addConstantBool(true, constantSystem); 4493 condition = graph.addConstantBool(true, constantSystem);
4489 stack.add(condition); 4494 stack.add(condition);
4490 } else { 4495 } else {
4491 // TODO(aprelev@gmail.com): Once old catch syntax is removed 4496 // TODO(aprelev@gmail.com): Once old catch syntax is removed
4492 // "if" condition above and this "else" branch should be deleted as 4497 // "if" condition above and this "else" branch should be deleted as
4493 // type of declared variable won't matter for the catch 4498 // type of declared variable won't matter for the catch
4494 // condition. 4499 // condition.
4495 DartType type = elements.getType(declaration.type); 4500 DartType type = elements.getType(declaration.type);
4496 if (type == null) { 4501 if (type == null) {
4497 compiler.cancel('Catch with unresolved type', node: catchBlock); 4502 compiler.cancel('Catch with unresolved type', node: catchBlock);
4498 } 4503 }
4499 condition = 4504 condition =
4500 new HIs(type, <HInstruction>[unwrappedException], nullOk: true); 4505 new HIs(type, <HInstruction>[unwrappedException], nullOk: true);
4501 push(condition); 4506 push(condition);
4502 } 4507 }
4503 } 4508 }
4504 } 4509 }
4505 4510
4506 void visitThen() { 4511 void visitThen() {
4507 CatchBlock catchBlock = link.head; 4512 CatchBlock catchBlock = link.head;
4508 link = link.tail; 4513 link = link.tail;
4514
4515 if (compiler.enableTypeAssertions) {
4516 // In checked mode: throw a type error if the on-catch type is
4517 // malformed.
4518 if (catchBlock.onKeyword != null) {
4519 DartType type = elements.getType(catchBlock.type);
4520 if (type != null && type.isMalformed) {
4521 String reasons = Types.fetchReasonsFromMalformedType(type);
4522 generateMalformedSubtypeError(node,
4523 unwrappedException, type, reasons);
4524 pop();
4525 return;
4526 }
4527 }
4528 }
4509 if (catchBlock.exception != null) { 4529 if (catchBlock.exception != null) {
4510 localsHandler.updateLocal(elements[catchBlock.exception], 4530 localsHandler.updateLocal(elements[catchBlock.exception],
4511 unwrappedException); 4531 unwrappedException);
4512 } 4532 }
4513 Node trace = catchBlock.trace; 4533 Node trace = catchBlock.trace;
4514 if (trace != null) { 4534 if (trace != null) {
4515 pushInvokeHelper1( 4535 pushInvokeHelper1(
4516 backend.getTraceFromException(), exception, HType.UNKNOWN); 4536 backend.getTraceFromException(), exception, HType.UNKNOWN);
4517 HInstruction traceInstruction = pop(); 4537 HInstruction traceInstruction = pop();
4518 localsHandler.updateLocal(elements[trace], traceInstruction); 4538 localsHandler.updateLocal(elements[trace], traceInstruction);
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
5072 new HSubGraphBlockInformation(elseBranch.graph)); 5092 new HSubGraphBlockInformation(elseBranch.graph));
5073 5093
5074 HBasicBlock conditionStartBlock = conditionBranch.block; 5094 HBasicBlock conditionStartBlock = conditionBranch.block;
5075 conditionStartBlock.setBlockFlow(info, joinBlock); 5095 conditionStartBlock.setBlockFlow(info, joinBlock);
5076 SubGraph conditionGraph = conditionBranch.graph; 5096 SubGraph conditionGraph = conditionBranch.graph;
5077 HIf branch = conditionGraph.end.last; 5097 HIf branch = conditionGraph.end.last;
5078 assert(branch is HIf); 5098 assert(branch is HIf);
5079 branch.blockInformation = conditionStartBlock.blockFlow; 5099 branch.blockInformation = conditionStartBlock.blockFlow;
5080 } 5100 }
5081 } 5101 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698