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