| 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 '../../closure.dart' show ClosureClassElement; | 9 import '../../closure.dart' show ClosureClassElement; |
| 10 import '../../common/codegen.dart' show CodegenRegistry; | 10 import '../../common/codegen.dart' show CodegenRegistry; |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 } | 632 } |
| 633 | 633 |
| 634 @override | 634 @override |
| 635 void visitUnreachable(tree_ir.Unreachable node) { | 635 void visitUnreachable(tree_ir.Unreachable node) { |
| 636 // Output nothing. | 636 // Output nothing. |
| 637 // TODO(asgerf): Emit a throw/return to assist local analysis in the VM? | 637 // TODO(asgerf): Emit a throw/return to assist local analysis in the VM? |
| 638 } | 638 } |
| 639 | 639 |
| 640 @override | 640 @override |
| 641 void visitTry(tree_ir.Try node) { | 641 void visitTry(tree_ir.Try node) { |
| 642 void register(ClassElement classElement) { |
| 643 if (classElement == null) return; |
| 644 registry.registerInstantiatedClass(classElement); |
| 645 } |
| 646 // We might catch JavaScript exceptions. |
| 647 register(glue.jsPlainJavaScriptObjectClass); |
| 648 register(glue.jsUnknownJavaScriptObjectClass); |
| 649 |
| 642 js.Block tryBlock = buildBodyBlock(node.tryBody); | 650 js.Block tryBlock = buildBodyBlock(node.tryBody); |
| 643 tree_ir.Variable exceptionVariable = node.catchParameters.first; | 651 tree_ir.Variable exceptionVariable = node.catchParameters.first; |
| 644 js.VariableDeclaration exceptionParameter = | 652 js.VariableDeclaration exceptionParameter = |
| 645 new js.VariableDeclaration(getVariableName(exceptionVariable)); | 653 new js.VariableDeclaration(getVariableName(exceptionVariable)); |
| 646 js.Block catchBlock = buildBodyBlock(node.catchBody); | 654 js.Block catchBlock = buildBodyBlock(node.catchBody); |
| 647 js.Catch catchPart = new js.Catch(exceptionParameter, catchBlock); | 655 js.Catch catchPart = new js.Catch(exceptionParameter, catchBlock); |
| 648 accumulator.add(new js.Try(tryBlock, catchPart, null)); | 656 accumulator.add(new js.Try(tryBlock, catchPart, null)); |
| 649 } | 657 } |
| 650 | 658 |
| 651 @override | 659 @override |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 js.Expression visitAwait(tree_ir.Await node) { | 923 js.Expression visitAwait(tree_ir.Await node) { |
| 916 return new js.Await(visitExpression(node.input)); | 924 return new js.Await(visitExpression(node.input)); |
| 917 } | 925 } |
| 918 | 926 |
| 919 visitFunctionExpression(tree_ir.FunctionExpression node) { | 927 visitFunctionExpression(tree_ir.FunctionExpression node) { |
| 920 // FunctionExpressions are currently unused. | 928 // FunctionExpressions are currently unused. |
| 921 // We might need them if we want to emit raw JS nested functions. | 929 // We might need them if we want to emit raw JS nested functions. |
| 922 throw 'FunctionExpressions should not be used'; | 930 throw 'FunctionExpressions should not be used'; |
| 923 } | 931 } |
| 924 } | 932 } |
| OLD | NEW |