Explorar el Código

Handle FileIndex/Line/Column for change_nedian in token buffer for generics

git-svn-id: trunk@19014 -
pierre hace 14 años
padre
commit
47f39748f6
Se han modificado 2 ficheros con 52 adiciones y 8 borrados
  1. 25 5
      compiler/scanner.pas
  2. 27 3
      compiler/utils/ppudump.pp

+ 25 - 5
compiler/scanner.pas

@@ -176,6 +176,8 @@ interface
           procedure startreplaytokens(buf:tdynamicarray; achange_endian : boolean);
           procedure writesizeint(val : sizeint);
           function  readsizeint : sizeint;
+          function  readdword : dword;
+          function  readword : word;
           procedure readchar;
           procedure readstring;
           procedure readnumber;
@@ -2102,6 +2104,26 @@ In case not, the value returned can be arbitrary.
         result:=val;
       end;
 
+    function tscannerfile.readdword : dword;
+      var
+        val : dword;
+      begin
+        replaytokenbuf.read(val,sizeof(dword));
+        if tokenbuf_change_endian then
+          val:=swapendian(val);
+        result:=val;
+      end;
+
+    function tscannerfile.readword : word;
+      var
+        val : word;
+      begin
+        replaytokenbuf.read(val,sizeof(word));
+        if tokenbuf_change_endian then
+          val:=swapendian(val);
+        result:=val;
+      end;
+
     procedure tscannerfile.recordtoken;
       var
         t : ttoken;
@@ -2376,7 +2398,7 @@ In case not, the value returned can be arbitrary.
                       end;
                     ST_LINE:
                       begin
-                        replaytokenbuf.read(current_tokenpos.line,sizeof(current_tokenpos.line));
+                        current_tokenpos.line:=readdword;
 
                         { don't generate invalid line info if no sources are available for the current module }
                         if not(get_module(current_filepos.moduleindex).sources_avail) then
@@ -2386,8 +2408,7 @@ In case not, the value returned can be arbitrary.
                       end;
                     ST_COLUMN:
                       begin
-                        replaytokenbuf.read(current_tokenpos.column,sizeof(current_tokenpos.column));
-
+                        current_tokenpos.column:=readword;
                         { don't generate invalid line info if no sources are available for the current module }
                         if not(get_module(current_filepos.moduleindex).sources_avail) then
                           current_tokenpos.column:=0;
@@ -2396,8 +2417,7 @@ In case not, the value returned can be arbitrary.
                       end;
                     ST_FILEINDEX:
                       begin
-                        replaytokenbuf.read(current_tokenpos.fileindex,sizeof(current_tokenpos.fileindex));
-
+                        current_tokenpos.fileindex:=readword;
                         { don't generate invalid line info if no sources are available for the current module }
                         if not(get_module(current_filepos.moduleindex).sources_avail) then
                           begin

+ 27 - 3
compiler/utils/ppudump.pp

@@ -1108,6 +1108,29 @@ var
         result:=ttoken(b);
     end;
 
+  function gettokenbufdword : dword;
+  var
+    var32 : dword;
+  begin
+    var32:=pdword(@tokenbuf[i])^;
+    inc(i,sizeof(dword));
+    if ppufile.change_endian then
+      var32:=swapendian(var32);
+    result:=var32;
+  end;
+
+  function gettokenbufword : word;
+  var
+    var16 : word;
+  begin
+    var16:=pword(@tokenbuf[i])^;
+    inc(i,sizeof(word));
+    if ppufile.change_endian then
+      var16:=swapendian(var16);
+    result:=var16;
+  end;
+
+
   function gettokenbufsizeint : int64;
   var
     var64 : int64;
@@ -1255,6 +1278,7 @@ begin
                         new_settings.pmessage:=nil;
                         { TSettings size depends in target...
                           We first read the size of the copied part }
+                        { Still not cross endian ready :( }
                         copy_size:=gettokenbufsizeint;
                         if copy_size < sizeof(tsettings)-sizeof(pointer) then
                           min_size:=copy_size
@@ -1279,19 +1303,19 @@ begin
                     ST_LINE:
                       begin
                         inc(i);
-                        write('Line: ',pdword(@tokenbuf[i])^);
+                        write('Line: ',gettokenbufdword);
                         inc(i,4);
                       end;
                     ST_COLUMN:
                       begin
                         inc(i);
-                        write('Col: ',pword(@tokenbuf[i])^);
+                        write('Col: ',gettokenbufword);
                         inc(i,2);
                       end;
                     ST_FILEINDEX:
                       begin
                         inc(i);
-                        write('File: ',pword(@tokenbuf[i])^);
+                        write('File: ',gettokenbufword);
                         inc(i,2);
                       end;
                   end;