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

Unified Diff: sdk/lib/_internal/compiler/implementation/world.dart

Issue 12210142: Implement is-checks against type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 10 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
Index: sdk/lib/_internal/compiler/implementation/world.dart
diff --git a/sdk/lib/_internal/compiler/implementation/world.dart b/sdk/lib/_internal/compiler/implementation/world.dart
index 271629bf64132666df45a3b3aba08074886ca86e..4eafbf72229bb9f3388676120ff3c74955f66ccd 100644
--- a/sdk/lib/_internal/compiler/implementation/world.dart
+++ b/sdk/lib/_internal/compiler/implementation/world.dart
@@ -10,6 +10,7 @@ class World {
final Map<ClassElement, Set<MixinApplicationElement>> mixinUses;
final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses;
final Set<ClassElement> classesNeedingRti;
+ final Set<ClassElement> usedFactoriesOfAbstractClasses;
ngeoffray 2013/02/27 12:36:28 Store the factories instead, as implied by the nam
karlklose 2013/02/27 16:11:32 Obsolete.
final Map<ClassElement, Set<ClassElement>> rtiDependencies;
final FullFunctionSet allFunctions;
@@ -19,6 +20,7 @@ class World {
typesImplementedBySubclasses =
new Map<ClassElement, Set<ClassElement>>(),
classesNeedingRti = new Set<ClassElement>(),
+ usedFactoriesOfAbstractClasses = new Set<ClassElement>(),
rtiDependencies = new Map<ClassElement, Set<ClassElement>>(),
allFunctions = new FullFunctionSet(compiler),
this.compiler = compiler;
@@ -79,14 +81,32 @@ class World {
}
}
+ Set<ClassElement> classesUsingTypeVariableTests = new Set<ClassElement>();
compiler.resolverWorld.isChecks.forEach((DartType type) {
- if (type is InterfaceType) {
+ if (type.kind == TypeKind.TYPE_VARIABLE) {
+ TypeVariableElement variable = type.element;
+ classesUsingTypeVariableTests.add(variable.enclosingElement);
+ }
+ });
+ compiler.resolverWorld.addImplicitChecks(classesUsingTypeVariableTests);
+ compiler.resolverWorld.isChecks.forEach((DartType type) {
+ if (type.kind == TypeKind.INTERFACE) {
InterfaceType itf = type;
if (!itf.isRaw) {
potentiallyAddForRti(itf.element);
}
+ } else if (type.kind == TypeKind.TYPE_VARIABLE) {
+ TypeVariableElement variable = type.element;
+ potentiallyAddForRti(variable.enclosingElement);
}
});
+
+ // TODO(karlklose): if we know all targets of factories for the abstract
+ // class, we should check whether one of these targets needs runtime type
+ // information before adding the class.
+ usedFactoriesOfAbstractClasses.forEach((ClassElement cls) {
+ potentiallyAddForRti(cls);
+ });
}
void registerMixinUse(MixinApplicationElement mixinApplication,
@@ -170,4 +190,8 @@ class World {
.map((Element member) => member.getEnclosingClass())
.where((ClassElement holder) => !identical(holder, objectClass));
}
+
+ void registerUsedFactoriesOfAbstractClasses(ClassElement cls) {
+ usedFactoriesOfAbstractClasses.add(cls);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698