| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 Iterable<VariableElement> getStaticNonFinalFieldsForEmission() { | 182 Iterable<VariableElement> getStaticNonFinalFieldsForEmission() { |
| 183 return initialVariableValues.keys.where((element) { | 183 return initialVariableValues.keys.where((element) { |
| 184 return element.kind == ElementKind.FIELD | 184 return element.kind == ElementKind.FIELD |
| 185 && !element.isInstanceMember() | 185 && !element.isInstanceMember() |
| 186 && !element.modifiers.isFinal() | 186 && !element.modifiers.isFinal() |
| 187 // The const fields are all either emitted elsewhere or inlined. | 187 // The const fields are all either emitted elsewhere or inlined. |
| 188 && !element.modifiers.isConst(); | 188 && !element.modifiers.isConst(); |
| 189 }); | 189 }); |
| 190 } | 190 } |
| 191 | 191 |
| 192 /** | |
| 193 * Returns an [Iterable] of static const fields that need to be initialized. | |
| 194 * The fields must be evaluated in order since they might depend on each | |
| 195 * other. | |
| 196 */ | |
| 197 Iterable<VariableElement> getStaticFinalFieldsForEmission() { | |
| 198 return initialVariableValues.keys.where((element) { | |
| 199 return element.kind == ElementKind.FIELD | |
| 200 && !element.isInstanceMember() | |
| 201 && element.modifiers.isFinal(); | |
| 202 }); | |
| 203 } | |
| 204 | |
| 205 List<VariableElement> getLazilyInitializedFieldsForEmission() { | 192 List<VariableElement> getLazilyInitializedFieldsForEmission() { |
| 206 return new List<VariableElement>.from(lazyStatics); | 193 return new List<VariableElement>.from(lazyStatics); |
| 207 } | 194 } |
| 208 | 195 |
| 209 /** | 196 /** |
| 210 * Returns a list of constants topologically sorted so that dependencies | 197 * Returns a list of constants topologically sorted so that dependencies |
| 211 * appear before the dependent constant. [preSortCompare] is a comparator | 198 * appear before the dependent constant. [preSortCompare] is a comparator |
| 212 * function that gives the constants a consistent order prior to the | 199 * function that gives the constants a consistent order prior to the |
| 213 * topological sort which gives the constants an ordering that is less | 200 * topological sort which gives the constants an ordering that is less |
| 214 * sensitive to perturbations in the source code. | 201 * sensitive to perturbations in the source code. |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 if (fieldValue == null) { | 947 if (fieldValue == null) { |
| 961 // Use the default value. | 948 // Use the default value. |
| 962 fieldValue = handler.compileConstant(field); | 949 fieldValue = handler.compileConstant(field); |
| 963 } | 950 } |
| 964 jsNewArguments.add(fieldValue); | 951 jsNewArguments.add(fieldValue); |
| 965 }, | 952 }, |
| 966 includeSuperAndInjectedMembers: true); | 953 includeSuperAndInjectedMembers: true); |
| 967 return jsNewArguments; | 954 return jsNewArguments; |
| 968 } | 955 } |
| 969 } | 956 } |
| OLD | NEW |