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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/universe/universe.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 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 library universe; 5 library universe;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../dart2jslib.dart'; 9 import '../dart2jslib.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return hasMatchingSelector(invokedSetters[member.name], member, compiler); 81 return hasMatchingSelector(invokedSetters[member.name], member, compiler);
82 } 82 }
83 83
84 bool hasFieldGetter(Element member, Compiler compiler) { 84 bool hasFieldGetter(Element member, Compiler compiler) {
85 return fieldGetters.contains(member); 85 return fieldGetters.contains(member);
86 } 86 }
87 87
88 bool hasFieldSetter(Element member, Compiler compiler) { 88 bool hasFieldSetter(Element member, Compiler compiler) {
89 return fieldSetters.contains(member); 89 return fieldSetters.contains(member);
90 } 90 }
91
92 /**
93 * Compute type arguments of classes that potentially use their type
ngeoffray 2013/02/26 14:11:37 Why potentially? We know they are for the resoluti
karlklose 2013/02/27 10:12:58 I meant it may use it, if the method containing it
94 * variables in is-checks and add the is-checks that they imply.
95 *
96 * This function must be called after all is-checks have been registered.
97 *
98 * TODO(karlklose): move these computations into a function producing an
99 * immutable datastructure.
100 */
101 void addImplicitChecks(Iterable<ClassElement> classesUsingChecks) {
102 if (!classesUsingChecks.isEmpty) {
ngeoffray 2013/02/26 14:11:37 How about: if (classesUsingChecks.isEmpty) return;
karlklose 2013/02/27 10:12:58 Done.
103 // Find all instantiated types that are a subtype of a class that uses
104 // one of its type arguments in an is-check and add the arguments to the
105 // set of is-checks.
106 // TODO(karlklose): replace this with code that uses a subtype lookup
107 // datastructure in the world.
108 for (DartType type in instantiatedTypes) {
109 if (type.kind != TypeKind.INTERFACE) {
110 continue;
111 }
112 InterfaceType classType = type;
113 for (ClassElement cls in classesUsingChecks) {
114 // We need the type as instance of its superclass anyway, so we just
115 // try to compute the substitution; if the result is [:null:], the
116 // classes are not related.
117 InterfaceType instance = classType.asInstanceOf(cls);
118 if (instance == null) continue;
119 Link<DartType> typeArguments = instance.typeArguments;
120 for (DartType argument in typeArguments) {
121 isChecks.add(argument);
122 }
123 }
124 }
125 }
126 }
91 } 127 }
92 128
93 class SelectorKind { 129 class SelectorKind {
94 final String name; 130 final String name;
95 const SelectorKind(this.name); 131 const SelectorKind(this.name);
96 132
97 static const SelectorKind GETTER = const SelectorKind('getter'); 133 static const SelectorKind GETTER = const SelectorKind('getter');
98 static const SelectorKind SETTER = const SelectorKind('setter'); 134 static const SelectorKind SETTER = const SelectorKind('setter');
99 static const SelectorKind CALL = const SelectorKind('call'); 135 static const SelectorKind CALL = const SelectorKind('call');
100 static const SelectorKind OPERATOR = const SelectorKind('operator'); 136 static const SelectorKind OPERATOR = const SelectorKind('operator');
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 if (cls.isSubclassOf(other)) { 567 if (cls.isSubclassOf(other)) {
532 // Resolve an invocation of [element.name] on [self]. If it 568 // Resolve an invocation of [element.name] on [self]. If it
533 // is found, this selector is a candidate. 569 // is found, this selector is a candidate.
534 return hasElementIn(self, element) && appliesUntyped(element, compiler); 570 return hasElementIn(self, element) && appliesUntyped(element, compiler);
535 } 571 }
536 } 572 }
537 573
538 return false; 574 return false;
539 } 575 }
540 } 576 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698