Browse Source

* fixed init table generation for classes and arrays

florian 25 years ago
parent
commit
a44fb4a474
2 changed files with 31 additions and 13 deletions
  1. 11 2
      compiler/ptype.pas
  2. 20 11
      compiler/symdef.inc

+ 11 - 2
compiler/ptype.pas

@@ -1134,10 +1134,16 @@ uses
                  else
                    datasegment^.concat(new(pai_const,init_32bit(0)));
                  { inittable for con-/destruction }
+                 {
                  if aktclass^.needs_inittable then
-                   datasegment^.concat(new(pai_const_symbol,init(aktclass^.get_inittable_label)))
+                 }
+                 { we generate the init table for classes always, because needs_inittable }
+                 { for classes is always false, it applies only for objects               }
+                 datasegment^.concat(new(pai_const_symbol,init(aktclass^.get_inittable_label)));
+                 {
                  else
                    datasegment^.concat(new(pai_const,init_32bit(0)));
+                 }
                  { auto table }
                  datasegment^.concat(new(pai_const,init_32bit(0)));
                  { interface table }
@@ -1535,7 +1541,10 @@ uses
 end.
 {
   $Log$
-  Revision 1.16  2000-01-28 23:17:53  florian
+  Revision 1.17  2000-02-05 14:33:32  florian
+    * fixed init table generation for classes and arrays
+
+  Revision 1.16  2000/01/28 23:17:53  florian
     * virtual XXXX; support for objects, only if -dWITHDMT is defined
 
   Revision 1.15  2000/01/27 16:31:40  florian

+ 20 - 11
compiler/symdef.inc

@@ -1947,7 +1947,7 @@
 
     procedure tarraydef.write_rtti_data;
       begin
-         rttilist^.concat(new(pai_const,init_8bit(13)));
+         rttilist^.concat(new(pai_const,init_8bit(tkarray)));
          write_rtti_name;
          { size of elements }
          rttilist^.concat(new(pai_const,init_32bit(elementtype.def^.size)));
@@ -2169,6 +2169,7 @@
 
     var
        count : longint;
+
     procedure count_inittable_fields(sym : pnamedindexobject);{$ifndef fpc}far;{$endif}
       begin
          if ((psym(sym)^.typ=varsym) and
@@ -3623,15 +3624,20 @@ Const local_symtable_index : longint = $8001;
       var
          oldb : boolean;
       begin
-         { there are recursive calls to needs_inittable possible, }
-         { so we have to change to old value how else should      }
-         { we do that ? check_rec_rtti can't be a nested          }
-         { procedure of needs_rtti !                              }
-         oldb:=binittable;
-         binittable:=false;
-         symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
-         needs_inittable:=binittable;
-         binittable:=oldb;
+         if is_class then
+           needs_inittable:=false
+         else
+           begin
+              { there are recursive calls to needs_inittable possible, }
+              { so we have to change to old value how else should      }
+              { we do that ? check_rec_rtti can't be a nested          }
+              { procedure of needs_rtti !                              }
+              oldb:=binittable;
+              binittable:=false;
+              symtable^.foreach({$ifndef TP}@{$endif}check_rec_inittable);
+              needs_inittable:=binittable;
+              binittable:=oldb;
+           end;
       end;
 
 
@@ -3915,7 +3921,10 @@ Const local_symtable_index : longint = $8001;
 
 {
   $Log$
-  Revision 1.192  2000-02-04 20:00:22  florian
+  Revision 1.193  2000-02-05 14:33:32  florian
+    * fixed init table generation for classes and arrays
+
+  Revision 1.192  2000/02/04 20:00:22  florian
     * an exception in a construcor calls now the destructor (this applies only
       to classes)