Chromium Code Reviews| 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 /// References to classes or constants are wrapped into functions (that are | |
|
floitsch
2015/01/29 17:06:31
I'm not yet 100% sure of these claims. If necessar
floitsch
2015/01/29 17:12:18
Already updated...
| |
| 45 /// only executed at runtime). It is safe to emit the data before classes | |
| 46 /// and constants are completely set up. In fact, the data must be emitted | |
| 47 /// before any class (including constant) is constructed. | |
| 48 /// | |
| 49 /// Note: the metadata is derived from the task's `metadataCollector`. The | |
| 50 /// list must not be emitted before all operations on it are done. For | |
| 51 /// example, the old emitter generates metadata when emitting reflection | |
| 52 /// data. | |
| 53 List<String> get metadata => _metadataCollector.globalMetadata; | |
| 54 | |
| 34 bool get isSplit => fragments.length > 1; | 55 bool get isSplit => fragments.length > 1; |
| 35 Iterable<Fragment> get deferredFragments => fragments.skip(1); | 56 Iterable<Fragment> get deferredFragments => fragments.skip(1); |
| 36 } | 57 } |
| 37 | 58 |
| 38 /** | 59 /** |
| 39 * This class represents a JavaScript object that contains static state, like | 60 * This class represents a JavaScript object that contains static state, like |
| 40 * classes or functions. | 61 * classes or functions. |
| 41 */ | 62 */ |
| 42 class Holder { | 63 class Holder { |
| 43 final String name; | 64 final String name; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 canBeApplied : canBeApplied, | 399 canBeApplied : canBeApplied, |
| 379 canBeReflected : canBeReflected, | 400 canBeReflected : canBeReflected, |
| 380 needsStubs : needsStubs); | 401 needsStubs : needsStubs); |
| 381 } | 402 } |
| 382 | 403 |
| 383 class StaticStubMethod extends StubMethod { | 404 class StaticStubMethod extends StubMethod { |
| 384 Holder holder; | 405 Holder holder; |
| 385 StaticStubMethod(String name, this.holder, js.Expression code) | 406 StaticStubMethod(String name, this.holder, js.Expression code) |
| 386 : super(name, code); | 407 : super(name, code); |
| 387 } | 408 } |
| OLD | NEW |