diff options
author | Steve Naroff <snaroff@apple.com> | 2007-10-14 23:13:51 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-10-14 23:13:51 +0000 |
commit | ff1afdb4f5ee2fc74ec0af788e18b3a036eaaafe (patch) | |
tree | f82832eee6a41de64b37863fb3512f429b1ddc0e /AST/Decl.cpp | |
parent | 3d58138992b9bc7b34aaa680f3ddf3971292eb7d (diff) |
- Teach ObjcInterfaceDecl::lookupInstance/ClassMethod to look through protocols.
- Start looking up methods in the global method pools (for "id").
- Start integrating interface types into the type system.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42971 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'AST/Decl.cpp')
-rw-r--r-- | AST/Decl.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/AST/Decl.cpp b/AST/Decl.cpp index 908bab4277..30ca5e6e1b 100644 --- a/AST/Decl.cpp +++ b/AST/Decl.cpp @@ -422,8 +422,20 @@ ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector &Sel) { return methods[i]; } } + // Didn't find one yet - look through protocols. + ObjcProtocolDecl **protocols = ClassDecl->getReferencedProtocols(); + int numProtocols = ClassDecl->getNumIntfRefProtocols(); + for (int pIdx = 0; pIdx < numProtocols; pIdx++) { + ObjcMethodDecl **methods = protocols[pIdx]->getInstanceMethods(); + int methodCount = protocols[pIdx]->getNumInstanceMethods(); + for (int i = 0; i < methodCount; ++i) { + if (methods[i]->getSelector() == Sel) { + return methods[i]; + } + } + } // Didn't find one yet - now look through categories. - ObjcCategoryDecl *CatDecl = this->getCategoryList(); + ObjcCategoryDecl *CatDecl = ClassDecl->getCategoryList(); while (CatDecl) { ObjcMethodDecl **methods = CatDecl->getInstanceMethods(); int methodCount = CatDecl->getNumInstanceMethods(); @@ -451,8 +463,20 @@ ObjcMethodDecl *ObjcInterfaceDecl::lookupClassMethod(Selector &Sel) { return methods[i]; } } + // Didn't find one yet - look through protocols. + ObjcProtocolDecl **protocols = ClassDecl->getReferencedProtocols(); + int numProtocols = ClassDecl->getNumIntfRefProtocols(); + for (int pIdx = 0; pIdx < numProtocols; pIdx++) { + ObjcMethodDecl **methods = protocols[pIdx]->getClassMethods(); + int methodCount = protocols[pIdx]->getNumClassMethods(); + for (int i = 0; i < methodCount; ++i) { + if (methods[i]->getSelector() == Sel) { + return methods[i]; + } + } + } // Didn't find one yet - now look through categories. - ObjcCategoryDecl *CatDecl = this->getCategoryList(); + ObjcCategoryDecl *CatDecl = ClassDecl->getCategoryList(); while (CatDecl) { ObjcMethodDecl **methods = CatDecl->getClassMethods(); int methodCount = CatDecl->getNumClassMethods(); |