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

Unified Diff: pkg/compiler/lib/src/universe/resolution_world_builder.dart

Issue 3011793002: Add types referenced in is-checks to the class hierarchy (Closed)
Patch Set: Add all resolved types in the program to the class hierarchy Created 3 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/corelib_2/corelib_2.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/universe/resolution_world_builder.dart
diff --git a/pkg/compiler/lib/src/universe/resolution_world_builder.dart b/pkg/compiler/lib/src/universe/resolution_world_builder.dart
index a2b023590561949a2a8f0be4a6b67f45f9ccd1cf..ae749a44fa1a63a4038d089830cf55ef389f01ae 100644
--- a/pkg/compiler/lib/src/universe/resolution_world_builder.dart
+++ b/pkg/compiler/lib/src/universe/resolution_world_builder.dart
@@ -319,6 +319,8 @@ abstract class ResolutionWorldBuilderBase
final Set<FieldEntity> fieldSetters = new Set<FieldEntity>();
final Set<DartType> isChecks = new Set<DartType>();
+ _ClassEnsurer _classEnsurer;
+
/// Set of all closures in the program. Used by the mirror tracking system
/// to find all live closure instances.
final Set<Local> localFunctions = new Set<Local>();
@@ -392,7 +394,9 @@ abstract class ResolutionWorldBuilderBase
this._backendUsageBuilder,
this._rtiNeedBuilder,
this._nativeResolutionEnqueuer,
- this.selectorConstraintsStrategy);
+ this.selectorConstraintsStrategy) {
+ _classEnsurer = new _ClassEnsurer(this);
+ }
Iterable<ClassEntity> get processedClasses => _processedClasses.keys
.where((cls) => _processedClasses[cls].isInstantiated);
@@ -944,6 +948,22 @@ abstract class ResolutionWorldBuilderBase
// variables to the super constructor.
forEachInstantiatedClass(addSubtypes);
+ instantiatedTypes.forEach((type) {
+ var callType = _dartTypes.getCallType(type);
+ if (callType != null) {
+ _classEnsurer.ensureClassesInType(callType);
+ }
+ });
+ localFunctions.forEach((function) {
+ _classEnsurer.ensureClassesInType(
+ _elementEnvironment.getLocalFunctionType(function));
+ });
+ isChecks.forEach(_classEnsurer.ensureClassesInType);
+ closurizedMembers.forEach((function) {
+ _classEnsurer
+ .ensureClassesInType(_elementEnvironment.getFunctionType(function));
+ });
+
_classHierarchyNodes.keys.toList().forEach(_ensureClassSet);
return typesImplementedBySubclasses;
@@ -1030,3 +1050,56 @@ abstract class KernelResolutionWorldBuilderBase
throw new UnimplementedError('KernelResolutionWorldBuilder.registerClass');
}
}
+
+// TODO(het): Make this have a type of BaseResolutionDartTypeVisitor<void, Null>
+class _ClassEnsurer extends BaseResolutionDartTypeVisitor<dynamic, Null> {
Siggi Cherem (dart-lang) 2017/09/05 18:20:33 consider adding a second TODO: to explain why you
Harry Terkelsen 2017/09/05 18:31:11 Done.
+ final ResolutionWorldBuilderBase worldBuilder;
+
+ _ClassEnsurer(this.worldBuilder);
+
+ void ensureClassesInType(DartType type) {
+ type.accept(this, null);
+ }
+
+ @override
+ visitType(DartType type, _) {}
+
+ @override
+ visitFunctionType(FunctionType type, _) {
+ type.returnType.accept(this, null);
+ type.parameterTypes.forEach((t) {
+ t.accept(this, null);
+ });
+ type.optionalParameterTypes.forEach((t) {
+ t.accept(this, null);
+ });
+ type.namedParameterTypes.forEach((t) {
+ t.accept(this, null);
+ });
+ }
+//
+// @override
+// visitGenericType(GenericType type, _) {
Siggi Cherem (dart-lang) 2017/09/05 18:20:33 delete?
Harry Terkelsen 2017/09/05 18:31:11 Done.
+// type.typeArguments.forEach((t) {
+// t.accept(this, null);
+// });
+// }
+
+ @override
+ visitInterfaceType(InterfaceType type, _) {
+ worldBuilder._ensureClassSet(type.element);
+ type.typeArguments.forEach((t) {
+ t.accept(this, null);
+ });
+ }
+
+ @override
+ visitTypedefType(TypedefType type, _) {
+ type.typeArguments.forEach((t) {
+ t.accept(this, null);
+ });
+ var functionType =
+ worldBuilder._elementEnvironment.getFunctionTypeOfTypedef(type.element);
+ functionType.accept(this, null);
+ }
+}
« no previous file with comments | « no previous file | tests/corelib_2/corelib_2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698