mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 13:29:27 +02:00
* always store generics token streams in little endian, so we don't have to
keep a separate field for each tstoreddef that records whether the endianness needs to be swapped git-svn-id: trunk@21914 -
This commit is contained in:
parent
25b80bedf9
commit
07ebc51b6c
@ -397,8 +397,7 @@ uses
|
||||
{ use the index the module got from the current compilation process }
|
||||
current_filepos.moduleindex:=hmodule.unit_index;
|
||||
current_tokenpos:=current_filepos;
|
||||
current_scanner.startreplaytokens(genericdef.generictokenbuf,
|
||||
genericdef.change_endian);
|
||||
current_scanner.startreplaytokens(genericdef.generictokenbuf);
|
||||
read_named_type(tt,srsym,genericdef,generictypelist,false);
|
||||
current_filepos:=oldcurrent_filepos;
|
||||
ttypesym(srsym).typedef:=tt;
|
||||
|
@ -43,7 +43,7 @@ type
|
||||
{$endif Test_Double_checksum}
|
||||
|
||||
const
|
||||
CurrentPPUVersion = 151;
|
||||
CurrentPPUVersion = 152;
|
||||
|
||||
{ buffer sizes }
|
||||
maxentrysize = 1024;
|
||||
|
@ -2216,8 +2216,7 @@ implementation
|
||||
{ use the index the module got from the current compilation process }
|
||||
current_filepos.moduleindex:=hmodule.unit_index;
|
||||
current_tokenpos:=current_filepos;
|
||||
current_scanner.startreplaytokens(tprocdef(tprocdef(hp).genericdef).generictokenbuf,
|
||||
tprocdef(tprocdef(hp).genericdef).change_endian);
|
||||
current_scanner.startreplaytokens(tprocdef(tprocdef(hp).genericdef).generictokenbuf);
|
||||
read_proc_body(nil,tprocdef(hp));
|
||||
current_filepos:=oldcurrent_filepos;
|
||||
end
|
||||
|
@ -71,9 +71,8 @@ interface
|
||||
settings : tsettings;
|
||||
tokenbuf : tdynamicarray;
|
||||
next : treplaystack;
|
||||
change_endian : boolean;
|
||||
constructor Create(atoken: ttoken;asettings:tsettings;
|
||||
atokenbuf:tdynamicarray;anext:treplaystack; achange_endian : boolean);
|
||||
atokenbuf:tdynamicarray;anext:treplaystack);
|
||||
end;
|
||||
|
||||
tcompile_time_predicate = function(var valuedescr: String) : Boolean;
|
||||
@ -118,7 +117,6 @@ interface
|
||||
|
||||
replaytokenbuf,
|
||||
recordtokenbuf : tdynamicarray;
|
||||
tokenbuf_change_endian : boolean;
|
||||
|
||||
{ last settings we stored }
|
||||
last_settings : tsettings;
|
||||
@ -173,7 +171,7 @@ interface
|
||||
procedure startrecordtokens(buf:tdynamicarray);
|
||||
procedure stoprecordtokens;
|
||||
procedure replaytoken;
|
||||
procedure startreplaytokens(buf:tdynamicarray; achange_endian : boolean);
|
||||
procedure startreplaytokens(buf:tdynamicarray);
|
||||
{ bit length asizeint is target depend }
|
||||
procedure tokenwritesizeint(val : asizeint);
|
||||
procedure tokenwritelongint(val : longint);
|
||||
@ -1960,12 +1958,11 @@ In case not, the value returned can be arbitrary.
|
||||
TReplayStack
|
||||
*****************************************************************************}
|
||||
constructor treplaystack.Create(atoken:ttoken;asettings:tsettings;
|
||||
atokenbuf:tdynamicarray;anext:treplaystack;achange_endian : boolean);
|
||||
atokenbuf:tdynamicarray;anext:treplaystack);
|
||||
begin
|
||||
token:=atoken;
|
||||
settings:=asettings;
|
||||
tokenbuf:=atokenbuf;
|
||||
change_endian:=achange_endian;
|
||||
next:=anext;
|
||||
end;
|
||||
|
||||
@ -2007,7 +2004,6 @@ In case not, the value returned can be arbitrary.
|
||||
{ reset scanner }
|
||||
preprocstack:=nil;
|
||||
replaystack:=nil;
|
||||
tokenbuf_change_endian:=false;
|
||||
comment_level:=0;
|
||||
yylexcount:=0;
|
||||
block_type:=bt_general;
|
||||
@ -2186,26 +2182,41 @@ In case not, the value returned can be arbitrary.
|
||||
|
||||
procedure tscannerfile.tokenwritesizeint(val : asizeint);
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
recordtokenbuf.write(val,sizeof(asizeint));
|
||||
end;
|
||||
|
||||
procedure tscannerfile.tokenwritelongint(val : longint);
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
recordtokenbuf.write(val,sizeof(longint));
|
||||
end;
|
||||
|
||||
procedure tscannerfile.tokenwriteshortint(val : shortint);
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
recordtokenbuf.write(val,sizeof(shortint));
|
||||
end;
|
||||
|
||||
procedure tscannerfile.tokenwriteword(val : word);
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
recordtokenbuf.write(val,sizeof(word));
|
||||
end;
|
||||
|
||||
procedure tscannerfile.tokenwritelongword(val : longword);
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
recordtokenbuf.write(val,sizeof(longword));
|
||||
end;
|
||||
|
||||
@ -2214,8 +2225,9 @@ In case not, the value returned can be arbitrary.
|
||||
val : asizeint;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(asizeint));
|
||||
if tokenbuf_change_endian then
|
||||
val:=swapendian(val);
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
result:=val;
|
||||
end;
|
||||
|
||||
@ -2224,8 +2236,9 @@ In case not, the value returned can be arbitrary.
|
||||
val : longword;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(longword));
|
||||
if tokenbuf_change_endian then
|
||||
val:=swapendian(val);
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
result:=val;
|
||||
end;
|
||||
|
||||
@ -2234,8 +2247,9 @@ In case not, the value returned can be arbitrary.
|
||||
val : longint;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(longint));
|
||||
if tokenbuf_change_endian then
|
||||
val:=swapendian(val);
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
result:=val;
|
||||
end;
|
||||
|
||||
@ -2260,8 +2274,9 @@ In case not, the value returned can be arbitrary.
|
||||
val : smallint;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(smallint));
|
||||
if tokenbuf_change_endian then
|
||||
val:=swapendian(val);
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
result:=val;
|
||||
end;
|
||||
|
||||
@ -2270,8 +2285,9 @@ In case not, the value returned can be arbitrary.
|
||||
val : word;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(word));
|
||||
if tokenbuf_change_endian then
|
||||
val:=swapendian(val);
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
val:=swapendian(val);
|
||||
{$endif}
|
||||
result:=val;
|
||||
end;
|
||||
|
||||
@ -2286,13 +2302,16 @@ In case not, the value returned can be arbitrary.
|
||||
end;
|
||||
|
||||
procedure tscannerfile.tokenreadset(var b;size : longint);
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
var
|
||||
i : longint;
|
||||
{$endif}
|
||||
begin
|
||||
replaytokenbuf.read(b,size);
|
||||
if tokenbuf_change_endian then
|
||||
for i:=0 to size-1 do
|
||||
Pbyte(@b)[i]:=reverse_byte(Pbyte(@b)[i]);
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
for i:=0 to size-1 do
|
||||
Pbyte(@b)[i]:=reverse_byte(Pbyte(@b)[i]);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure tscannerfile.tokenwriteenum(var b;size : longint);
|
||||
@ -2301,8 +2320,19 @@ In case not, the value returned can be arbitrary.
|
||||
end;
|
||||
|
||||
procedure tscannerfile.tokenwriteset(var b;size : longint);
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
var
|
||||
i: longint;
|
||||
tmpset: array[0..31] of byte;
|
||||
{$endif}
|
||||
begin
|
||||
{$ifdef FPC_BIG_ENDIAN}
|
||||
for i:=0 to size-1 do
|
||||
tmpset[i]:=reverse_byte(Pbyte(@b)[i]);
|
||||
recordtokenbuf.write(tmpset,size);
|
||||
{$else}
|
||||
recordtokenbuf.write(b,size);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
|
||||
@ -2577,7 +2607,7 @@ In case not, the value returned can be arbitrary.
|
||||
end;
|
||||
|
||||
|
||||
procedure tscannerfile.startreplaytokens(buf:tdynamicarray; achange_endian : boolean);
|
||||
procedure tscannerfile.startreplaytokens(buf:tdynamicarray);
|
||||
begin
|
||||
if not assigned(buf) then
|
||||
internalerror(200511175);
|
||||
@ -2585,12 +2615,11 @@ In case not, the value returned can be arbitrary.
|
||||
if token in [_CWCHAR,_CWSTRING,_CCHAR,_CSTRING,_INTCONST,_REALNUMBER,_ID] then
|
||||
internalerror(200511178);
|
||||
replaystack:=treplaystack.create(token,current_settings,
|
||||
replaytokenbuf,replaystack,tokenbuf_change_endian);
|
||||
replaytokenbuf,replaystack);
|
||||
if assigned(inputpointer) then
|
||||
dec(inputpointer);
|
||||
{ install buffer }
|
||||
replaytokenbuf:=buf;
|
||||
tokenbuf_change_endian:=achange_endian;
|
||||
|
||||
{ reload next token }
|
||||
replaytokenbuf.seek(0);
|
||||
@ -3121,10 +3150,6 @@ In case not, the value returned can be arbitrary.
|
||||
hp:=replaystack.next;
|
||||
replaystack.free;
|
||||
replaystack:=hp;
|
||||
if assigned (replaystack) then
|
||||
tokenbuf_change_endian:=replaystack.change_endian
|
||||
else
|
||||
tokenbuf_change_endian:=false;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -61,9 +61,6 @@ interface
|
||||
genericdef : tstoreddef;
|
||||
genericdefderef : tderef;
|
||||
generictokenbuf : tdynamicarray;
|
||||
{ Set if PPU was generated with another
|
||||
endianess as current compiler or ppudump utils }
|
||||
change_endian : boolean;
|
||||
constructor create(dt:tdeftyp);
|
||||
constructor ppuload(dt:tdeftyp;ppufile:tcompilerppufile);
|
||||
destructor destroy;override;
|
||||
@ -1337,7 +1334,6 @@ implementation
|
||||
{$endif}
|
||||
generictokenbuf:=nil;
|
||||
genericdef:=nil;
|
||||
change_endian:=false;
|
||||
|
||||
{ Don't register forwarddefs, they are disposed at the
|
||||
end of an type block }
|
||||
@ -1395,7 +1391,6 @@ implementation
|
||||
if df_generic in defoptions then
|
||||
begin
|
||||
sizeleft:=ppufile.getlongint;
|
||||
change_endian:=ppufile.change_endian;
|
||||
initgeneric;
|
||||
while sizeleft>0 do
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user