| 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 class World { | 5 class World { |
| 6 final Compiler compiler; | 6 final Compiler compiler; |
| 7 final Map<ClassElement, Set<ClassElement>> subtypes; | 7 final Map<ClassElement, Set<ClassElement>> subtypes; |
| 8 final Set<ClassElement> classesNeedingRti; | 8 final Set<ClassElement> classesNeedingRti; |
| 9 final Map<ClassElement, Set<ClassElement>> rtiDependencies; | 9 final Map<ClassElement, Set<ClassElement>> rtiDependencies; |
| 10 final FunctionSet userDefinedGetters; | 10 final FunctionSet userDefinedGetters; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 compiler.resolverWorld.instantiatedClasses.forEach(addSubtypes); | 34 compiler.resolverWorld.instantiatedClasses.forEach(addSubtypes); |
| 35 | 35 |
| 36 // Find the classes that need runtime type information. Such | 36 // Find the classes that need runtime type information. Such |
| 37 // classes are: | 37 // classes are: |
| 38 // (1) used in a is check with type variables, | 38 // (1) used in a is check with type variables, |
| 39 // (2) dependencies of classes in (1), | 39 // (2) dependencies of classes in (1), |
| 40 // (3) subclasses of (2) and (3). | 40 // (3) subclasses of (2) and (3). |
| 41 | 41 |
| 42 void potentiallyAddForRti(ClassElement cls, Function callback) { | 42 void potentiallyAddForRti(ClassElement cls, Function callback) { |
| 43 if (cls.typeVariables.isEmpty()) return; | 43 if (cls.typeVariables.isEmpty) return; |
| 44 if (classesNeedingRti.contains(cls)) return; | 44 if (classesNeedingRti.contains(cls)) return; |
| 45 classesNeedingRti.add(cls); | 45 classesNeedingRti.add(cls); |
| 46 if (callback != null) { | 46 if (callback != null) { |
| 47 callback(); | 47 callback(); |
| 48 } | 48 } |
| 49 Set<ClassElement> classes = subtypes[cls]; | 49 Set<ClassElement> classes = subtypes[cls]; |
| 50 if (classes == null) return; | 50 if (classes == null) return; |
| 51 classes.forEach((ClassElement sub) { | 51 classes.forEach((ClassElement sub) { |
| 52 potentiallyAddForRti(sub, callback); | 52 potentiallyAddForRti(sub, callback); |
| 53 }); | 53 }); |
| 54 } | 54 } |
| 55 | 55 |
| 56 compiler.resolverWorld.isChecks.forEach((DartType type) { | 56 compiler.resolverWorld.isChecks.forEach((DartType type) { |
| 57 if (type is InterfaceType) { | 57 if (type is InterfaceType) { |
| 58 InterfaceType itf = type; | 58 InterfaceType itf = type; |
| 59 if (!itf.arguments.isEmpty()) { | 59 if (!itf.arguments.isEmpty) { |
| 60 potentiallyAddForRti(itf.element, null); | 60 potentiallyAddForRti(itf.element, null); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 }); | 63 }); |
| 64 | 64 |
| 65 List<ClassElement> worklist = | 65 List<ClassElement> worklist = |
| 66 new List<ClassElement>.from(classesNeedingRti); | 66 new List<ClassElement>.from(classesNeedingRti); |
| 67 while (!worklist.isEmpty()) { | 67 while (!worklist.isEmpty) { |
| 68 Element e = worklist.removeLast(); | 68 Element e = worklist.removeLast(); |
| 69 Set<Element> dependencies = rtiDependencies[e]; | 69 Set<Element> dependencies = rtiDependencies[e]; |
| 70 if (dependencies == null) continue; | 70 if (dependencies == null) continue; |
| 71 dependencies.forEach((Element other) { | 71 dependencies.forEach((Element other) { |
| 72 potentiallyAddForRti(other, () => worklist.add(other)); | 72 potentiallyAddForRti(other, () => worklist.add(other)); |
| 73 }); | 73 }); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool needsRti(ClassElement cls) { | 77 bool needsRti(ClassElement cls) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 class MemberSet { | 182 class MemberSet { |
| 183 final Set<Element> elements; | 183 final Set<Element> elements; |
| 184 final SourceString name; | 184 final SourceString name; |
| 185 | 185 |
| 186 MemberSet(SourceString this.name) : elements = new Set<Element>(); | 186 MemberSet(SourceString this.name) : elements = new Set<Element>(); |
| 187 | 187 |
| 188 void add(Element element) { | 188 void add(Element element) { |
| 189 elements.add(element); | 189 elements.add(element); |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool isEmpty() => elements.isEmpty(); | 192 bool get isEmpty => elements.isEmpty; |
| 193 } | 193 } |
| OLD | NEW |