Jelajahi Sumber

- removed most special handling of self (the self parameter has had the
correct type since quite a while)
o exceptions:
o objects/records (self is a "var" parameter there, and sometimes
we want to load it as a pointer to an object instead
o Objective-C class methods, where self has to be id (to have a signature
compatible with what Objective-C compilers generate), but when loading
it we want a classrefdef of the current class for type check and
method resolving

git-svn-id: trunk@30949 -

Jonas Maebe 10 tahun lalu
induk
melakukan
822b943d08
1 mengubah file dengan 12 tambahan dan 15 penghapusan
  1. 12 15
      compiler/nld.pas

+ 12 - 15
compiler/nld.pas

@@ -333,27 +333,24 @@ implementation
                    { and behaves as if its address escapes its parent block         }
                    make_not_regable(self,[ra_addr_taken]);
                  end;
-               { fix self type which is declared as voidpointer in the
-                 definition }
-               if vo_is_self in tabstractvarsym(symtableentry).varoptions then
+               resultdef:=tabstractvarsym(symtableentry).vardef;
+               { self for objects is passed as var-parameter on the caller
+                 side, but on the callee-side we use it as a pointer ->
+                 adjust }
+               if (vo_is_self in tabstractvarsym(symtableentry).varoptions) then
                  begin
-                   resultdef:=tprocdef(symtableentry.owner.defowner).struct;
-                   if is_objectpascal_helper(resultdef) then
-                     resultdef:=tobjectdef(resultdef).extendeddef;
-                   if (po_classmethod in tprocdef(symtableentry.owner.defowner).procoptions) or
-                      (po_staticmethod in tprocdef(symtableentry.owner.defowner).procoptions) then
-                     resultdef:=cclassrefdef.create(resultdef)
-                   else if (is_object(resultdef) or is_record(resultdef)) and
-                           (loadnf_load_self_pointer in loadnodeflags) then
-                     resultdef:=getpointerdef(resultdef);
+                   if (is_object(resultdef) or is_record(resultdef)) and
+                      (loadnf_load_self_pointer in loadnodeflags) then
+                     resultdef:=getpointerdef(resultdef)
+                   else if (resultdef=objc_idtype) and
+                      (po_classmethod in tprocdef(symtableentry.owner.defowner).procoptions) then
+                     resultdef:=cclassrefdef.create(tprocdef(symtableentry.owner.defowner).struct)
                  end
                else if vo_is_vmt in tabstractvarsym(symtableentry).varoptions then
                  begin
                    resultdef:=tprocdef(symtableentry.owner.defowner).struct;
                    resultdef:=cclassrefdef.create(resultdef);
-                 end
-               else
-                 resultdef:=tabstractvarsym(symtableentry).vardef;
+                 end;
              end;
            procsym :
              begin