Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: pkg/compiler/lib/src/world.dart

Issue 2981633002: Introduce TypedefEntity (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.world; 5 library dart2js.world;
6 6
7 import 'closure.dart' show ClosureClassElement; 7 import 'closure.dart' show ClosureClassElement;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'constants/constant_system.dart'; 9 import 'constants/constant_system.dart';
10 import 'common_elements.dart' show CommonElements, ElementEnvironment; 10 import 'common_elements.dart' show CommonElements, ElementEnvironment;
11 import 'elements/entities.dart'; 11 import 'elements/entities.dart';
12 import 'elements/elements.dart' 12 import 'elements/elements.dart'
13 show 13 show
14 ClassElement, 14 ClassElement,
15 Element, 15 Element,
16 MemberElement, 16 MemberElement,
17 MethodElement, 17 MethodElement,
18 MixinApplicationElement, 18 MixinApplicationElement;
19 TypedefElement;
20 import 'elements/resolution_types.dart'; 19 import 'elements/resolution_types.dart';
21 import 'elements/types.dart'; 20 import 'elements/types.dart';
22 import 'js_backend/backend_usage.dart' show BackendUsage; 21 import 'js_backend/backend_usage.dart' show BackendUsage;
23 import 'js_backend/interceptor_data.dart' show InterceptorData; 22 import 'js_backend/interceptor_data.dart' show InterceptorData;
24 import 'js_backend/native_data.dart' show NativeData; 23 import 'js_backend/native_data.dart' show NativeData;
25 import 'js_backend/runtime_types.dart' 24 import 'js_backend/runtime_types.dart'
26 show RuntimeTypesNeed, RuntimeTypesNeedBuilder; 25 show RuntimeTypesNeed, RuntimeTypesNeedBuilder;
27 import 'ordered_typeset.dart'; 26 import 'ordered_typeset.dart';
28 import 'options.dart'; 27 import 'options.dart';
29 import 'types/masks.dart' show CommonMasks, FlatTypeMask, TypeMask; 28 import 'types/masks.dart' show CommonMasks, FlatTypeMask, TypeMask;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 TypeMask getCachedMask(ClassEntity base, int flags, TypeMask createMask()); 285 TypeMask getCachedMask(ClassEntity base, int flags, TypeMask createMask());
287 286
288 /// Returns `true` if the field [element] is known to be effectively final. 287 /// Returns `true` if the field [element] is known to be effectively final.
289 bool fieldNeverChanges(MemberEntity element); 288 bool fieldNeverChanges(MemberEntity element);
290 289
291 /// Extends the receiver type [mask] for calling [selector] to take live 290 /// Extends the receiver type [mask] for calling [selector] to take live
292 /// `noSuchMethod` handlers into account. 291 /// `noSuchMethod` handlers into account.
293 TypeMask extendMaskIfReachesAll(Selector selector, TypeMask mask); 292 TypeMask extendMaskIfReachesAll(Selector selector, TypeMask mask);
294 293
295 /// Returns all resolved typedefs. 294 /// Returns all resolved typedefs.
296 Iterable<TypedefElement> get allTypedefs; 295 Iterable<TypedefEntity> get allTypedefs;
297 296
298 /// Returns the mask for the potential receivers of a dynamic call to 297 /// Returns the mask for the potential receivers of a dynamic call to
299 /// [selector] on [mask]. 298 /// [selector] on [mask].
300 /// 299 ///
301 /// This will narrow the constraints of [mask] to a [TypeMask] of the 300 /// This will narrow the constraints of [mask] to a [TypeMask] of the
302 /// set of classes that actually implement the selected member or implement 301 /// set of classes that actually implement the selected member or implement
303 /// the handling 'noSuchMethod' where the selected member is unimplemented. 302 /// the handling 'noSuchMethod' where the selected member is unimplemented.
304 TypeMask computeReceiverType(Selector selector, TypeMask mask); 303 TypeMask computeReceiverType(Selector selector, TypeMask mask);
305 304
306 /// Returns all the instance members that may be invoked with the 305 /// Returns all the instance members that may be invoked with the
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 380 }
382 381
383 abstract class OpenWorld implements World { 382 abstract class OpenWorld implements World {
384 /// Called to add [cls] to the set of known classes. 383 /// Called to add [cls] to the set of known classes.
385 /// 384 ///
386 /// This ensures that class hierarchy queries can be performed on [cls] and 385 /// This ensures that class hierarchy queries can be performed on [cls] and
387 /// classes that extend or implement it. 386 /// classes that extend or implement it.
388 void registerClass(covariant ClassEntity cls); 387 void registerClass(covariant ClassEntity cls);
389 388
390 void registerUsedElement(MemberEntity element); 389 void registerUsedElement(MemberEntity element);
391 void registerTypedef(TypedefElement typedef); 390 void registerTypedef(TypedefEntity typedef);
392 391
393 ClosedWorld closeWorld(); 392 ClosedWorld closeWorld();
394 393
395 /// Returns an iterable over all mixin applications that mixin [cls]. 394 /// Returns an iterable over all mixin applications that mixin [cls].
396 Iterable<ClassEntity> allMixinUsesOf(ClassEntity cls); 395 Iterable<ClassEntity> allMixinUsesOf(ClassEntity cls);
397 } 396 }
398 397
399 /// Enum values defining subset of classes included in queries. 398 /// Enum values defining subset of classes included in queries.
400 enum ClassQuery { 399 enum ClassQuery {
401 /// Only the class itself is included. 400 /// Only the class itself is included.
402 EXACT, 401 EXACT,
403 402
404 /// The class and all subclasses (transitively) are included. 403 /// The class and all subclasses (transitively) are included.
405 SUBCLASS, 404 SUBCLASS,
406 405
407 /// The class and all classes that implement or subclass it (transitively) 406 /// The class and all classes that implement or subclass it (transitively)
408 /// are included. 407 /// are included.
409 SUBTYPE, 408 SUBTYPE,
410 } 409 }
411 410
412 abstract class ClosedWorldBase implements ClosedWorld, ClosedWorldRefiner { 411 abstract class ClosedWorldBase implements ClosedWorld, ClosedWorldRefiner {
413 final ConstantSystem constantSystem; 412 final ConstantSystem constantSystem;
414 final NativeData nativeData; 413 final NativeData nativeData;
415 final InterceptorData interceptorData; 414 final InterceptorData interceptorData;
416 final BackendUsage backendUsage; 415 final BackendUsage backendUsage;
417 416
418 FunctionSet _allFunctions; 417 FunctionSet _allFunctions;
419 418
420 final Set<TypedefElement> _allTypedefs; 419 final Set<TypedefEntity> _allTypedefs;
421 420
422 final Map<ClassEntity, Set<ClassEntity>> mixinUses; 421 final Map<ClassEntity, Set<ClassEntity>> mixinUses;
423 Map<ClassEntity, List<ClassEntity>> _liveMixinUses; 422 Map<ClassEntity, List<ClassEntity>> _liveMixinUses;
424 423
425 final Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses; 424 final Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses;
426 425
427 // We keep track of subtype and subclass relationships in four 426 // We keep track of subtype and subclass relationships in four
428 // distinct sets to make class hierarchy analysis faster. 427 // distinct sets to make class hierarchy analysis faster.
429 final Map<ClassEntity, ClassHierarchyNode> _classHierarchyNodes; 428 final Map<ClassEntity, ClassHierarchyNode> _classHierarchyNodes;
430 final Map<ClassEntity, ClassSet> _classSets; 429 final Map<ClassEntity, ClassSet> _classSets;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 this.dartTypes, 465 this.dartTypes,
467 this.commonElements, 466 this.commonElements,
468 this.constantSystem, 467 this.constantSystem,
469 this.nativeData, 468 this.nativeData,
470 this.interceptorData, 469 this.interceptorData,
471 this.backendUsage, 470 this.backendUsage,
472 Set<ClassEntity> implementedClasses, 471 Set<ClassEntity> implementedClasses,
473 this.liveNativeClasses, 472 this.liveNativeClasses,
474 this.liveInstanceMembers, 473 this.liveInstanceMembers,
475 this.assignedInstanceMembers, 474 this.assignedInstanceMembers,
476 Set<TypedefElement> allTypedefs, 475 Set<TypedefEntity> allTypedefs,
477 this.mixinUses, 476 this.mixinUses,
478 this.typesImplementedBySubclasses, 477 this.typesImplementedBySubclasses,
479 Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes, 478 Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes,
480 Map<ClassEntity, ClassSet> classSets) 479 Map<ClassEntity, ClassSet> classSets)
481 : this._implementedClasses = implementedClasses, 480 : this._implementedClasses = implementedClasses,
482 this._allTypedefs = allTypedefs, 481 this._allTypedefs = allTypedefs,
483 this._classHierarchyNodes = classHierarchyNodes, 482 this._classHierarchyNodes = classHierarchyNodes,
484 this._classSets = classSets { 483 this._classSets = classSets {
485 _commonMasks = new CommonMasks(this); 484 _commonMasks = new CommonMasks(this);
486 } 485 }
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 /// Returns [ClassSet] for [cls] used to model the extends and implements 1008 /// Returns [ClassSet] for [cls] used to model the extends and implements
1010 /// relations of known classes. 1009 /// relations of known classes.
1011 /// 1010 ///
1012 /// This method is only provided for testing. For queries on classes, use the 1011 /// This method is only provided for testing. For queries on classes, use the
1013 /// methods defined in [ClosedWorld]. 1012 /// methods defined in [ClosedWorld].
1014 ClassSet getClassSet(ClassEntity cls) { 1013 ClassSet getClassSet(ClassEntity cls) {
1015 assert(checkClass(cls)); 1014 assert(checkClass(cls));
1016 return _classSets[cls]; 1015 return _classSets[cls];
1017 } 1016 }
1018 1017
1019 Iterable<TypedefElement> get allTypedefs => _allTypedefs; 1018 Iterable<TypedefEntity> get allTypedefs => _allTypedefs;
1020 1019
1021 void _ensureFunctionSet() { 1020 void _ensureFunctionSet() {
1022 if (_allFunctions == null) { 1021 if (_allFunctions == null) {
1023 // [FunctionSet] is created lazily because it is not used when we switch 1022 // [FunctionSet] is created lazily because it is not used when we switch
1024 // from a frontend to a backend model before inference. 1023 // from a frontend to a backend model before inference.
1025 _allFunctions = new FunctionSet(liveInstanceMembers); 1024 _allFunctions = new FunctionSet(liveInstanceMembers);
1026 } 1025 }
1027 } 1026 }
1028 1027
1029 TypeMask computeReceiverType(Selector selector, TypeMask mask) { 1028 TypeMask computeReceiverType(Selector selector, TypeMask mask) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 ConstantSystem constantSystem, 1188 ConstantSystem constantSystem,
1190 NativeData nativeData, 1189 NativeData nativeData,
1191 InterceptorData interceptorData, 1190 InterceptorData interceptorData,
1192 BackendUsage backendUsage, 1191 BackendUsage backendUsage,
1193 ResolutionWorldBuilder resolutionWorldBuilder, 1192 ResolutionWorldBuilder resolutionWorldBuilder,
1194 RuntimeTypesNeedBuilder rtiNeedBuilder, 1193 RuntimeTypesNeedBuilder rtiNeedBuilder,
1195 Set<ClassEntity> implementedClasses, 1194 Set<ClassEntity> implementedClasses,
1196 Iterable<ClassEntity> liveNativeClasses, 1195 Iterable<ClassEntity> liveNativeClasses,
1197 Iterable<MemberEntity> liveInstanceMembers, 1196 Iterable<MemberEntity> liveInstanceMembers,
1198 Iterable<MemberEntity> assignedInstanceMembers, 1197 Iterable<MemberEntity> assignedInstanceMembers,
1199 Set<TypedefElement> allTypedefs, 1198 Set<TypedefEntity> allTypedefs,
1200 Map<ClassEntity, Set<ClassEntity>> mixinUses, 1199 Map<ClassEntity, Set<ClassEntity>> mixinUses,
1201 Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses, 1200 Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses,
1202 Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes, 1201 Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes,
1203 Map<ClassEntity, ClassSet> classSets}) 1202 Map<ClassEntity, ClassSet> classSets})
1204 : super( 1203 : super(
1205 elementEnvironment, 1204 elementEnvironment,
1206 dartTypes, 1205 dartTypes,
1207 commonElements, 1206 commonElements,
1208 constantSystem, 1207 constantSystem,
1209 nativeData, 1208 nativeData,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 void computeRtiNeed(ResolutionWorldBuilder resolutionWorldBuilder, 1342 void computeRtiNeed(ResolutionWorldBuilder resolutionWorldBuilder,
1344 RuntimeTypesNeedBuilder rtiNeedBuilder, 1343 RuntimeTypesNeedBuilder rtiNeedBuilder,
1345 {bool enableTypeAssertions}) { 1344 {bool enableTypeAssertions}) {
1346 _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed( 1345 _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed(
1347 resolutionWorldBuilder, this, 1346 resolutionWorldBuilder, this,
1348 enableTypeAssertions: enableTypeAssertions); 1347 enableTypeAssertions: enableTypeAssertions);
1349 } 1348 }
1350 1349
1351 RuntimeTypesNeed get rtiNeed => _rtiNeed; 1350 RuntimeTypesNeed get rtiNeed => _rtiNeed;
1352 } 1351 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698