| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 code_generator; | 5 library code_generator; |
| 6 | 6 |
| 7 import 'glue.dart'; | 7 import 'glue.dart'; |
| 8 | 8 |
| 9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; | 9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; |
| 10 import '../../js/js.dart' as js; | 10 import '../../js/js.dart' as js; |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 accumulator.add( | 518 accumulator.add( |
| 519 buildWhile(new js.LiteralBool(true), node.body, node.label, node)); | 519 buildWhile(new js.LiteralBool(true), node.body, node.label, node)); |
| 520 } | 520 } |
| 521 | 521 |
| 522 @override | 522 @override |
| 523 void visitReturn(tree_ir.Return node) { | 523 void visitReturn(tree_ir.Return node) { |
| 524 accumulator.add(new js.Return(visitExpression(node.value))); | 524 accumulator.add(new js.Return(visitExpression(node.value))); |
| 525 } | 525 } |
| 526 | 526 |
| 527 @override | 527 @override |
| 528 void visitThrow(tree_ir.Throw node) { |
| 529 accumulator.add(new js.Throw(visitExpression(node.value))); |
| 530 } |
| 531 |
| 532 @override |
| 533 void visitRethrow(tree_ir.Rethrow node) { |
| 534 glue.reportInternalError('rethrow seen in JavaScript output'); |
| 535 } |
| 536 |
| 537 @override |
| 528 void visitTry(tree_ir.Try node) { | 538 void visitTry(tree_ir.Try node) { |
| 529 js.Block tryBlock = buildBodyBlock(node.tryBody); | 539 js.Block tryBlock = buildBodyBlock(node.tryBody); |
| 530 tree_ir.Variable exceptionVariable = node.catchParameters.first; | 540 tree_ir.Variable exceptionVariable = node.catchParameters.first; |
| 531 js.VariableDeclaration exceptionParameter = | 541 js.VariableDeclaration exceptionParameter = |
| 532 new js.VariableDeclaration(getVariableName(exceptionVariable)); | 542 new js.VariableDeclaration(getVariableName(exceptionVariable)); |
| 533 js.Block catchBlock = buildBodyBlock(node.catchBody); | 543 js.Block catchBlock = buildBodyBlock(node.catchBody); |
| 534 js.Catch catchPart = new js.Catch(exceptionParameter, catchBlock); | 544 js.Catch catchPart = new js.Catch(exceptionParameter, catchBlock); |
| 535 accumulator.add(new js.Try(tryBlock, catchPart, null)); | 545 accumulator.add(new js.Try(tryBlock, catchPart, null)); |
| 536 } | 546 } |
| 537 | 547 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 | 650 |
| 641 @override | 651 @override |
| 642 visitVariableDeclaration(tree_ir.VariableDeclaration node) { | 652 visitVariableDeclaration(tree_ir.VariableDeclaration node) { |
| 643 return errorUnsupportedNode(node); | 653 return errorUnsupportedNode(node); |
| 644 } | 654 } |
| 645 | 655 |
| 646 errorUnsupportedNode(tree_ir.DartSpecificNode node) { | 656 errorUnsupportedNode(tree_ir.DartSpecificNode node) { |
| 647 throw "Unsupported node in JS backend: $node"; | 657 throw "Unsupported node in JS backend: $node"; |
| 648 } | 658 } |
| 649 } | 659 } |
| OLD | NEW |