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

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: Remove some obsolete code. 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..323f8d115147fb5eaae5fec893ed378f62a3b447 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> instantiatedAbstractClasses;
ngeoffray 2013/02/26 14:11:37 This name makes it think like it's an error. Maybe
karlklose 2013/02/27 10:12:58 Done.
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>(),
+ instantiatedAbstractClasses = new Set<ClassElement>(),
rtiDependencies = new Map<ClassElement, Set<ClassElement>>(),
allFunctions = new FullFunctionSet(compiler),
this.compiler = compiler;
@@ -60,7 +62,6 @@ class World {
// (3) subclasses of (2) and (3).
void potentiallyAddForRti(ClassElement cls) {
- if (cls.typeVariables.isEmpty) return;
ngeoffray 2013/02/26 14:11:37 Why are you removing this check?
karlklose 2013/02/27 10:12:58 That was an error. Restored.
if (classesNeedingRti.contains(cls)) return;
classesNeedingRti.add(cls);
@@ -79,14 +80,32 @@ class World {
}
}
+ Set<ClassElement> classesUsingTypeVariableTests = new Set<ClassElement>();
+ compiler.resolverWorld.isChecks.forEach((DartType type) {
+ if (type is TypeVariableType) {
ngeoffray 2013/02/26 14:11:37 Use the kind?
karlklose 2013/02/27 10:12:58 Done.
+ TypeVariableElement variable = type.element;
+ classesUsingTypeVariableTests.add(variable.enclosingElement);
+ }
+ });
+ compiler.resolverWorld.addImplicitChecks(classesUsingTypeVariableTests);
compiler.resolverWorld.isChecks.forEach((DartType type) {
if (type is InterfaceType) {
ngeoffray 2013/02/26 14:11:37 Use the kind?
karlklose 2013/02/27 10:12:58 Done.
InterfaceType itf = type;
if (!itf.isRaw) {
potentiallyAddForRti(itf.element);
}
+ } else if (type is TypeVariableType) {
ngeoffray 2013/02/26 14:11:37 USe the kind?
karlklose 2013/02/27 10:12:58 Done.
+ 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.
ngeoffray 2013/02/26 14:11:37 Isn't that in the rtiDependencies map? Thinking ab
karlklose 2013/02/27 10:12:58 How do we know the instantiated class (in general)
+ instantiatedAbstractClasses.forEach((ClassElement cls) {
+ potentiallyAddForRti(cls);
+ });
}
void registerMixinUse(MixinApplicationElement mixinApplication,
@@ -112,7 +131,8 @@ class World {
}
bool needsRti(ClassElement cls) {
- return classesNeedingRti.contains(cls) || compiler.enabledRuntimeType;
+ return classesNeedingRti.contains(cls) ||
+ compiler.enabledRuntimeType;
ngeoffray 2013/02/26 14:11:37 Fits in one line.
karlklose 2013/02/27 10:12:58 Done.
}
bool hasAnyUserDefinedGetter(Selector selector) {
@@ -170,4 +190,8 @@ class World {
.map((Element member) => member.getEnclosingClass())
.where((ClassElement holder) => !identical(holder, objectClass));
}
+
+ void registerInstantiatedAbstractClass(ClassElement cls) {
+ instantiatedAbstractClasses.add(cls);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698