| 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.new_js_emitter.model; | 5 library dart2js.new_js_emitter.model; |
| 6 | 6 |
| 7 import '../js/js.dart' as js show Expression; | 7 import '../js/js.dart' as js show Expression; |
| 8 import '../constants/values.dart' show ConstantValue; | 8 import '../constants/values.dart' show ConstantValue; |
| 9 | 9 |
| 10 import '../deferred_load.dart' show OutputUnit; | 10 import '../deferred_load.dart' show OutputUnit; |
| 11 | 11 |
| 12 import 'js_emitter.dart' show MetadataCollector; |
| 13 |
| 12 import '../common.dart'; | 14 import '../common.dart'; |
| 13 | 15 |
| 14 class Program { | 16 class Program { |
| 15 final List<Fragment> fragments; | 17 final List<Fragment> fragments; |
| 16 final bool outputContainsConstantList; | 18 final bool outputContainsConstantList; |
| 17 final bool outputContainsNativeClasses; | 19 final bool outputContainsNativeClasses; |
| 18 /// A map from load id to the list of fragments that need to be loaded. | 20 /// A map from load id to the list of fragments that need to be loaded. |
| 19 final Map<String, List<Fragment>> loadMap; | 21 final Map<String, List<Fragment>> loadMap; |
| 20 | 22 |
| 21 // If this field is not `null` then its value must be emitted in the embedded | 23 // If this field is not `null` then its value must be emitted in the embedded |
| 22 // global `TYPE_TO_INTERCEPTOR_MAP`. The map references constants and classes. | 24 // global `TYPE_TO_INTERCEPTOR_MAP`. The map references constants and classes. |
| 23 final js.Expression typeToInterceptorMap; | 25 final js.Expression typeToInterceptorMap; |
| 24 | 26 |
| 27 // TODO(floitsch): we should store the metadata directly instead of storing |
| 28 // the collector. However, the old emitter still updates the data. |
| 29 final MetadataCollector _metadataCollector; |
| 30 |
| 25 Program(this.fragments, | 31 Program(this.fragments, |
| 26 this.loadMap, | 32 this.loadMap, |
| 27 this.typeToInterceptorMap, | 33 this.typeToInterceptorMap, |
| 34 this._metadataCollector, |
| 28 {this.outputContainsNativeClasses, | 35 {this.outputContainsNativeClasses, |
| 29 this.outputContainsConstantList}) { | 36 this.outputContainsConstantList}) { |
| 30 assert(outputContainsNativeClasses != null); | 37 assert(outputContainsNativeClasses != null); |
| 31 assert(outputContainsConstantList != null); | 38 assert(outputContainsConstantList != null); |
| 32 } | 39 } |
| 33 | 40 |
| 41 /// A list of pretty-printed JavaScript expressions. |
| 42 /// |
| 43 /// This list must be emitted in the `METADATA` embedded global. |
| 44 /// The list references constants and must hence be emitted after constants |
| 45 /// have been initialized. |
| 46 /// |
| 47 /// Note: the metadata is derived from the task's `metadataCollector`. The |
| 48 /// list must not be emitted before all operations on it are done. For |
| 49 /// example, the old emitter generates metadata when emitting reflection |
| 50 /// data. |
| 51 List<String> get metadata => _metadataCollector.globalMetadata; |
| 52 |
| 34 bool get isSplit => fragments.length > 1; | 53 bool get isSplit => fragments.length > 1; |
| 35 Iterable<Fragment> get deferredFragments => fragments.skip(1); | 54 Iterable<Fragment> get deferredFragments => fragments.skip(1); |
| 36 } | 55 } |
| 37 | 56 |
| 38 /** | 57 /** |
| 39 * This class represents a JavaScript object that contains static state, like | 58 * This class represents a JavaScript object that contains static state, like |
| 40 * classes or functions. | 59 * classes or functions. |
| 41 */ | 60 */ |
| 42 class Holder { | 61 class Holder { |
| 43 final String name; | 62 final String name; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 canBeApplied : canBeApplied, | 397 canBeApplied : canBeApplied, |
| 379 canBeReflected : canBeReflected, | 398 canBeReflected : canBeReflected, |
| 380 needsStubs : needsStubs); | 399 needsStubs : needsStubs); |
| 381 } | 400 } |
| 382 | 401 |
| 383 class StaticStubMethod extends StubMethod { | 402 class StaticStubMethod extends StubMethod { |
| 384 Holder holder; | 403 Holder holder; |
| 385 StaticStubMethod(String name, this.holder, js.Expression code) | 404 StaticStubMethod(String name, this.holder, js.Expression code) |
| 386 : super(name, code); | 405 : super(name, code); |
| 387 } | 406 } |
| OLD | NEW |