Implement polymorphic inline caches.

Swift SVN r20740
This commit is contained in:
Nadav Rotem
2014-07-30 07:43:47 +00:00
parent a643754644
commit 0cb8bf0ab8
6 changed files with 106 additions and 29 deletions

View File

@@ -33,4 +33,22 @@ void ClassHierarchyAnalysis::init() {
}
}
void ClassHierarchyAnalysis::collectSubClasses(ClassDecl *C,
std::vector<ClassDecl*> &Sub) {
// TODO: Cache this search.
assert(Sub.empty() && "Incoming list is not empty");
for (auto &VT : M->getVTableList()) {
ClassDecl *CD = VT.getClass();
// Ignore classes that are at the top of the class hierarchy:
if (!CD->hasSuperclass())
continue;
// Add the superclass to the list of inherited classes.
ClassDecl *Super = CD->getSuperclass()->getClassOrBoundGenericClass();
if (Super == C) {
Sub.push_back(CD);
}
}
}
ClassHierarchyAnalysis::~ClassHierarchyAnalysis() {}