Jelajahi Sumber

* fixed writing "packed" status of bitpacked records to ppu files.
Not sure how it ever worked, nor how exactly symtable ppu entries
work -- but it's now stored with the recorddef (which also means
that bitpacking is disabled currently for objects and classes,
since they are based on tabstractrecorddef rather than trecorddef)

git-svn-id: trunk@4679 -

Jonas Maebe 19 tahun lalu
induk
melakukan
3bb41dcf9a
7 mengubah file dengan 37 tambahan dan 9 penghapusan
  1. 2 0
      .gitattributes
  2. 1 1
      compiler/ppu.pas
  3. 2 1
      compiler/ptype.pas
  4. 2 0
      compiler/symdef.pas
  5. 1 7
      compiler/symtable.pas
  6. 17 0
      tests/webtbf/tw7438.pp
  7. 12 0
      tests/webtbf/tw7438a.pp

+ 2 - 0
.gitattributes

@@ -6532,6 +6532,8 @@ tests/webtbf/tw6686.pp svneol=native#text/plain
 tests/webtbf/tw6796.pp svneol=native#text/plain
 tests/webtbf/tw6922.pp svneol=native#text/plain
 tests/webtbf/tw6970.pp svneol=native#text/plain
+tests/webtbf/tw7438.pp svneol=native#text/plain
+tests/webtbf/tw7438a.pp svneol=native#text/plain
 tests/webtbf/uw0744.pp svneol=native#text/plain
 tests/webtbf/uw0840a.pp svneol=native#text/plain
 tests/webtbf/uw0840b.pp svneol=native#text/plain

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 
 const
-  CurrentPPUVersion=64;
+  CurrentPPUVersion=65;
 
 { buffer sizes }
   maxentrysize = 1024;

+ 2 - 1
compiler/ptype.pas

@@ -711,7 +711,8 @@ implementation
                 else
                   begin
                     oldaktpackrecords:=aktpackrecords;
-                    if not bitpacking then
+                    if (not bitpacking) or
+                       (token in [_CLASS,_OBJECT]) then
                       aktpackrecords:=1
                     else
                       aktpackrecords:=bit_alignment;

+ 2 - 0
compiler/symdef.pas

@@ -2809,6 +2809,7 @@ implementation
          trecordsymtable(symtable).fieldalignment:=shortint(ppufile.getbyte);
          trecordsymtable(symtable).recordalignment:=shortint(ppufile.getbyte);
          trecordsymtable(symtable).padalignment:=shortint(ppufile.getbyte);
+         trecordsymtable(symtable).usefieldalignment:=shortint(ppufile.getbyte);  
          trecordsymtable(symtable).ppuload(ppufile);
          symtable.defowner:=self;
          isunion:=false;
@@ -2876,6 +2877,7 @@ implementation
          ppufile.putbyte(byte(trecordsymtable(symtable).fieldalignment));
          ppufile.putbyte(byte(trecordsymtable(symtable).recordalignment));
          ppufile.putbyte(byte(trecordsymtable(symtable).padalignment));
+         ppufile.putbyte(byte(trecordsymtable(symtable).usefieldalignment));
          ppufile.writeentry(ibrecorddef);
          trecordsymtable(symtable).ppuwrite(ppufile);
       end;

+ 1 - 7
compiler/symtable.pas

@@ -103,7 +103,6 @@ interface
           { no need to save in/restore from ppu file. datasize is always (databitsize+7) div 8.       }
           databitsize    : aint;
           { bitpacked? -> all fieldvarsym offsets are in bits instead of bytes }
-          packed_record: boolean;
         public
           property datasize : aint read _datasize write setdatasize;
        end;
@@ -831,7 +830,6 @@ implementation
         databitsize:=0;
         recordalignment:=1;
         usefieldalignment:=usealign;
-        packed_record:=usealign=bit_alignment;
         padalignment:=1;
         { recordalign C_alignment means C record packing, that starts
           with an alignment of 1 }
@@ -849,8 +847,6 @@ implementation
       var
         storesymtable : tsymtable;
       begin
-        packed_record:=boolean(ppufile.getbyte);
-
         storesymtable:=aktrecordsymtable;
         aktrecordsymtable:=self;
 
@@ -865,8 +861,6 @@ implementation
         oldtyp : byte;
         storesymtable : tsymtable;
       begin
-         ppufile.putbyte(byte(packed_record));
-
          storesymtable:=aktrecordsymtable;
          aktrecordsymtable:=self;
          oldtyp:=ppufile.entrytyp;
@@ -1059,7 +1053,7 @@ implementation
 
     function tabstractrecordsymtable.is_packed: boolean;
       begin
-        result:=packed_record;
+        result:=usefieldalignment=bit_alignment;
       end;
 
 

+ 17 - 0
tests/webtbf/tw7438.pp

@@ -0,0 +1,17 @@
+{ %norun }
+
+{$mode macpas}
+unit tw7438;
+
+interface
+
+type
+  tr = bitpacked record
+    l1: longint;
+    l2: longint;
+  end;
+
+
+implementation
+
+end.

+ 12 - 0
tests/webtbf/tw7438a.pp

@@ -0,0 +1,12 @@
+{ %fail }
+
+{$mode macpas}
+
+uses
+  tw7438;
+
+var
+  t: tr;
+begin
+  writeln(ptruint(@t.l2) - ptruint(@t.l1));
+end.