Browse Source

+ support for non-static class methods on the JVM target

git-svn-id: branches/jvmbackend@18557 -
Jonas Maebe 14 years ago
parent
commit
84640fe7f0
5 changed files with 13 additions and 10 deletions
  1. 1 1
      compiler/agjasmin.pas
  2. 1 1
      compiler/jvm/hlcgcpu.pas
  3. 3 1
      compiler/ncal.pas
  4. 0 4
      compiler/pdecobj.pas
  5. 8 3
      compiler/symdef.pas

+ 1 - 1
compiler/agjasmin.pas

@@ -702,7 +702,7 @@ implementation
       begin
       begin
         result:=VisibilityToStr(pd.visibility);
         result:=VisibilityToStr(pd.visibility);
         if (pd.procsym.owner.symtabletype in [globalsymtable,staticsymtable,localsymtable]) or
         if (pd.procsym.owner.symtabletype in [globalsymtable,staticsymtable,localsymtable]) or
-           (po_staticmethod in pd.procoptions) then
+           (po_classmethod in pd.procoptions) then
           result:=result+'static ';
           result:=result+'static ';
         if is_javainterface(tdef(pd.owner.defowner)) then
         if is_javainterface(tdef(pd.owner.defowner)) then
           result:=result+'abstract ';
           result:=result+'abstract ';

+ 1 - 1
compiler/jvm/hlcgcpu.pas

@@ -1864,7 +1864,7 @@ implementation
             case tobjectdef(pd.owner.defowner).objecttype of
             case tobjectdef(pd.owner.defowner).objecttype of
               odt_javaclass:
               odt_javaclass:
                 begin
                 begin
-                  if (po_staticmethod in pd.procoptions) then
+                  if (po_classmethod in pd.procoptions) then
                     opc:=a_invokestatic
                     opc:=a_invokestatic
                   else if (pd.visibility=vis_private) or
                   else if (pd.visibility=vis_private) or
                      (pd.proctypeoption=potype_constructor) or
                      (pd.proctypeoption=potype_constructor) or

+ 3 - 1
compiler/ncal.pas

@@ -1713,7 +1713,9 @@ implementation
                 selfdef:=tobjectdef(tprocdef(procdefinition).struct).extendeddef
                 selfdef:=tobjectdef(tprocdef(procdefinition).struct).extendeddef
               else
               else
                 selfdef:=tprocdef(procdefinition).struct;
                 selfdef:=tprocdef(procdefinition).struct;
-              if (oo_has_vmt in selfdef.objectoptions) then
+              if (oo_has_vmt in tprocdef(procdefinition).struct.objectoptions) or
+                 { all Java classes have a "VMT" }
+                 (target_info.system in [system_jvm_java32]) then
                 begin
                 begin
                   { we only need the vmt, loading self is not required and there is no
                   { we only need the vmt, loading self is not required and there is no
                     need to check for typen, because that will always get the
                     need to check for typen, because that will always get the

+ 0 - 4
compiler/pdecobj.pas

@@ -781,10 +781,6 @@ implementation
           if is_java_class_or_interface(pd.struct) then
           if is_java_class_or_interface(pd.struct) then
             begin
             begin
               include(pd.procoptions,po_java);
               include(pd.procoptions,po_java);
-              { In java, all methods are either regular virtual methods,
-                or static class methods }
-              if [po_staticmethod,po_classmethod]*pd.procoptions=[po_classmethod] then
-                messagepos(pd.fileinfo,type_e_java_class_method_not_static);
             end;
             end;
         end;
         end;
 
 

+ 8 - 3
compiler/symdef.pas

@@ -4488,9 +4488,14 @@ implementation
             for i:=0 to paras.count-1 do
             for i:=0 to paras.count-1 do
               begin
               begin
                 vs:=tparavarsym(paras[i]);
                 vs:=tparavarsym(paras[i]);
-                { function result and self pointer are not part of the mangled
-                  name }
-                if ([vo_is_funcret,vo_is_self] * vs.varoptions <> []) then
+                { function result is not part of the mangled name }
+                if vo_is_funcret in vs.varoptions then
+                  exit;
+                { self pointer neither, except for class methods (the JVM only
+                  supports static class methods natively, so the self pointer
+                  here is a regular parameter as far as the JVM is concerned }
+                if not(po_classmethod in procoptions) and
+                   (vo_is_self in vs.varoptions) then
                   continue;
                   continue;
                 { passing by reference is emulated by passing an array of one
                 { passing by reference is emulated by passing an array of one
                   element containing the value; for types that aren't pointers
                   element containing the value; for types that aren't pointers