| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The [ConstantHandler] keeps track of compile-time constants, | 8 * The [ConstantHandler] keeps track of compile-time constants, |
| 9 * initializations of global and static fields, and default values of | 9 * initializations of global and static fields, and default values of |
| 10 * optional parameters. | 10 * optional parameters. |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 return makeConstructedConstant(node, type, constructor, evaluateArguments); | 706 return makeConstructedConstant(node, type, constructor, evaluateArguments); |
| 707 } | 707 } |
| 708 | 708 |
| 709 Constant makeConstructedConstant( | 709 Constant makeConstructedConstant( |
| 710 Node node, InterfaceType type, FunctionElement constructor, | 710 Node node, InterfaceType type, FunctionElement constructor, |
| 711 List<Constant> getArguments(FunctionElement constructor)) { | 711 List<Constant> getArguments(FunctionElement constructor)) { |
| 712 if (constructor.isRedirectingFactory) { | 712 if (constructor.isRedirectingFactory) { |
| 713 type = constructor.computeTargetType(compiler, type); | 713 type = constructor.computeTargetType(compiler, type); |
| 714 } | 714 } |
| 715 | 715 |
| 716 constructor = constructor.redirectionTarget; | 716 FunctionElement target = constructor.redirectionTarget; |
| 717 if (target != null) { |
| 718 constructor = target; |
| 719 } else { |
| 720 constructor = constructor.defaultImplementation; |
| 721 } |
| 717 ClassElement classElement = constructor.getEnclosingClass(); | 722 ClassElement classElement = constructor.getEnclosingClass(); |
| 718 // The constructor must be an implementation to ensure that field | 723 // The constructor must be an implementation to ensure that field |
| 719 // initializers are handled correctly. | 724 // initializers are handled correctly. |
| 720 constructor = constructor.implementation; | 725 constructor = constructor.implementation; |
| 721 assert(invariant(node, constructor.isImplementation)); | 726 assert(invariant(node, constructor.isImplementation)); |
| 722 | 727 |
| 723 List<Constant> arguments = getArguments(constructor); | 728 List<Constant> arguments = getArguments(constructor); |
| 724 ConstructorEvaluator evaluator = | 729 ConstructorEvaluator evaluator = |
| 725 new ConstructorEvaluator(constructor, handler, compiler); | 730 new ConstructorEvaluator(constructor, handler, compiler); |
| 726 evaluator.evaluateConstructorFieldValues(arguments); | 731 evaluator.evaluateConstructorFieldValues(arguments); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 if (fieldValue == null) { | 955 if (fieldValue == null) { |
| 951 // Use the default value. | 956 // Use the default value. |
| 952 fieldValue = handler.compileConstant(field); | 957 fieldValue = handler.compileConstant(field); |
| 953 } | 958 } |
| 954 jsNewArguments.add(fieldValue); | 959 jsNewArguments.add(fieldValue); |
| 955 }, | 960 }, |
| 956 includeSuperAndInjectedMembers: true); | 961 includeSuperAndInjectedMembers: true); |
| 957 return jsNewArguments; | 962 return jsNewArguments; |
| 958 } | 963 } |
| 959 } | 964 } |
| OLD | NEW |