Browse Source

* problem with calls to method pointers in methods fixed
- double ansistrings temp management removed

florian 26 years ago
parent
commit
2ac877d04f
2 changed files with 46 additions and 19 deletions
  1. 41 13
      compiler/cg386cal.pas
  2. 5 6
      compiler/temp_gen.pas

+ 41 - 13
compiler/cg386cal.pas

@@ -873,26 +873,50 @@ implementation
               if (p^.procdefinition^.options and pomethodpointer)<>0 then
                 begin
                    { method pointer can't be in a register }
+                   hregister:=R_NO;
+
+                   { do some hacking if we call a method pointer }
+                   { which is a class member                     }
+                   { else ESI is overwritten !                   }
+                   if (p^.right^.location.reference.base=R_ESI) or
+                     (p^.right^.location.reference.index=R_ESI) then
+                     begin
+                        del_reference(p^.right^.location.reference);
+                        exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
+                          newreference(p^.right^.location.reference),R_EDI)));
+                        hregister:=R_EDI;
+                     end;
+
                    inc(p^.right^.location.reference.offset,4);
+
                    { load ESI }
                    exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
                      newreference(p^.right^.location.reference),R_ESI)));
                    { push self pointer }
                    exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,R_ESI)));
-                   del_reference(p^.right^.location.reference);
                    dec(p^.right^.location.reference.offset,4);
+
+                   if hregister=R_NO then
+                     exprasmlist^.concat(new(pai386,op_ref(A_CALL,S_NO,newreference(p^.right^.location.reference))))
+                   else
+                     exprasmlist^.concat(new(pai386,op_reg(A_CALL,S_NO,hregister)));
+
+                   del_reference(p^.right^.location.reference);
+                end
+              else
+                begin
+                   case p^.right^.location.loc of
+                      LOC_REGISTER,LOC_CREGISTER:
+                         begin
+                             exprasmlist^.concat(new(pai386,op_reg(A_CALL,S_NO,p^.right^.location.register)));
+                             ungetregister32(p^.right^.location.register);
+                         end
+                      else
+                         exprasmlist^.concat(new(pai386,op_ref(A_CALL,S_NO,newreference(p^.right^.location.reference))));
+                         del_reference(p^.right^.location.reference);
+                   end;
                 end;
-              case p^.right^.location.loc of
-                 LOC_REGISTER,LOC_CREGISTER:
-                    begin
-                        exprasmlist^.concat(new(pai386,op_reg(A_CALL,S_NO,p^.right^.location.register)));
-                        ungetregister32(p^.right^.location.register);
-                    end
-                 else
-                    exprasmlist^.concat(new(pai386,op_ref(A_CALL,S_NO,newreference(p^.right^.location.reference))));
-                    del_reference(p^.right^.location.reference);
-              end;
-             end;
+           end;
 
            { this was only for normal functions
              displaced here so we also get
@@ -1258,7 +1282,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.61  1999-02-02 11:04:36  florian
+  Revision 1.62  1999-02-02 23:52:32  florian
+    * problem with calls to method pointers in methods fixed
+    - double ansistrings temp management removed
+
+  Revision 1.61  1999/02/02 11:04:36  florian
     * class destructors fixed, class instances weren't disposed correctly
 
   Revision 1.60  1999/01/28 23:56:44  florian

+ 5 - 6
compiler/temp_gen.pas

@@ -70,7 +70,6 @@ unit temp_gen;
           pos : longint;
           size : longint;
           persistant : boolean; { used for inlined procedures }
-          istempansistring : boolean;
 {$ifdef EXTDEBUG}
           posinfo,releaseposinfo : tfileposinfo;
 {$endif}
@@ -198,7 +197,6 @@ unit temp_gen;
          tl^.size:=size;
          tl^.next:=templist;
          tl^.persistant:=false;
-         tl^.istempansistring:=false;
          templist:=tl;
 {$ifdef EXTDEBUG}
          tl^.posinfo:=aktfilepos;
@@ -256,7 +254,6 @@ unit temp_gen;
          { do a reset, because the reference isn't used }
          reset_reference(ref);
          ref.offset:=gettempofsize(4);
-         templist^.istempansistring:=true;
          ref.base:=procinfo.framepointer;
       end;
 
@@ -452,8 +449,6 @@ unit temp_gen;
                        end;
                    if (ref.offset=tl^.pos) then
                      begin
-                        if tl^.istempansistring then
-                          decransiref(ref);
                         ungettemp(ref.offset,tl^.size);
 {$ifdef TEMPDEBUG}
                    Comment(V_Debug,'temp managment  : ungettemp()'+
@@ -508,7 +503,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.6  1999-01-15 11:34:23  pierre
+  Revision 1.7  1999-02-02 23:52:33  florian
+    * problem with calls to method pointers in methods fixed
+    - double ansistrings temp management removed
+
+  Revision 1.6  1999/01/15 11:34:23  pierre
    + better info for temp allocation debugging
 
   Revision 1.5  1998/11/30 09:43:24  pierre