Przeglądaj źródła

* renamed fobjcforcedprocname to fforcedprocname and also use it for the
JVM target to force virtual method calls to be name-based rather than
VMT-entry-based

git-svn-id: trunk@27149 -

Jonas Maebe 11 lat temu
rodzic
commit
84442d05f9
3 zmienionych plików z 15 dodań i 13 usunięć
  1. 4 0
      compiler/jvm/njvmcal.pas
  2. 6 4
      compiler/ncal.pas
  3. 5 9
      compiler/ncgcal.pas

+ 4 - 0
compiler/jvm/njvmcal.pas

@@ -590,6 +590,10 @@ implementation
           result:=inherited pass_1;
           result:=inherited pass_1;
           if assigned(result) then
           if assigned(result) then
             exit;
             exit;
+          { set fforcedprocname so that even virtual method calls will be
+            name-based (instead of based on VMT entry numbers) }
+          if procdefinition.typ=procdef then
+            fforcedprocname:=stringdup(tprocdef(procdefinition).mangledname)
         end;
         end;
     end;
     end;
 
 

+ 6 - 4
compiler/ncal.pas

@@ -98,8 +98,10 @@ interface
           pushedparasize : longint;
           pushedparasize : longint;
           { Objective-C support: force the call node to call the routine with
           { Objective-C support: force the call node to call the routine with
             this name rather than the name of symtableprocentry (don't store
             this name rather than the name of symtableprocentry (don't store
-            to ppu, is set while processing the node) }
-          fobjcforcedprocname: pshortstring;
+            to ppu, is set while processing the node). Also used on the JVM
+            target for calling virtual methods, as this is name-based and not
+            based on VMT entry locations }
+          fforcedprocname: pshortstring;
        public
        public
           { the symbol containing the definition of the procedure }
           { the symbol containing the definition of the procedure }
           { to call                                               }
           { to call                                               }
@@ -1202,7 +1204,7 @@ implementation
          funcretnode.free;
          funcretnode.free;
          if assigned(varargsparas) then
          if assigned(varargsparas) then
            varargsparas.free;
            varargsparas.free;
-         stringdispose(fobjcforcedprocname);
+         stringdispose(fforcedprocname);
          inherited destroy;
          inherited destroy;
       end;
       end;
 
 
@@ -2059,7 +2061,7 @@ implementation
            (srsym.typ<>procsym) or
            (srsym.typ<>procsym) or
            (tprocsym(srsym).ProcdefList.count<>1) then
            (tprocsym(srsym).ProcdefList.count<>1) then
           Message1(cg_f_unknown_compilerproc,'objc.'+msgsendname);
           Message1(cg_f_unknown_compilerproc,'objc.'+msgsendname);
-        fobjcforcedprocname:=stringdup(tprocdef(tprocsym(srsym).ProcdefList[0]).mangledname);
+        fforcedprocname:=stringdup(tprocdef(tprocsym(srsym).ProcdefList[0]).mangledname);
 
 
         { B) Handle self }
         { B) Handle self }
         { 1) in case of sending a message to a superclass, self is a pointer to
         { 1) in case of sending a message to a superclass, self is a pointer to

+ 5 - 9
compiler/ncgcal.pas

@@ -869,10 +869,8 @@ implementation
 {$endif vtentry}
 {$endif vtentry}
 
 
              name_to_call:='';
              name_to_call:='';
-             if assigned(fobjcforcedprocname) then
-               name_to_call:=fobjcforcedprocname^;
-             { in the JVM, virtual method calls are also name-based }
-{$ifndef jvm}
+             if assigned(fforcedprocname) then
+               name_to_call:=fforcedprocname^;
              { When methodpointer is typen we don't need (and can't) load
              { When methodpointer is typen we don't need (and can't) load
                a pointer. We can directly call the correct procdef (PFV) }
                a pointer. We can directly call the correct procdef (PFV) }
              if (name_to_call='') and
              if (name_to_call='') and
@@ -951,7 +949,6 @@ implementation
                  extra_post_call_code;
                  extra_post_call_code;
                end
                end
              else
              else
-{$endif jvm}
                begin
                begin
                   { Load parameters that are in temporary registers in the
                   { Load parameters that are in temporary registers in the
                     correct parameter register }
                     correct parameter register }
@@ -981,10 +978,9 @@ implementation
                         extra_interrupt_code;
                         extra_interrupt_code;
                       extra_call_code;
                       extra_call_code;
                       if (name_to_call='') then
                       if (name_to_call='') then
-                        if cnf_inherited in callnodeflags then
-                          hlcg.a_call_name_inherited(current_asmdata.CurrAsmList,tprocdef(procdefinition),tprocdef(procdefinition).mangledname)
-                        else
-                          hlcg.a_call_name(current_asmdata.CurrAsmList,tprocdef(procdefinition),tprocdef(procdefinition).mangledname,typedef,po_weakexternal in procdefinition.procoptions).resetiftemp
+                        name_to_call:=tprocdef(procdefinition).mangledname;
+                      if cnf_inherited in callnodeflags then
+                        hlcg.a_call_name_inherited(current_asmdata.CurrAsmList,tprocdef(procdefinition),name_to_call)
                       else
                       else
                         hlcg.a_call_name(current_asmdata.CurrAsmList,tprocdef(procdefinition),name_to_call,typedef,po_weakexternal in procdefinition.procoptions).resetiftemp;
                         hlcg.a_call_name(current_asmdata.CurrAsmList,tprocdef(procdefinition),name_to_call,typedef,po_weakexternal in procdefinition.procoptions).resetiftemp;
                       extra_post_call_code;
                       extra_post_call_code;