| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 List<Constant> _buildConstants(LibrariesMap librariesMap) { | 193 List<Constant> _buildConstants(LibrariesMap librariesMap) { |
| 194 List<ConstantValue> constantValues = | 194 List<ConstantValue> constantValues = |
| 195 _task.outputConstantLists[librariesMap.outputUnit]; | 195 _task.outputConstantLists[librariesMap.outputUnit]; |
| 196 if (constantValues == null) return const <Constant>[]; | 196 if (constantValues == null) return const <Constant>[]; |
| 197 return constantValues.map((ConstantValue value) => _constants[value]) | 197 return constantValues.map((ConstantValue value) => _constants[value]) |
| 198 .toList(growable: false); | 198 .toList(growable: false); |
| 199 } | 199 } |
| 200 | 200 |
| 201 List<StaticField> _buildStaticNonFinalFields(LibrariesMap librariesMap) { | 201 List<StaticField> _buildStaticNonFinalFields(LibrariesMap librariesMap) { |
| 202 // TODO(floitsch): handle static non-final fields correctly with deferred | 202 List<VariableElement> staticNonFinalFields = |
| 203 // libraries. | 203 _task.outputStaticNonFinalFieldLists[librariesMap.outputUnit]; |
| 204 if (librariesMap != _registry.mainLibrariesMap) { | 204 if (staticNonFinalFields == null) return const <StaticField>[]; |
| 205 return const <StaticField>[]; | 205 |
| 206 } | 206 return staticNonFinalFields |
| 207 Iterable<VariableElement> staticNonFinalFields = | |
| 208 backend.constants.getStaticNonFinalFieldsForEmission(); | |
| 209 return Elements.sortedByPosition(staticNonFinalFields) | |
| 210 .map(_buildStaticField) | 207 .map(_buildStaticField) |
| 211 .toList(growable: false); | 208 .toList(growable: false); |
| 212 } | 209 } |
| 213 | 210 |
| 214 StaticField _buildStaticField(Element element) { | 211 StaticField _buildStaticField(Element element) { |
| 215 JavaScriptConstantCompiler handler = backend.constants; | 212 JavaScriptConstantCompiler handler = backend.constants; |
| 216 ConstantValue initialValue = handler.getInitialValueFor(element).value; | 213 ConstantValue initialValue = handler.getInitialValueFor(element).value; |
| 217 // TODO(zarah): The holder should not be registered during building of | 214 // TODO(zarah): The holder should not be registered during building of |
| 218 // a static field. | 215 // a static field. |
| 219 _registry.registerHolder(namer.globalObjectForConstant(initialValue)); | 216 _registry.registerHolder(namer.globalObjectForConstant(initialValue)); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 _registry.registerConstant(outputUnit, constantValue); | 756 _registry.registerConstant(outputUnit, constantValue); |
| 760 assert(!_constants.containsKey(constantValue)); | 757 assert(!_constants.containsKey(constantValue)); |
| 761 String name = namer.constantName(constantValue); | 758 String name = namer.constantName(constantValue); |
| 762 String constantObject = namer.globalObjectForConstant(constantValue); | 759 String constantObject = namer.globalObjectForConstant(constantValue); |
| 763 Holder holder = _registry.registerHolder(constantObject); | 760 Holder holder = _registry.registerHolder(constantObject); |
| 764 Constant constant = new Constant(name, holder, constantValue); | 761 Constant constant = new Constant(name, holder, constantValue); |
| 765 _constants[constantValue] = constant; | 762 _constants[constantValue] = constant; |
| 766 } | 763 } |
| 767 } | 764 } |
| 768 } | 765 } |
| OLD | NEW |