OLD | NEW |
---|---|
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 Loading... | |
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 use one of their type variables in | |
94 * 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) return; | |
ngeoffray
2013/02/27 12:36:28
Add a comment?
karlklose
2013/02/27 16:11:32
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) continue; | |
110 InterfaceType classType = type; | |
111 for (ClassElement cls in classesUsingChecks) { | |
112 // We need the type as instance of its superclass anyway, so we just | |
ngeoffray
2013/02/27 12:36:28
Remove tabs.
karlklose
2013/02/27 16:11:32
Done.
| |
113 // try to compute the substitution; if the result is [:null:], the | |
114 // classes are not related. | |
115 InterfaceType instance = classType.asInstanceOf(cls); | |
116 if (instance == null) continue; | |
117 Link<DartType> typeArguments = instance.typeArguments; | |
118 for (DartType argument in typeArguments) { | |
119 isChecks.add(argument); | |
120 } | |
121 } | |
122 } | |
123 } | |
91 } | 124 } |
92 | 125 |
93 class SelectorKind { | 126 class SelectorKind { |
94 final String name; | 127 final String name; |
95 const SelectorKind(this.name); | 128 const SelectorKind(this.name); |
96 | 129 |
97 static const SelectorKind GETTER = const SelectorKind('getter'); | 130 static const SelectorKind GETTER = const SelectorKind('getter'); |
98 static const SelectorKind SETTER = const SelectorKind('setter'); | 131 static const SelectorKind SETTER = const SelectorKind('setter'); |
99 static const SelectorKind CALL = const SelectorKind('call'); | 132 static const SelectorKind CALL = const SelectorKind('call'); |
100 static const SelectorKind OPERATOR = const SelectorKind('operator'); | 133 static const SelectorKind OPERATOR = const SelectorKind('operator'); |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 if (cls.isSubclassOf(other)) { | 564 if (cls.isSubclassOf(other)) { |
532 // Resolve an invocation of [element.name] on [self]. If it | 565 // Resolve an invocation of [element.name] on [self]. If it |
533 // is found, this selector is a candidate. | 566 // is found, this selector is a candidate. |
534 return hasElementIn(self, element) && appliesUntyped(element, compiler); | 567 return hasElementIn(self, element) && appliesUntyped(element, compiler); |
535 } | 568 } |
536 } | 569 } |
537 | 570 |
538 return false; | 571 return false; |
539 } | 572 } |
540 } | 573 } |
OLD | NEW |