| 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 'model.dart'; | 7 import 'model.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../js/js.dart' as js; | 9 import '../js/js.dart' as js; |
| 10 | 10 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 JavaScriptConstantCompiler handler = backend.constants; | 154 JavaScriptConstantCompiler handler = backend.constants; |
| 155 ConstantValue initialValue = handler.getInitialValueFor(element).value; | 155 ConstantValue initialValue = handler.getInitialValueFor(element).value; |
| 156 js.Expression code = _task.emitter.constantReference(initialValue); | 156 js.Expression code = _task.emitter.constantReference(initialValue); |
| 157 String name = namer.getNameOfGlobalField(element); | 157 String name = namer.getNameOfGlobalField(element); |
| 158 bool isFinal = false; | 158 bool isFinal = false; |
| 159 bool isLazy = false; | 159 bool isLazy = false; |
| 160 return new StaticField(name, _registry.registerHolder(r'$'), code, | 160 return new StaticField(name, _registry.registerHolder(r'$'), code, |
| 161 isFinal, isLazy); | 161 isFinal, isLazy); |
| 162 } | 162 } |
| 163 | 163 |
| 164 List<StaticField> _buildStaticLazilyInitializedFields(Fragment fragment) { | |
| 165 JavaScriptConstantCompiler handler = backend.constants; | |
| 166 List<VariableElement> lazyFields = | |
| 167 handler.getLazilyInitializedFieldsForEmission(); | |
| 168 // TODO(floitsch): handle static lazy finals correctly with deferred | |
| 169 // libraries. | |
| 170 if (fragment != _registry.mainFragment) return const <StaticField>[]; | |
| 171 throw new UnimplementedError("lazy statics"); | |
| 172 } | |
| 173 | |
| 174 List<Library> _buildLibraries(Fragment fragment) { | 164 List<Library> _buildLibraries(Fragment fragment) { |
| 175 List<Library> libraries = new List<Library>(fragment.length); | 165 List<Library> libraries = new List<Library>(fragment.length); |
| 176 int count = 0; | 166 int count = 0; |
| 177 fragment.forEach((LibraryElement library, List<Element> elements) { | 167 fragment.forEach((LibraryElement library, List<Element> elements) { |
| 178 libraries[count++] = _buildLibrary(library, elements); | 168 libraries[count++] = _buildLibrary(library, elements); |
| 179 }); | 169 }); |
| 180 return libraries; | 170 return libraries; |
| 181 } | 171 } |
| 182 | 172 |
| 183 // Note that a library-element may have multiple [Library]s, if it is split | 173 // Note that a library-element may have multiple [Library]s, if it is split |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 for (ConstantValue constantValue in constantValues) { | 272 for (ConstantValue constantValue in constantValues) { |
| 283 assert(!_constants.containsKey(constantValue)); | 273 assert(!_constants.containsKey(constantValue)); |
| 284 String name = namer.constantName(constantValue); | 274 String name = namer.constantName(constantValue); |
| 285 String constantObject = namer.globalObjectForConstant(constantValue); | 275 String constantObject = namer.globalObjectForConstant(constantValue); |
| 286 Holder holder = _registry.registerHolder(constantObject); | 276 Holder holder = _registry.registerHolder(constantObject); |
| 287 Constant constant = new Constant(name, holder, constantValue); | 277 Constant constant = new Constant(name, holder, constantValue); |
| 288 _constants[constantValue] = constant; | 278 _constants[constantValue] = constant; |
| 289 }; | 279 }; |
| 290 } | 280 } |
| 291 } | 281 } |
| OLD | NEW |