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 | 9 import '../../closure.dart' show |
10 ClosureClassElement; | 10 ClosureClassElement; |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 } | 831 } |
832 } | 832 } |
833 | 833 |
834 @override | 834 @override |
835 js.Expression visitTypeExpression(tree_ir.TypeExpression node) { | 835 js.Expression visitTypeExpression(tree_ir.TypeExpression node) { |
836 List<js.Expression> arguments = visitExpressionList(node.arguments); | 836 List<js.Expression> arguments = visitExpressionList(node.arguments); |
837 return glue.generateTypeRepresentation(node.dartType, arguments, registry); | 837 return glue.generateTypeRepresentation(node.dartType, arguments, registry); |
838 } | 838 } |
839 | 839 |
840 js.Node handleForeignCode(tree_ir.ForeignCode node) { | 840 js.Node handleForeignCode(tree_ir.ForeignCode node) { |
841 registry.registerStaticUse(node.dependency); | 841 if (node.dependency != null) { |
| 842 // Dependency is only used if [node] calls a Dart function. Currently only |
| 843 // through foreign function `RAW_DART_FUNCTION_REF`. |
| 844 registry.registerStaticUse(node.dependency); |
| 845 } |
842 // TODO(sra): Should this be in CodegenRegistry? | 846 // TODO(sra): Should this be in CodegenRegistry? |
843 glue.registerNativeBehavior(node.nativeBehavior, node); | 847 glue.registerNativeBehavior(node.nativeBehavior, node); |
844 return node.codeTemplate.instantiate(visitExpressionList(node.arguments)); | 848 return node.codeTemplate.instantiate(visitExpressionList(node.arguments)); |
845 } | 849 } |
846 | 850 |
847 @override | 851 @override |
848 js.Expression visitForeignExpression(tree_ir.ForeignExpression node) { | 852 js.Expression visitForeignExpression(tree_ir.ForeignExpression node) { |
849 return handleForeignCode(node); | 853 return handleForeignCode(node); |
850 } | 854 } |
851 | 855 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 void registerDefaultParameterValues(ExecutableElement element) { | 1045 void registerDefaultParameterValues(ExecutableElement element) { |
1042 if (element is! FunctionElement) return; | 1046 if (element is! FunctionElement) return; |
1043 FunctionElement function = element; | 1047 FunctionElement function = element; |
1044 if (function.isStatic) return; // Defaults are inlined at call sites. | 1048 if (function.isStatic) return; // Defaults are inlined at call sites. |
1045 function.functionSignature.forEachOptionalParameter((param) { | 1049 function.functionSignature.forEachOptionalParameter((param) { |
1046 ConstantValue constant = glue.getDefaultParameterValue(param); | 1050 ConstantValue constant = glue.getDefaultParameterValue(param); |
1047 registry.registerCompileTimeConstant(constant); | 1051 registry.registerCompileTimeConstant(constant); |
1048 }); | 1052 }); |
1049 } | 1053 } |
1050 } | 1054 } |
OLD | NEW |