| OLD | NEW |
| 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 3188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3199 add(exception); | 3199 add(exception); |
| 3200 HInstruction oldRethrowableException = rethrowableException; | 3200 HInstruction oldRethrowableException = rethrowableException; |
| 3201 rethrowableException = exception; | 3201 rethrowableException = exception; |
| 3202 | 3202 |
| 3203 pushInvokeHelper1(interceptors.getExceptionUnwrapper(), exception); | 3203 pushInvokeHelper1(interceptors.getExceptionUnwrapper(), exception); |
| 3204 HInvokeStatic unwrappedException = pop(); | 3204 HInvokeStatic unwrappedException = pop(); |
| 3205 tryInstruction.exception = exception; | 3205 tryInstruction.exception = exception; |
| 3206 Link<Node> link = node.catchBlocks.nodes; | 3206 Link<Node> link = node.catchBlocks.nodes; |
| 3207 | 3207 |
| 3208 void pushCondition(CatchBlock catchBlock) { | 3208 void pushCondition(CatchBlock catchBlock) { |
| 3209 VariableDefinitions declaration = catchBlock.formals.nodes.head; | 3209 if (catchBlock.onKeyword != null) { |
| 3210 HInstruction condition = null; | 3210 Type type = elements.getType(catchBlock.type); |
| 3211 if (declaration.type == null) { | |
| 3212 condition = graph.addConstantBool(true); | |
| 3213 stack.add(condition); | |
| 3214 } else { | |
| 3215 Type type = elements.getType(declaration.type); | |
| 3216 if (type == null) { | 3211 if (type == null) { |
| 3217 compiler.cancel('Catch with unresolved type', node: catchBlock); | 3212 compiler.cancel('On with unresolved type', |
| 3213 node: catchBlock.type); |
| 3218 } | 3214 } |
| 3219 condition = new HIs(type, unwrappedException, nullOk: true); | 3215 HInstruction condition = new HIs(type, unwrappedException); |
| 3220 push(condition); | 3216 push(condition); |
| 3221 } | 3217 } |
| 3218 else { |
| 3219 VariableDefinitions declaration = catchBlock.formals.nodes.head; |
| 3220 HInstruction condition = null; |
| 3221 if (declaration.type == null) { |
| 3222 condition = graph.addConstantBool(true); |
| 3223 stack.add(condition); |
| 3224 } else { |
| 3225 // TODO(aprelev@gmail.com): Once old catch syntax is removed |
| 3226 // "if" condition above and this "else" branch should be deleted as |
| 3227 // type of declared variable won't matter for the catch |
| 3228 // condition |
| 3229 Type type = elements.getType(declaration.type); |
| 3230 if (type == null) { |
| 3231 compiler.cancel('Catch with unresolved type', node: catchBlock); |
| 3232 } |
| 3233 condition = new HIs(type, unwrappedException, nullOk: true); |
| 3234 push(condition); |
| 3235 } |
| 3236 } |
| 3222 } | 3237 } |
| 3223 | 3238 |
| 3224 void visitThen() { | 3239 void visitThen() { |
| 3225 CatchBlock catchBlock = link.head; | 3240 CatchBlock catchBlock = link.head; |
| 3226 link = link.tail; | 3241 link = link.tail; |
| 3227 localsHandler.updateLocal(elements[catchBlock.exception], | 3242 localsHandler.updateLocal(elements[catchBlock.exception], |
| 3228 unwrappedException); | 3243 unwrappedException); |
| 3229 Node trace = catchBlock.trace; | 3244 Node trace = catchBlock.trace; |
| 3230 if (trace != null) { | 3245 if (trace != null) { |
| 3231 pushInvokeHelper1(interceptors.getTraceFromException(), exception); | 3246 pushInvokeHelper1(interceptors.getTraceFromException(), exception); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3606 new HSubGraphBlockInformation(elseBranch.graph)); | 3621 new HSubGraphBlockInformation(elseBranch.graph)); |
| 3607 | 3622 |
| 3608 HBasicBlock conditionStartBlock = conditionBranch.block; | 3623 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 3609 conditionStartBlock.setBlockFlow(info, joinBlock); | 3624 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 3610 SubGraph conditionGraph = conditionBranch.graph; | 3625 SubGraph conditionGraph = conditionBranch.graph; |
| 3611 HIf branch = conditionGraph.end.last; | 3626 HIf branch = conditionGraph.end.last; |
| 3612 assert(branch is HIf); | 3627 assert(branch is HIf); |
| 3613 branch.blockInformation = conditionStartBlock.blockFlow; | 3628 branch.blockInformation = conditionStartBlock.blockFlow; |
| 3614 } | 3629 } |
| 3615 } | 3630 } |
| OLD | NEW |