OLD | NEW |
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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 } | 426 } |
427 ir.Primitive value = visit(node.expression); | 427 ir.Primitive value = visit(node.expression); |
428 JumpTarget target = elements.getTargetDefinition(node); | 428 JumpTarget target = elements.getTargetDefinition(node); |
429 Element error = | 429 Element error = |
430 (compiler.backend as JavaScriptBackend).getFallThroughError(); | 430 (compiler.backend as JavaScriptBackend).getFallThroughError(); |
431 irBuilder.buildSimpleSwitch(target, value, cases, defaultCase, error, | 431 irBuilder.buildSimpleSwitch(target, value, cases, defaultCase, error, |
432 sourceInformationBuilder.buildGeneric(node)); | 432 sourceInformationBuilder.buildGeneric(node)); |
433 } | 433 } |
434 | 434 |
435 visitTryStatement(ast.TryStatement node) { | 435 visitTryStatement(ast.TryStatement node) { |
436 // Finally blocks are not yet implemented. | 436 // Try/catch/finally is not yet implemented. |
437 if (node.finallyBlock != null) { | 437 if (!node.catchBlocks.isEmpty && node.finallyBlock != null) { |
438 return giveup(node, 'try/finally'); | 438 return giveup(node, 'try/catch/finally'); |
439 } | 439 } |
440 | 440 |
441 List<CatchClauseInfo> catchClauseInfos = <CatchClauseInfo>[]; | 441 List<CatchClauseInfo> catchClauseInfos = <CatchClauseInfo>[]; |
442 for (ast.CatchBlock catchClause in node.catchBlocks.nodes) { | 442 for (ast.CatchBlock catchClause in node.catchBlocks.nodes) { |
443 assert(catchClause.exception != null); | 443 assert(catchClause.exception != null); |
444 LocalVariableElement exceptionVariable = elements[catchClause.exception]; | 444 LocalVariableElement exceptionVariable = elements[catchClause.exception]; |
445 LocalVariableElement stackTraceVariable; | 445 LocalVariableElement stackTraceVariable; |
446 if (catchClause.trace != null) { | 446 if (catchClause.trace != null) { |
447 stackTraceVariable = elements[catchClause.trace]; | 447 stackTraceVariable = elements[catchClause.trace]; |
448 } | 448 } |
449 DartType type; | 449 DartType type; |
450 if (catchClause.onKeyword != null) { | 450 if (catchClause.onKeyword != null) { |
451 type = elements.getType(catchClause.type); | 451 type = elements.getType(catchClause.type); |
452 } | 452 } |
453 catchClauseInfos.add(new CatchClauseInfo( | 453 catchClauseInfos.add(new CatchClauseInfo( |
454 type: type, | 454 type: type, |
455 exceptionVariable: exceptionVariable, | 455 exceptionVariable: exceptionVariable, |
456 stackTraceVariable: stackTraceVariable, | 456 stackTraceVariable: stackTraceVariable, |
457 buildCatchBlock: subbuild(catchClause.block))); | 457 buildCatchBlock: subbuild(catchClause.block))); |
458 } | 458 } |
459 | 459 |
| 460 SubbuildFunction buildFinallyBlock = |
| 461 node.finallyBlock == null ? null : subbuild(node.finallyBlock); |
460 irBuilder.buildTry( | 462 irBuilder.buildTry( |
461 tryStatementInfo: tryStatements[node], | 463 tryStatementInfo: tryStatements[node], |
462 buildTryBlock: subbuild(node.tryBlock), | 464 buildTryBlock: subbuild(node.tryBlock), |
463 catchClauseInfos: catchClauseInfos, | 465 catchClauseInfos: catchClauseInfos, |
| 466 buildFinallyBlock: buildFinallyBlock, |
464 closureClassMap: closureClassMap); | 467 closureClassMap: closureClassMap); |
465 } | 468 } |
466 | 469 |
467 // ## Expressions ## | 470 // ## Expressions ## |
468 ir.Primitive visitConditional(ast.Conditional node) { | 471 ir.Primitive visitConditional(ast.Conditional node) { |
469 return irBuilder.buildConditional( | 472 return irBuilder.buildConditional( |
470 build(node.condition), | 473 build(node.condition), |
471 subbuild(node.thenExpression), | 474 subbuild(node.thenExpression), |
472 subbuild(node.elseExpression)); | 475 subbuild(node.elseExpression)); |
473 } | 476 } |
(...skipping 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3137 } | 3140 } |
3138 | 3141 |
3139 processSetStatic(ir.SetStatic node) { | 3142 processSetStatic(ir.SetStatic node) { |
3140 node.body = replacementFor(node.body); | 3143 node.body = replacementFor(node.body); |
3141 } | 3144 } |
3142 | 3145 |
3143 processContinuation(ir.Continuation node) { | 3146 processContinuation(ir.Continuation node) { |
3144 node.body = replacementFor(node.body); | 3147 node.body = replacementFor(node.body); |
3145 } | 3148 } |
3146 } | 3149 } |
OLD | NEW |