| 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript | 7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript |
| 8 /// backend. | 8 /// backend. |
| 9 /// | 9 /// |
| 10 /// Since this task needs to distinguish between frontend and backend constants | 10 /// Since this task needs to distinguish between frontend and backend constants |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 ConstantExpression compileVariableWithDefinitions( | 125 ConstantExpression compileVariableWithDefinitions( |
| 126 VariableElement element, TreeElements definitions, | 126 VariableElement element, TreeElements definitions, |
| 127 {bool isConst: false, bool checkType: true}) { | 127 {bool isConst: false, bool checkType: true}) { |
| 128 if (!isConst && lazyStatics.contains(element)) { | 128 if (!isConst && lazyStatics.contains(element)) { |
| 129 return null; | 129 return null; |
| 130 } | 130 } |
| 131 ConstantExpression value = super.compileVariableWithDefinitions( | 131 ConstantExpression value = super.compileVariableWithDefinitions( |
| 132 element, definitions, | 132 element, definitions, |
| 133 isConst: isConst, checkType: checkType); | 133 isConst: isConst, checkType: checkType); |
| 134 if (!isConst && value == null) { | 134 if (!isConst && value == null) { |
| 135 lazyStatics.add(element); | 135 registerLazyStatic(element); |
| 136 } | 136 } |
| 137 return value; | 137 return value; |
| 138 } | 138 } |
| 139 | 139 |
| 140 @override |
| 141 void registerLazyStatic(FieldElement element) { |
| 142 lazyStatics.add(element); |
| 143 } |
| 144 |
| 140 void addCompileTimeConstantForEmission(ConstantValue constant) { | 145 void addCompileTimeConstantForEmission(ConstantValue constant) { |
| 141 compiledConstants.add(constant); | 146 compiledConstants.add(constant); |
| 142 } | 147 } |
| 143 | 148 |
| 144 /** | 149 /** |
| 145 * Returns an [Iterable] of static non final fields that need to be | 150 * Returns an [Iterable] of static non final fields that need to be |
| 146 * initialized. The fields list must be evaluated in order since they might | 151 * initialized. The fields list must be evaluated in order since they might |
| 147 * depend on each other. | 152 * depend on each other. |
| 148 */ | 153 */ |
| 149 Iterable<VariableElement> getStaticNonFinalFieldsForEmission() { | 154 Iterable<VariableElement> getStaticNonFinalFieldsForEmission() { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // TODO(ahe): This doesn't belong here. Rename this class and generalize. | 313 // TODO(ahe): This doesn't belong here. Rename this class and generalize. |
| 309 var closureClassMap = constants | 314 var closureClassMap = constants |
| 310 .compiler.closureToClassMapper.closureMappingCache | 315 .compiler.closureToClassMapper.closureMappingCache |
| 311 .remove(node); | 316 .remove(node); |
| 312 if (closureClassMap != null) { | 317 if (closureClassMap != null) { |
| 313 closureClassMap | 318 closureClassMap |
| 314 .removeMyselfFrom(constants.compiler.enqueuer.codegen.universe); | 319 .removeMyselfFrom(constants.compiler.enqueuer.codegen.universe); |
| 315 } | 320 } |
| 316 } | 321 } |
| 317 } | 322 } |
| OLD | NEW |