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

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: New implementation + test. 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') | tests/language/language.status » ('J')
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.cancel('On with no type', node: catchBlock.type);
ngeoffray 2013/02/18 15:48:35 cancel -> internalError ?
Johnni Winther 2013/02/19 07:08:54 Done.
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 =
4482 graph.addConstantBool(true, constantSystem);
4483 stack.add(condition);
4484 } else {
4485 HInstruction condition =
4486 new HIs(type, <HInstruction>[unwrappedException]);
4487 push(condition);
4488 }
4483 } 4489 }
4484 else { 4490 else {
ngeoffray 2013/02/18 15:48:35 Move else one line above.
Johnni Winther 2013/02/19 07:08:54 Done.
4485 VariableDefinitions declaration = catchBlock.formals.nodes.head; 4491 VariableDefinitions declaration = catchBlock.formals.nodes.head;
4486 HInstruction condition = null; 4492 HInstruction condition = null;
4487 if (declaration.type == null) { 4493 if (declaration.type == null) {
4488 condition = graph.addConstantBool(true, constantSystem); 4494 condition = graph.addConstantBool(true, constantSystem);
4489 stack.add(condition); 4495 stack.add(condition);
4490 } else { 4496 } else {
4491 // TODO(aprelev@gmail.com): Once old catch syntax is removed 4497 // TODO(aprelev@gmail.com): Once old catch syntax is removed
4492 // "if" condition above and this "else" branch should be deleted as 4498 // "if" condition above and this "else" branch should be deleted as
4493 // type of declared variable won't matter for the catch 4499 // type of declared variable won't matter for the catch
4494 // condition. 4500 // condition.
4495 DartType type = elements.getType(declaration.type); 4501 DartType type = elements.getType(declaration.type);
4496 if (type == null) { 4502 if (type == null) {
4497 compiler.cancel('Catch with unresolved type', node: catchBlock); 4503 compiler.cancel('Catch with unresolved type', node: catchBlock);
4498 } 4504 }
4499 condition = 4505 condition =
4500 new HIs(type, <HInstruction>[unwrappedException], nullOk: true); 4506 new HIs(type, <HInstruction>[unwrappedException], nullOk: true);
4501 push(condition); 4507 push(condition);
4502 } 4508 }
4503 } 4509 }
4504 } 4510 }
4505 4511
4506 void visitThen() { 4512 void visitThen() {
4507 CatchBlock catchBlock = link.head; 4513 CatchBlock catchBlock = link.head;
4508 link = link.tail; 4514 link = link.tail;
4515
4516 if (compiler.enableTypeAssertions) {
4517 // In checked mode: Throw a type error if the on-catch type is
ngeoffray 2013/02/18 15:48:35 Throw -> throw
Johnni Winther 2013/02/19 07:08:54 Done.
4518 // malformed.
4519 if (catchBlock.onKeyword != null) {
4520 DartType type = elements.getType(catchBlock.type);
4521 if (type != null && type.isMalformed) {
4522 String reasons = Types.fetchReasonsFromMalformedType(type);
4523 generateMalformedSubtypeError(node,
4524 unwrappedException, type, reasons);
4525 pop();
4526 return;
4527 }
4528 }
4529 }
4509 if (catchBlock.exception != null) { 4530 if (catchBlock.exception != null) {
4510 localsHandler.updateLocal(elements[catchBlock.exception], 4531 localsHandler.updateLocal(elements[catchBlock.exception],
4511 unwrappedException); 4532 unwrappedException);
4512 } 4533 }
4513 Node trace = catchBlock.trace; 4534 Node trace = catchBlock.trace;
4514 if (trace != null) { 4535 if (trace != null) {
4515 pushInvokeHelper1( 4536 pushInvokeHelper1(
4516 backend.getTraceFromException(), exception, HType.UNKNOWN); 4537 backend.getTraceFromException(), exception, HType.UNKNOWN);
4517 HInstruction traceInstruction = pop(); 4538 HInstruction traceInstruction = pop();
4518 localsHandler.updateLocal(elements[trace], traceInstruction); 4539 localsHandler.updateLocal(elements[trace], traceInstruction);
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
5072 new HSubGraphBlockInformation(elseBranch.graph)); 5093 new HSubGraphBlockInformation(elseBranch.graph));
5073 5094
5074 HBasicBlock conditionStartBlock = conditionBranch.block; 5095 HBasicBlock conditionStartBlock = conditionBranch.block;
5075 conditionStartBlock.setBlockFlow(info, joinBlock); 5096 conditionStartBlock.setBlockFlow(info, joinBlock);
5076 SubGraph conditionGraph = conditionBranch.graph; 5097 SubGraph conditionGraph = conditionBranch.graph;
5077 HIf branch = conditionGraph.end.last; 5098 HIf branch = conditionGraph.end.last;
5078 assert(branch is HIf); 5099 assert(branch is HIf);
5079 branch.blockInformation = conditionStartBlock.blockFlow; 5100 branch.blockInformation = conditionStartBlock.blockFlow;
5080 } 5101 }
5081 } 5102 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | tests/language/language.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698