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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 } |
OLD | NEW |