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 '../constants/values.dart' show ConstantValue; | 7 import '../constants/values.dart' show ConstantValue; |
8 import '../deferred_load.dart' show OutputUnit; | 8 import '../deferred_load.dart' show OutputUnit; |
9 import '../elements/entities.dart'; | 9 import '../elements/entities.dart'; |
10 import '../js/js.dart' as js show Expression, Name, Statement, TokenFinalizer; | 10 import '../js/js.dart' as js show Expression, Name, Statement, TokenFinalizer; |
11 import 'js_emitter.dart' show MetadataCollector; | 11 import 'js_emitter.dart' show MetadataCollector; |
12 | 12 |
13 class Program { | 13 class Program { |
14 final List<Fragment> fragments; | 14 final List<Fragment> fragments; |
15 final List<Holder> holders; | 15 final List<Holder> holders; |
16 final bool outputContainsConstantList; | 16 final bool outputContainsConstantList; |
17 final bool needsNativeSupport; | 17 final bool needsNativeSupport; |
18 final bool hasIsolateSupport; | 18 final bool hasIsolateSupport; |
| 19 final bool hasSoftDeferredClasses; |
19 | 20 |
20 /// A map from load id to the list of fragments that need to be loaded. | 21 /// A map from load id to the list of fragments that need to be loaded. |
21 final Map<String, List<Fragment>> loadMap; | 22 final Map<String, List<Fragment>> loadMap; |
22 | 23 |
23 /// A map from names to strings. | 24 /// A map from names to strings. |
24 /// | 25 /// |
25 /// This map is needed to support `const Symbol` expressions; | 26 /// This map is needed to support `const Symbol` expressions; |
26 final Map<js.Name, String> symbolsMap; | 27 final Map<js.Name, String> symbolsMap; |
27 | 28 |
28 // If this field is not `null` then its value must be emitted in the embedded | 29 // If this field is not `null` then its value must be emitted in the embedded |
29 // global `TYPE_TO_INTERCEPTOR_MAP`. The map references constants and classes. | 30 // global `TYPE_TO_INTERCEPTOR_MAP`. The map references constants and classes. |
30 final js.Expression typeToInterceptorMap; | 31 final js.Expression typeToInterceptorMap; |
31 | 32 |
32 // TODO(floitsch): we should store the metadata directly instead of storing | 33 // TODO(floitsch): we should store the metadata directly instead of storing |
33 // the collector. However, the old emitter still updates the data. | 34 // the collector. However, the old emitter still updates the data. |
34 final MetadataCollector _metadataCollector; | 35 final MetadataCollector _metadataCollector; |
35 final Iterable<js.TokenFinalizer> finalizers; | 36 final Iterable<js.TokenFinalizer> finalizers; |
36 | 37 |
37 Program(this.fragments, this.holders, this.loadMap, this.symbolsMap, | 38 Program(this.fragments, this.holders, this.loadMap, this.symbolsMap, |
38 this.typeToInterceptorMap, this._metadataCollector, this.finalizers, | 39 this.typeToInterceptorMap, this._metadataCollector, this.finalizers, |
39 {this.needsNativeSupport, | 40 {this.needsNativeSupport, |
40 this.outputContainsConstantList, | 41 this.outputContainsConstantList, |
41 this.hasIsolateSupport}) { | 42 this.hasIsolateSupport, |
| 43 this.hasSoftDeferredClasses}) { |
42 assert(needsNativeSupport != null); | 44 assert(needsNativeSupport != null); |
43 assert(outputContainsConstantList != null); | 45 assert(outputContainsConstantList != null); |
44 assert(hasIsolateSupport != null); | 46 assert(hasIsolateSupport != null); |
45 } | 47 } |
46 | 48 |
47 /// A list of metadata expressions. | 49 /// A list of metadata expressions. |
48 /// | 50 /// |
49 /// This list must be emitted in the `METADATA` embedded global. | 51 /// This list must be emitted in the `METADATA` embedded global. |
50 /// The list references constants and must hence be emitted after constants | 52 /// The list references constants and must hence be emitted after constants |
51 /// have been initialized. | 53 /// have been initialized. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 227 |
226 /// noSuchMethod stubs in the special case that the class is Object. | 228 /// noSuchMethod stubs in the special case that the class is Object. |
227 final List<StubMethod> noSuchMethodStubs; | 229 final List<StubMethod> noSuchMethodStubs; |
228 final List<Field> staticFieldsForReflection; | 230 final List<Field> staticFieldsForReflection; |
229 final bool hasRtiField; // Per-instance runtime type information pseudo-field. | 231 final bool hasRtiField; // Per-instance runtime type information pseudo-field. |
230 final bool onlyForRti; | 232 final bool onlyForRti; |
231 final bool isDirectlyInstantiated; | 233 final bool isDirectlyInstantiated; |
232 final bool isNative; | 234 final bool isNative; |
233 final bool isClosureBaseClass; // Common base class for closures. | 235 final bool isClosureBaseClass; // Common base class for closures. |
234 | 236 |
| 237 /// Whether this class should be soft deferred. |
| 238 /// |
| 239 /// A soft-deferred class is only fully initialized at first instantiation. |
| 240 final bool isSoftDeferred; |
| 241 |
235 // If the class implements a function type, and the type is encoded in the | 242 // If the class implements a function type, and the type is encoded in the |
236 // metatada table, then this field contains the index into that field. | 243 // metatada table, then this field contains the index into that field. |
237 final js.Expression functionTypeIndex; | 244 final js.Expression functionTypeIndex; |
238 | 245 |
239 /// Whether the class must be evaluated eagerly. | 246 /// Whether the class must be evaluated eagerly. |
240 bool isEager = false; | 247 bool isEager = false; |
241 | 248 |
242 /// Leaf tags. See [NativeEmitter.prepareNativeClasses]. | 249 /// Leaf tags. See [NativeEmitter.prepareNativeClasses]. |
243 List<String> nativeLeafTags; | 250 List<String> nativeLeafTags; |
244 | 251 |
(...skipping 12 matching lines...) Expand all Loading... |
257 this.staticFieldsForReflection, | 264 this.staticFieldsForReflection, |
258 this.callStubs, | 265 this.callStubs, |
259 this.noSuchMethodStubs, | 266 this.noSuchMethodStubs, |
260 this.checkedSetters, | 267 this.checkedSetters, |
261 this.isChecks, | 268 this.isChecks, |
262 this.functionTypeIndex, | 269 this.functionTypeIndex, |
263 {this.hasRtiField, | 270 {this.hasRtiField, |
264 this.onlyForRti, | 271 this.onlyForRti, |
265 this.isDirectlyInstantiated, | 272 this.isDirectlyInstantiated, |
266 this.isNative, | 273 this.isNative, |
267 this.isClosureBaseClass}) { | 274 this.isClosureBaseClass, |
| 275 this.isSoftDeferred = false}) { |
268 assert(onlyForRti != null); | 276 assert(onlyForRti != null); |
269 assert(isDirectlyInstantiated != null); | 277 assert(isDirectlyInstantiated != null); |
270 assert(isNative != null); | 278 assert(isNative != null); |
271 assert(isClosureBaseClass != null); | 279 assert(isClosureBaseClass != null); |
272 } | 280 } |
273 | 281 |
274 bool get isMixinApplication => false; | 282 bool get isMixinApplication => false; |
275 Class get superclass => _superclass; | 283 Class get superclass => _superclass; |
276 | 284 |
277 void setSuperclass(Class superclass) { | 285 void setSuperclass(Class superclass) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 functionType: functionType); | 537 functionType: functionType); |
530 | 538 |
531 bool get isStatic => true; | 539 bool get isStatic => true; |
532 } | 540 } |
533 | 541 |
534 class StaticStubMethod extends StubMethod implements StaticMethod { | 542 class StaticStubMethod extends StubMethod implements StaticMethod { |
535 Holder holder; | 543 Holder holder; |
536 StaticStubMethod(js.Name name, this.holder, js.Expression code) | 544 StaticStubMethod(js.Name name, this.holder, js.Expression code) |
537 : super(name, code); | 545 : super(name, code); |
538 } | 546 } |
OLD | NEW |