| 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 dart2js.js_emitter.program_builder; | 5 library dart2js.js_emitter.program_builder; |
| 6 | 6 |
| 7 import 'js_emitter.dart' show computeMixinClass; | 7 import 'js_emitter.dart' show computeMixinClass; |
| 8 import 'model.dart'; | 8 import 'model.dart'; |
| 9 | 9 |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 Iterable<VariableElement> staticNonFinalFields = | 202 Iterable<VariableElement> staticNonFinalFields = |
| 203 backend.constants.getStaticNonFinalFieldsForEmission(); | 203 backend.constants.getStaticNonFinalFieldsForEmission(); |
| 204 return Elements.sortedByPosition(staticNonFinalFields) | 204 return Elements.sortedByPosition(staticNonFinalFields) |
| 205 .map(_buildStaticField) | 205 .map(_buildStaticField) |
| 206 .toList(growable: false); | 206 .toList(growable: false); |
| 207 } | 207 } |
| 208 | 208 |
| 209 StaticField _buildStaticField(Element element) { | 209 StaticField _buildStaticField(Element element) { |
| 210 JavaScriptConstantCompiler handler = backend.constants; | 210 JavaScriptConstantCompiler handler = backend.constants; |
| 211 ConstantValue initialValue = handler.getInitialValueFor(element).value; | 211 ConstantValue initialValue = handler.getInitialValueFor(element).value; |
| 212 // TODO(zarah): The holder should not be registered during building of |
| 213 // a static field. |
| 214 _registry.registerHolder(namer.globalObjectForConstant(initialValue)); |
| 212 js.Expression code = _task.emitter.constantReference(initialValue); | 215 js.Expression code = _task.emitter.constantReference(initialValue); |
| 213 String name = namer.getNameOfGlobalField(element); | 216 String name = namer.getNameOfGlobalField(element); |
| 214 bool isFinal = false; | 217 bool isFinal = false; |
| 215 bool isLazy = false; | 218 bool isLazy = false; |
| 216 return new StaticField(element, | 219 return new StaticField(element, |
| 217 name, _registry.registerHolder(r'$'), code, | 220 name, _registry.registerHolder(r'$'), code, |
| 218 isFinal, isLazy); | 221 isFinal, isLazy); |
| 219 } | 222 } |
| 220 | 223 |
| 221 List<StaticField> _buildStaticLazilyInitializedFields( | 224 List<StaticField> _buildStaticLazilyInitializedFields( |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 _registry.registerConstant(outputUnit, constantValue); | 661 _registry.registerConstant(outputUnit, constantValue); |
| 659 assert(!_constants.containsKey(constantValue)); | 662 assert(!_constants.containsKey(constantValue)); |
| 660 String name = namer.constantName(constantValue); | 663 String name = namer.constantName(constantValue); |
| 661 String constantObject = namer.globalObjectForConstant(constantValue); | 664 String constantObject = namer.globalObjectForConstant(constantValue); |
| 662 Holder holder = _registry.registerHolder(constantObject); | 665 Holder holder = _registry.registerHolder(constantObject); |
| 663 Constant constant = new Constant(name, holder, constantValue); | 666 Constant constant = new Constant(name, holder, constantValue); |
| 664 _constants[constantValue] = constant; | 667 _constants[constantValue] = constant; |
| 665 } | 668 } |
| 666 } | 669 } |
| 667 } | 670 } |
| OLD | NEW |