aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteTest.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2007-10-19 00:36:46 +0000
committerFariborz Jahanian <fjahanian@apple.com>2007-10-19 00:36:46 +0000
commit776d6ff62397a35247787280128fe441a0fbe7c4 (patch)
treef571c53d52d615e4c74c7f952bfbaf90f0ef32ce /Driver/RewriteTest.cpp
parent54d02e9a913af2945ea063edfda3070381956df5 (diff)
rewrite of metadata for implemented instance methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43159 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r--Driver/RewriteTest.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index 883482c67e..69739f5c51 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -133,6 +133,7 @@ void RewriteTest::RewriteAtEncode(ObjCEncodeExpr *Exp) {
void RewriteTest::WriteObjcClassMetaData(ObjcImplementationDecl *IDecl) {
ObjcInterfaceDecl *CDecl = IDecl->getClassInterface();
+ // Build _objc_ivar_list metadata for classes ivars if needed
if (IDecl->getImplDeclNumIvars() > 0 ||
CDecl&& CDecl->getIntfDeclNumIvars() > 0) {
static bool objc_ivar = false;
@@ -178,6 +179,48 @@ void RewriteTest::WriteObjcClassMetaData(ObjcImplementationDecl *IDecl) {
printf("};\n");
}
+ // Build _objc_method_list for class's instance methods if needed
+ if (IDecl->getNumInstanceMethods() > 0) {
+ int NumMethods = IDecl->getNumInstanceMethods();
+ static bool objc_method = false;
+ if (!objc_method) {
+ /* struct _objc_method {
+ SEL _cmd;
+ char *method_types;
+ void *_imp;
+ }
+ */
+ printf("\nstruct _objc_method {\n");
+ printf("\tSEL _cmd;\n");
+ printf("\tchar *method_types;\n");
+ printf("\tvoid *_imp;\n");
+ printf("};\n");
+ objc_method = true;
+ }
+ /* struct _objc_method_list {
+ struct objc_method_list *next_method;
+ int method_count;
+ struct _objc_method method_list[method_count];
+ }
+ */
+ printf("\nstatic struct {\n");
+ printf("\tstruct objc_method_list *next_method;\n");
+ printf("\tint method_count;\n");
+ printf("\tstruct _objc_method method_list[%d];\n", NumMethods);
+ printf("} _OBJC_INSTANCE_METHODS_%s "
+ "__attribute__ ((section (\"__OBJC, __inst_meth\")))= "
+ "{\n\t0, %d\n", IDecl->getName(), NumMethods);
+ ObjcMethodDecl **Methods = IDecl->getInstanceMethods();
+ for (int i = 0; i < NumMethods; i++)
+ // TODO: 1) method selector name may hav to go into their own section
+ // 2) encode method types for use here (which may have to go into
+ // __meth_var_types section, 3) Need method address as 3rd initializer.
+ printf("\t,(SEL)\"%s\", \"\", 0\n",
+ Methods[i]->getSelector().getName().c_str());
+ printf("};\n");
+ }
+
+
}
void RewriteTest::WriteObjcMetaData() {