diff options
author | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2009-09-09 22:27:39 +0000 |
---|---|---|
committer | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2009-09-09 22:27:39 +0000 |
commit | 396068b4ac8539dfb5407e2e788e0a4cea3d0916 (patch) | |
tree | 4cf27c8a4d2ba30496e880bde6ef9aad3fae4fb8 /compiler/objcutil.pas | |
parent | b228bc66d45fcd5122dda7acf196f000b52a1985 (diff) | |
download | fpc-396068b4ac8539dfb5407e2e788e0a4cea3d0916.tar.gz |
* fixed calling inherited methods in Objective-C + test
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/objc@13686 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/objcutil.pas')
-rw-r--r-- | compiler/objcutil.pas | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/compiler/objcutil.pas b/compiler/objcutil.pas index f670885a82..5bbb0a777a 100644 --- a/compiler/objcutil.pas +++ b/compiler/objcutil.pas @@ -33,7 +33,7 @@ interface { Generate a node loading the superclass structure necessary to call an inherited Objective-C method. } - function objcsuperclassnode(def: tobjectdef): tnode; + function objcsuperclassnode(def: tdef): tnode; { The internals of Objective-C's @encode() functionality: encode a type into the internal format used by the run time. Returns false @@ -58,27 +58,32 @@ implementation verbose, symtable,symconst,symsym, defutil,paramgr, - nbas,nmem,ncal,nld; + nbas,nmem,ncal,nld,ncon; {****************************************************************** objcsuperclassnode *******************************************************************} - function objcsuperclassnode(def: tobjectdef): tnode; + function objcsuperclassnode(def: tdef): tnode; var - block: tnode; - statements: tstatementnode; para: tcallparanode; begin - { only valid for Objective-C classes } - if not is_objcclass(def) then - internalerror(2009032904); - block:=internalstatements(statements); - para:=ccallparanode.create(cloadvmtaddrnode.create(ctypenode.create(def)),nil); - addstatement(statements,ccallnode.createinternfromunit('OBJC1','CLASS_GETSUPERCLASS',para)); - typecheckpass(block); - result:=block; + { only valid for Objective-C classes and classrefs } + if not is_objcclass(def) and + not is_objcclassref(def) then + internalerror(2009090901); + { Can be done a lot more efficiently with direct symbol accesses, but + requires extra node types. Maybe later. } + if is_objcclassref(def) then + begin + para:=ccallparanode.create(cstringconstnode.createstr(tobjectdef(tclassrefdef(def).pointeddef).objextname^),nil); + para:=ccallparanode.create(ccallnode.createinternfromunit('OBJC1','OBJC_GETMETACLASS',para),nil); + end + else + para:=ccallparanode.create(cloadvmtaddrnode.create(ctypenode.create(def)),nil); + result:=ccallnode.createinternfromunit('OBJC1','CLASS_GETSUPERCLASS',para); + typecheckpass(result); end; |