* don't call class_getSuperClass() anymore to obtain the superclass, but

load it inline. This should be safe even on the non-fragile ABI, because
    the isa and superclass fields are expected at fixed offsets by the runtime
    (and gcc and clang also use direct memory accesses in this case)

git-svn-id: branches/objc@13784 -
This commit is contained in:
Jonas Maebe 2009-10-01 12:07:22 +00:00
parent 3660bf7f98
commit 8700874a96
2 changed files with 14 additions and 6 deletions

View File

@ -64,7 +64,7 @@ implementation
verbose,systems,
symtable,symconst,symsym,
defutil,paramgr,
nbas,nmem,ncal,nld,ncon,
nbas,nmem,ncal,nld,ncon,ncnv,
export;
@ -119,7 +119,9 @@ end;
function objcsuperclassnode(def: tdef): tnode;
var
para: tcallparanode;
para : tcallparanode;
class_type : tdef;
vs : tsym;
begin
{ only valid for Objective-C classes and classrefs }
if not is_objcclass(def) and
@ -140,12 +142,17 @@ end;
superclass. For the fragile ABI, we have to do this ourselves.
NOTE: those send2 methods are only available on Mac OS X 10.6 and later!
(but on also all iPhone SDK revisions we support) }
(but also on all iPhone SDK revisions we support) }
if not(target_info.system in system_objc_nfabi) then
{$endif onlymacosx10_6 or arm}
begin
para:=ccallparanode.create(result,nil);
result:=ccallnode.createinternfromunit('OBJC','CLASS_GETSUPERCLASS',para);
class_type:=search_named_unit_globaltype('OBJC','OBJC_OBJECT').typedef;
result:=ctypeconvnode.create_internal(cderefnode.create(ctypeconvnode.create_internal(result,voidpointertype)),class_type);
vs:=tsym(tabstractrecorddef(class_type).symtable.Find('SUPERCLASS'));
if not assigned(vs) or
(vs.typ<>fieldvarsym) then
internalerror(200909301);
result:=csubscriptnode.create(vs,result);
end;
typecheckpass(result);
end;

View File

@ -60,6 +60,7 @@ type
objc_object = record
isa: pobjc_class;
superclass: pobjc_class;
end;
id = ^objc_object;
pobjc_object = id;