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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/world.dart

Issue 12334070: Support runtime check of function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Register dependency Created 7 years, 9 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 | Annotate | Revision Log
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 part of dart2js; 5 part of dart2js;
6 6
7 class World { 7 class World {
8 final Compiler compiler; 8 final Compiler compiler;
9 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses; 9 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses;
10 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses; 10 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // the calls of the list constructor whenever we determine that 123 // the calls of the list constructor whenever we determine that
124 // JSArray needs type arguments. 124 // JSArray needs type arguments.
125 compiler.backend.addBackendRtiDependencies(this); 125 compiler.backend.addBackendRtiDependencies(this);
126 // Compute the set of all classes that need runtime type information. 126 // Compute the set of all classes that need runtime type information.
127 compiler.resolverWorld.isChecks.forEach((DartType type) { 127 compiler.resolverWorld.isChecks.forEach((DartType type) {
128 if (type.kind == TypeKind.INTERFACE) { 128 if (type.kind == TypeKind.INTERFACE) {
129 InterfaceType itf = type; 129 InterfaceType itf = type;
130 if (!itf.isRaw) { 130 if (!itf.isRaw) {
131 potentiallyAddForRti(itf.element); 131 potentiallyAddForRti(itf.element);
132 } 132 }
133 } else if (type.kind == TypeKind.TYPE_VARIABLE) { 133 } else {
134 TypeVariableElement variable = type.element; 134 TypeVariableType typeVariable = type.typeVariableOccurrence;
135 potentiallyAddForRti(variable.enclosingElement); 135 if (typeVariable != null) {
136 TypeVariableElement variable = typeVariable.element;
137 potentiallyAddForRti(variable.enclosingElement);
ngeoffray 2013/03/13 09:30:46 Why wasn't the previous code for type variable goo
Johnni Winther 2013/03/22 07:30:24 This code handles both types [:T:] and [:void f(T
138 } else if (type.kind == TypeKind.FUNCTION) {
139 compiler.resolverWorld.closurizedMembers.forEach((Element member) {
140 DartType memberType = member.computeType(compiler);
141 typeVariable = memberType.typeVariableOccurrence;
142 if (typeVariable != null &&
143 compiler.types.isPotentialSubtype(memberType, type)) {
144 TypeVariableElement variable = typeVariable.element;
145 potentiallyAddForRti(variable.enclosingElement);
146 }
147 });
148 compiler.resolverWorld.callMethods.forEach((Element member) {
149 DartType memberType = member.computeType(compiler);
150 if (compiler.types.isPotentialSubtype(memberType, type)) {
151 potentiallyAddForRti(member.getEnclosingClass());
152 }
153 });
154 }
136 } 155 }
137 }); 156 });
138 // Add the classes that need RTI because they use a type variable as 157 // Add the classes that need RTI because they use a type variable as
139 // expression. 158 // expression.
140 classesUsingTypeVariableExpression.forEach(potentiallyAddForRti); 159 classesUsingTypeVariableExpression.forEach(potentiallyAddForRti);
141 } 160 }
142 161
143 Iterable<ClassElement> commonSupertypesOf(ClassElement x, ClassElement y) { 162 Iterable<ClassElement> commonSupertypesOf(ClassElement x, ClassElement y) {
144 Set<ClassElement> xSet = supertypes[x]; 163 Set<ClassElement> xSet = supertypes[x];
145 if (xSet == null) return const <ClassElement>[]; 164 if (xSet == null) return const <ClassElement>[];
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (mask != null) { 271 if (mask != null) {
253 noSuchMethodSelector = new TypedSelector(mask, noSuchMethodSelector); 272 noSuchMethodSelector = new TypedSelector(mask, noSuchMethodSelector);
254 } 273 }
255 ClassElement objectClass = compiler.objectClass; 274 ClassElement objectClass = compiler.objectClass;
256 return allFunctions 275 return allFunctions
257 .filter(noSuchMethodSelector) 276 .filter(noSuchMethodSelector)
258 .map((Element member) => member.getEnclosingClass()) 277 .map((Element member) => member.getEnclosingClass())
259 .where((ClassElement holder) => !identical(holder, objectClass)); 278 .where((ClassElement holder) => !identical(holder, objectClass));
260 } 279 }
261 } 280 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698