зеркало из https://github.com/microsoft/clang-1.git
Add category lookup (removing a couple FIXME's).
Changed ObjcInterfaceDecl::ListCategories->CategoryList. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42968 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
8de2826e4d
Коммит
3d58138992
30
AST/Decl.cpp
30
AST/Decl.cpp
|
@ -410,7 +410,8 @@ void ObjcImplementationDecl::ObjcAddImplMethods(ObjcMethodDecl **insMethods,
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: look through categories...
|
||||
// lookupInstanceMethod - This method returns an instance method by looking in
|
||||
// the class, it's categories, and it's super classes (using a linear search).
|
||||
ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector &Sel) {
|
||||
ObjcInterfaceDecl* ClassDecl = this;
|
||||
while (ClassDecl != NULL) {
|
||||
|
@ -421,12 +422,25 @@ ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector &Sel) {
|
|||
return methods[i];
|
||||
}
|
||||
}
|
||||
// Didn't find one yet - now look through categories.
|
||||
ObjcCategoryDecl *CatDecl = this->getCategoryList();
|
||||
while (CatDecl) {
|
||||
ObjcMethodDecl **methods = CatDecl->getInstanceMethods();
|
||||
int methodCount = CatDecl->getNumInstanceMethods();
|
||||
for (int i = 0; i < methodCount; ++i) {
|
||||
if (methods[i]->getSelector() == Sel) {
|
||||
return methods[i];
|
||||
}
|
||||
}
|
||||
CatDecl = CatDecl->getNextClassCategory();
|
||||
}
|
||||
ClassDecl = ClassDecl->getSuperClass();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FIXME: look through categories...
|
||||
// lookupClassMethod - This method returns a class method by looking in the
|
||||
// class, it's categories, and it's super classes (using a linear search).
|
||||
ObjcMethodDecl *ObjcInterfaceDecl::lookupClassMethod(Selector &Sel) {
|
||||
ObjcInterfaceDecl* ClassDecl = this;
|
||||
while (ClassDecl != NULL) {
|
||||
|
@ -437,6 +451,18 @@ ObjcMethodDecl *ObjcInterfaceDecl::lookupClassMethod(Selector &Sel) {
|
|||
return methods[i];
|
||||
}
|
||||
}
|
||||
// Didn't find one yet - now look through categories.
|
||||
ObjcCategoryDecl *CatDecl = this->getCategoryList();
|
||||
while (CatDecl) {
|
||||
ObjcMethodDecl **methods = CatDecl->getClassMethods();
|
||||
int methodCount = CatDecl->getNumClassMethods();
|
||||
for (int i = 0; i < methodCount; ++i) {
|
||||
if (methods[i]->getSelector() == Sel) {
|
||||
return methods[i];
|
||||
}
|
||||
}
|
||||
CatDecl = CatDecl->getNextClassCategory();
|
||||
}
|
||||
ClassDecl = ClassDecl->getSuperClass();
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -1117,7 +1117,7 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface(
|
|||
CDecl->setClassInterface(IDecl);
|
||||
/// Check for duplicate interface declaration for this category
|
||||
ObjcCategoryDecl *CDeclChain;
|
||||
for (CDeclChain = IDecl->getListCategories(); CDeclChain;
|
||||
for (CDeclChain = IDecl->getCategoryList(); CDeclChain;
|
||||
CDeclChain = CDeclChain->getNextClassCategory()) {
|
||||
if (CDeclChain->getIdentifier() == CategoryName) {
|
||||
Diag(CategoryLoc, diag::err_dup_category_def, ClassName->getName(),
|
||||
|
@ -1889,7 +1889,7 @@ void Sema::ActOnAddMethodsToObjcDecl(Scope* S, DeclTy *classDecl,
|
|||
// Find category interface decl and then check that all methods declared
|
||||
// in this interface is implemented in the category @implementation.
|
||||
if (IDecl) {
|
||||
for (ObjcCategoryDecl *Categories = IDecl->getListCategories();
|
||||
for (ObjcCategoryDecl *Categories = IDecl->getCategoryList();
|
||||
Categories; Categories = Categories->getNextClassCategory()) {
|
||||
if (Categories->getIdentifier() == CatImplClass->getIdentifier()) {
|
||||
ImplCategoryMethodsVsIntfMethods(CatImplClass, Categories);
|
||||
|
|
|
@ -70,7 +70,7 @@ class ObjcInterfaceDecl : public TypeDecl {
|
|||
int NumClassMethods; // -1 if not defined
|
||||
|
||||
/// List of categories defined for this class.
|
||||
ObjcCategoryDecl *ListCategories;
|
||||
ObjcCategoryDecl *CategoryList;
|
||||
|
||||
bool ForwardDecl; // declared with @class.
|
||||
public:
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
NumIvars(-1),
|
||||
InstanceMethods(0), NumInstanceMethods(-1),
|
||||
ClassMethods(0), NumClassMethods(-1),
|
||||
ListCategories(0), ForwardDecl(FD) {
|
||||
CategoryList(0), ForwardDecl(FD) {
|
||||
AllocIntfRefProtocols(numRefProtos);
|
||||
}
|
||||
|
||||
|
@ -126,9 +126,9 @@ public:
|
|||
ObjcInterfaceDecl *getSuperClass() const { return SuperClass; }
|
||||
void setSuperClass(ObjcInterfaceDecl * superCls) { SuperClass = superCls; }
|
||||
|
||||
ObjcCategoryDecl* getListCategories() const { return ListCategories; }
|
||||
void setListCategories(ObjcCategoryDecl *category) {
|
||||
ListCategories = category;
|
||||
ObjcCategoryDecl* getCategoryList() const { return CategoryList; }
|
||||
void setCategoryList(ObjcCategoryDecl *category) {
|
||||
CategoryList = category;
|
||||
}
|
||||
ObjcMethodDecl *lookupInstanceMethod(Selector &Sel);
|
||||
ObjcMethodDecl *lookupClassMethod(Selector &Sel);
|
||||
|
@ -480,8 +480,8 @@ public:
|
|||
|
||||
ObjcCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
|
||||
void insertNextClassCategory() {
|
||||
NextClassCategory = ClassInterface->getListCategories();
|
||||
ClassInterface->setListCategories(this);
|
||||
NextClassCategory = ClassInterface->getCategoryList();
|
||||
ClassInterface->setCategoryList(this);
|
||||
}
|
||||
|
||||
static bool classof(const Decl *D) { return D->getKind() == ObjcCategory; }
|
||||
|
|
Загрузка…
Ссылка в новой задаче