Browse Source

* fixed bug #292 from bugs directory

florian 26 years ago
parent
commit
796234f596
2 changed files with 29 additions and 3 deletions
  1. 23 2
      compiler/cgai386.pas
  2. 6 1
      compiler/new/cgobj.pas

+ 23 - 2
compiler/cgai386.pas

@@ -3127,9 +3127,11 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
        mangled_length : longint;
        mangled_length : longint;
        p : pchar;
        p : pchar;
 {$endif GDB}
 {$endif GDB}
-       okexitlabel,noreraiselabel : pasmlabel;
+       nofinal,okexitlabel,noreraiselabel : pasmlabel;
        hr : treference;
        hr : treference;
        oldexprasmlist : paasmoutput;
        oldexprasmlist : paasmoutput;
+       ai : paicpu;
+
   begin
   begin
       oldexprasmlist:=exprasmlist;
       oldexprasmlist:=exprasmlist;
       exprasmlist:=alist;
       exprasmlist:=alist;
@@ -3148,6 +3150,22 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
             begin
             begin
               emitinsertcall('FPC_HELP_DESTRUCTOR');
               emitinsertcall('FPC_HELP_DESTRUCTOR');
               exprasmlist^.insert(new(paicpu,op_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI)));
               exprasmlist^.insert(new(paicpu,op_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI)));
+              { must the object be finalized ? }
+              if procinfo^._class^.needs_inittable then
+                begin
+                   getlabel(nofinal);
+                   exprasmlist^.insert(new(pai_label,init(nofinal)));
+                   emitinsertcall('FPC_FINALIZE');
+                   exprasmlist^.insert(new(paicpu,op_reg(A_PUSH,S_L,R_ESI)));
+                   exprasmlist^.insert(new(paicpu,op_sym(A_PUSH,S_L,procinfo^._class^.get_inittable_label)));
+                   ai:=new(paicpu,op_sym(A_Jcc,S_NO,nofinal));
+                   ai^.SetCondition(C_Z);
+                   exprasmlist^.insert(ai);
+                   reset_reference(hr);
+                   hr.base:=R_EBP;
+                   hr.offset:=8;
+                   exprasmlist^.insert(new(paicpu,op_const_ref(A_CMP,S_L,0,newreference(hr))));
+                end;
             end;
             end;
         end;
         end;
 
 
@@ -3359,7 +3377,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.49  1999-09-28 21:07:53  florian
+  Revision 1.50  1999-09-29 11:46:18  florian
+    * fixed bug 292 from bugs directory
+
+  Revision 1.49  1999/09/28 21:07:53  florian
     * fixed bug 608
     * fixed bug 608
 
 
   Revision 1.48  1999/09/28 19:43:47  florian
   Revision 1.48  1999/09/28 19:43:47  florian

+ 6 - 1
compiler/new/cgobj.pas

@@ -803,6 +803,8 @@ unit cgobj;
                a_call_name(list,'FPC_DISPOSE_CLASS',0)
                a_call_name(list,'FPC_DISPOSE_CLASS',0)
              else
              else
                begin
                begin
+                  we must do a finalize here for objects if
+                  necessary
                   { vmt_offset_reg can be a scratch register, }
                   { vmt_offset_reg can be a scratch register, }
                   { but it must be always the same            }
                   { but it must be always the same            }
                   a_reg_alloc(list,vmt_offset_reg);
                   a_reg_alloc(list,vmt_offset_reg);
@@ -1080,7 +1082,10 @@ unit cgobj;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.26  1999-09-14 11:16:09  florian
+  Revision 1.27  1999-09-29 11:46:20  florian
+    * fixed bug 292 from bugs directory
+
+  Revision 1.26  1999/09/14 11:16:09  florian
     * only small updates to work with the current compiler
     * only small updates to work with the current compiler
 
 
   Revision 1.25  1999/09/03 13:09:09  jonas
   Revision 1.25  1999/09/03 13:09:09  jonas