Browse Source

* Fix failures introduced by rev 18975

git-svn-id: trunk@18976 -
pierre 14 years ago
parent
commit
b526bb4dfa
3 changed files with 19 additions and 31 deletions
  1. 1 1
      compiler/ppu.pas
  2. 11 29
      compiler/scanner.pas
  3. 7 1
      compiler/utils/ppudump.pp

+ 1 - 1
compiler/ppu.pas

@@ -247,7 +247,6 @@ type
     crc_test2  : pcrc_array;
   private
 {$endif def Test_Double_checksum}
-    change_endian : boolean;
     buf      : pchar;
     bufstart,
     bufsize,
@@ -263,6 +262,7 @@ type
     entrytyp : byte;
     header           : tppuheader;
     size             : integer;
+    change_endian    : boolean; { Used in ppudump util }
     { crc for the entire unit }
     crc,
     { crc for the interface definitions in this unit }

+ 11 - 29
compiler/scanner.pas

@@ -250,25 +250,6 @@ implementation
       symbase,symtable,symtype,symsym,symconst,symdef,defutil,
       fmodule;
 
-   const
-   { Same valus as in ppu unit, but
-   their only goal here is to set change_endian constant }
-
-     uf_big_endian          = $000004;
-     uf_little_endian       = $001000;
-   {$ifdef FPC_BIG_ENDIAN}
-       target_flags = uf_little_endian;
-   {$else not FPC_BIG_ENDIAN}
-       target_flags = uf_big_endian;
-   {$endif not FPC_BIG_ENDIAN}
-   {$IFDEF ENDIAN_LITTLE}
-       source_flags = uf_little_endian;
-   {$ELSE}
-       source_flags = uf_big_endian;
-   {$ENDIF}
-     { Change_endian must be use to store recordtokenbuf in
-       target endian order }
-       change_endian = (source_flags<>target_flags);
     var
       { dictionaries with the supported directives }
       turbo_scannerdirectives : TFPHashObjectList;     { for other modes }
@@ -284,7 +265,6 @@ implementation
       preprocstring : array [preproctyp] of string[7]
         = ('$IFDEF','$IFNDEF','$IF','$IFOPT','$ELSE','$ELSEIF');
 
-
     function is_keyword(const s:string):boolean;
       var
         low,high,mid : longint;
@@ -2103,7 +2083,7 @@ In case not, the value returned can be arbitrary.
 
     procedure tscannerfile.writesizeint(val : sizeint);
       begin
-        if change_endian then
+        if target_info.endian <> source_info.endian then
           val:=swapendian(val);
         recordtokenbuf.write(val,sizeof(sizeint));
       end;
@@ -2113,7 +2093,7 @@ In case not, the value returned can be arbitrary.
         val : sizeint;
       begin
         replaytokenbuf.read(val,sizeof(sizeint));
-        if change_endian then
+        if target_info.endian <> source_info.endian then
           val:=swapendian(val);
         result:=val;
       end;
@@ -2122,8 +2102,7 @@ In case not, the value returned can be arbitrary.
       var
         t : ttoken;
         s : tspecialgenerictoken;
-        len,val,msgnb : sizeint;
-        copy_size : longint;
+        len,val,msgnb,copy_size : sizeint;
         b : byte;
         pmsg : pmessagestaterecord;
       begin
@@ -2138,7 +2117,7 @@ In case not, the value returned can be arbitrary.
             writetoken(t);
             recordtokenbuf.write(s,1);
             copy_size:=sizeof(current_settings)-sizeof(pointer);
-            recordtokenbuf.write(copy_size,sizeof(longint));
+            writesizeint(copy_size);
             recordtokenbuf.write(current_settings,copy_size);
             last_settings:=current_settings;
           end;
@@ -2282,7 +2261,7 @@ In case not, the value returned can be arbitrary.
 
     procedure tscannerfile.replaytoken;
       var
-        wlen,mesgnb : sizeint;
+        wlen,mesgnb,copy_size : sizeint;
         specialtoken : tspecialgenerictoken;
         i : byte;
         pmsg,prevmsg : pmessagestaterecord;
@@ -2361,8 +2340,12 @@ In case not, the value returned can be arbitrary.
                 else
                   case specialtoken of
                     ST_LOADSETTINGS:
-                      replaytokenbuf.read(current_settings,
-                        sizeof(current_settings)-sizeof(pointer));
+                      begin
+                        copy_size:=readsizeint;
+                        if copy_size <> sizeof(current_settings)-sizeof(pointer) then
+                          internalerror(2011090501);
+                        replaytokenbuf.read(current_settings,copy_size);
+                      end;
                     ST_LOADMESSAGES:
                       begin
                         current_settings.pmessage:=nil;
@@ -4546,5 +4529,4 @@ exit_label:
         DoneWideString(patternw);
       end;
 
-
 end.

+ 7 - 1
compiler/utils/ppudump.pp

@@ -936,19 +936,25 @@ var
       begin
         var64:=pint64(@tokenbuf[i])^;
         inc(i,sizeof(int64));
+        if ppufile.change_endian then
+          var64:=swapendian(var64);
         result:=var64;
       end
     else if CpuAddrBitSize[cpu]=32 then
       begin
         var32:=plongint(@tokenbuf[i])^;
         inc(i,sizeof(longint));
+        if ppufile.change_endian then
+          var32:=swapendian(var32);
         result:=var32;
       end
     else if CpuAddrBitSize[cpu]=16 then
       begin
         var16:=psmallint(@tokenbuf[i])^;
         inc(i,sizeof(smallint));
-        result:=var32;
+        if ppufile.change_endian then
+          var16:=swapendian(var16);
+        result:=var16;
       end
     else
       begin