OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 kernel.class_hierarchy_basic; | 5 library kernel.class_hierarchy_basic; |
6 | 6 |
7 import 'package:kernel/type_algebra.dart'; | 7 import 'package:kernel/type_algebra.dart'; |
8 import 'package:kernel/ast.dart'; | 8 import 'package:kernel/ast.dart'; |
9 | 9 |
10 /// A simple implementation of the class hierarchy interface using | 10 /// A simple implementation of the class hierarchy interface using |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 void forEachOverridePair( | 39 void forEachOverridePair( |
40 Class class_, callback(Member member, Member superMember, bool setter)) { | 40 Class class_, callback(Member member, Member superMember, bool setter)) { |
41 void report(Member member, Member superMember, bool setter) { | 41 void report(Member member, Member superMember, bool setter) { |
42 if (!identical(member, superMember)) { | 42 if (!identical(member, superMember)) { |
43 callback(member, superMember, setter); | 43 callback(member, superMember, setter); |
44 } | 44 } |
45 } | 45 } |
| 46 |
46 // Report declared members overriding inheritable members. | 47 // Report declared members overriding inheritable members. |
47 for (var member in class_.mixin.members) { | 48 for (var member in class_.mixin.members) { |
48 for (var supertype in class_.supers) { | 49 for (var supertype in class_.supers) { |
49 if (member.hasGetter) { | 50 if (member.hasGetter) { |
50 for (var superMember | 51 for (var superMember |
51 in getInterfaceMembersByName(supertype.classNode, member.name)) { | 52 in getInterfaceMembersByName(supertype.classNode, member.name)) { |
52 report(member, superMember, false); | 53 report(member, superMember, false); |
53 } | 54 } |
54 } | 55 } |
55 if (member.hasSetter) { | 56 if (member.hasSetter) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (interfaceGettersAndCalls.containsKey(node)) return; | 166 if (interfaceGettersAndCalls.containsKey(node)) return; |
166 interfaceGettersAndCalls[node] = <Name, List<Member>>{}; | 167 interfaceGettersAndCalls[node] = <Name, List<Member>>{}; |
167 interfaceSetters[node] = <Name, List<Member>>{}; | 168 interfaceSetters[node] = <Name, List<Member>>{}; |
168 void inheritFrom(Supertype type) { | 169 void inheritFrom(Supertype type) { |
169 if (type == null) return; | 170 if (type == null) return; |
170 buildInterfaceTable(type.classNode); | 171 buildInterfaceTable(type.classNode); |
171 mergeMaps(interfaceGettersAndCalls[type.classNode], | 172 mergeMaps(interfaceGettersAndCalls[type.classNode], |
172 interfaceGettersAndCalls[node]); | 173 interfaceGettersAndCalls[node]); |
173 mergeMaps(interfaceSetters[type.classNode], interfaceSetters[node]); | 174 mergeMaps(interfaceSetters[type.classNode], interfaceSetters[node]); |
174 } | 175 } |
| 176 |
175 inheritFrom(node.supertype); | 177 inheritFrom(node.supertype); |
176 inheritFrom(node.mixedInType); | 178 inheritFrom(node.mixedInType); |
177 node.implementedTypes.forEach(inheritFrom); | 179 node.implementedTypes.forEach(inheritFrom); |
178 // Overwrite map entries with declared members. | 180 // Overwrite map entries with declared members. |
179 for (Procedure procedure in node.mixin.procedures) { | 181 for (Procedure procedure in node.mixin.procedures) { |
180 if (procedure.isStatic) continue; | 182 if (procedure.isStatic) continue; |
181 if (procedure.kind == ProcedureKind.Setter) { | 183 if (procedure.kind == ProcedureKind.Setter) { |
182 interfaceSetters[node][procedure.name] = <Member>[procedure]; | 184 interfaceSetters[node][procedure.name] = <Member>[procedure]; |
183 } else { | 185 } else { |
184 interfaceGettersAndCalls[node][procedure.name] = <Member>[procedure]; | 186 interfaceGettersAndCalls[node][procedure.name] = <Member>[procedure]; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 int getClassIndex(Class node) { | 246 int getClassIndex(Class node) { |
245 return classIndex[node]; | 247 return classIndex[node]; |
246 } | 248 } |
247 | 249 |
248 List<int> getExpenseHistogram() => <int>[]; | 250 List<int> getExpenseHistogram() => <int>[]; |
249 double getCompressionRatio() => 0.0; | 251 double getCompressionRatio() => 0.0; |
250 int getSuperTypeHashTableSize() => 0; | 252 int getSuperTypeHashTableSize() => 0; |
251 | 253 |
252 noSuchMethod(inv) => super.noSuchMethod(inv); | 254 noSuchMethod(inv) => super.noSuchMethod(inv); |
253 } | 255 } |
OLD | NEW |