mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-05 08:09:52 +01:00
Hopefully fix problems related to loading of ppufile generated with other endianess for generics
git-svn-id: trunk@44056 -
This commit is contained in:
parent
6a1c09bb43
commit
d1e4066477
@ -660,7 +660,7 @@ implementation
|
||||
isunique,
|
||||
istyperenaming : boolean;
|
||||
generictypelist : tfphashobjectlist;
|
||||
generictokenbuf : tdynamicarray;
|
||||
localgenerictokenbuf : tdynamicarray;
|
||||
p:tnode;
|
||||
gendef : tstoreddef;
|
||||
s : shortstring;
|
||||
@ -682,7 +682,7 @@ implementation
|
||||
defpos:=current_tokenpos;
|
||||
istyperenaming:=false;
|
||||
generictypelist:=nil;
|
||||
generictokenbuf:=nil;
|
||||
localgenerictokenbuf:=nil;
|
||||
|
||||
{ class attribute definitions? }
|
||||
if m_prefixed_attributes in current_settings.modeswitches then
|
||||
@ -744,8 +744,8 @@ implementation
|
||||
{ Start recording a generic template }
|
||||
if assigned(generictypelist) then
|
||||
begin
|
||||
generictokenbuf:=tdynamicarray.create(256);
|
||||
current_scanner.startrecordtokens(generictokenbuf);
|
||||
localgenerictokenbuf:=tdynamicarray.create(256);
|
||||
current_scanner.startrecordtokens(localgenerictokenbuf);
|
||||
end;
|
||||
|
||||
{ is the type already defined? -- must be in the current symtable,
|
||||
@ -1132,7 +1132,7 @@ implementation
|
||||
if assigned(generictypelist) then
|
||||
begin
|
||||
current_scanner.stoprecordtokens;
|
||||
tstoreddef(hdef).generictokenbuf:=generictokenbuf;
|
||||
tstoreddef(hdef).generictokenbuf:=localgenerictokenbuf;
|
||||
{ Generic is never a type renaming }
|
||||
hdef.typesym:=newtype;
|
||||
generictypelist.free;
|
||||
|
||||
@ -970,7 +970,7 @@ uses
|
||||
replaydepth:=current_scanner.replay_stack_depth;
|
||||
if genericdef.typ=procdef then
|
||||
begin
|
||||
current_scanner.startreplaytokens(tprocdef(genericdef).genericdecltokenbuf);
|
||||
current_scanner.startreplaytokens(tprocdef(genericdef).genericdecltokenbuf,tprocdef(genericdef).generic_buf_needs_swapping);
|
||||
parse_proc_head(tprocdef(genericdef).struct,tprocdef(genericdef).proctypeoption,false,genericdef,generictypelist,pd);
|
||||
if assigned(pd) then
|
||||
begin
|
||||
@ -984,7 +984,7 @@ uses
|
||||
end
|
||||
else
|
||||
begin
|
||||
current_scanner.startreplaytokens(genericdef.generictokenbuf);
|
||||
current_scanner.startreplaytokens(genericdef.generictokenbuf,genericdef.generic_buf_needs_swapping);
|
||||
hadtypetoken:=false;
|
||||
read_named_type(result,srsym,genericdef,generictypelist,false,hadtypetoken);
|
||||
ttypesym(srsym).typedef:=result;
|
||||
@ -1632,7 +1632,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(tprocdef(def.genericdef).generictokenbuf);
|
||||
current_scanner.startreplaytokens(tprocdef(def.genericdef).generictokenbuf,tprocdef(def.genericdef).generic_buf_needs_swapping);
|
||||
read_proc_body(def);
|
||||
current_filepos:=oldcurrent_filepos;
|
||||
end
|
||||
|
||||
@ -75,11 +75,12 @@ interface
|
||||
patternw : pcompilerwidestring;
|
||||
settings : tsettings;
|
||||
tokenbuf : tdynamicarray;
|
||||
tokenbuf_needs_swapping : boolean;
|
||||
next : treplaystack;
|
||||
constructor Create(atoken: ttoken;aidtoken:ttoken;
|
||||
const aorgpattern,apattern:string;const acstringpattern:ansistring;
|
||||
apatternw:pcompilerwidestring;asettings:tsettings;
|
||||
atokenbuf:tdynamicarray;anext:treplaystack);
|
||||
atokenbuf:tdynamicarray;change_endian:boolean;anext:treplaystack);
|
||||
destructor destroy;override;
|
||||
end;
|
||||
|
||||
@ -145,8 +146,8 @@ interface
|
||||
|
||||
{ true, if we are parsing preprocessor expressions }
|
||||
in_preproc_comp_expr : boolean;
|
||||
{ true if cross-compiling for a CPU in opposite endianess}
|
||||
change_endian_for_tokens : boolean;
|
||||
{ true if tokens must be converted to opposite endianess}
|
||||
change_endian_for_replay : boolean;
|
||||
|
||||
constructor Create(const fn:string; is_macro: boolean = false);
|
||||
destructor Destroy;override;
|
||||
@ -184,7 +185,7 @@ interface
|
||||
procedure stoprecordtokens;
|
||||
function is_recording_tokens:boolean;
|
||||
procedure replaytoken;
|
||||
procedure startreplaytokens(buf:tdynamicarray);
|
||||
procedure startreplaytokens(buf:tdynamicarray; change_endian:boolean);
|
||||
{ bit length asizeint is target depend }
|
||||
procedure tokenwritesizeint(val : asizeint);
|
||||
procedure tokenwritelongint(val : longint);
|
||||
@ -2645,7 +2646,7 @@ type
|
||||
constructor treplaystack.Create(atoken:ttoken;aidtoken:ttoken;
|
||||
const aorgpattern,apattern:string;const acstringpattern:ansistring;
|
||||
apatternw:pcompilerwidestring;asettings:tsettings;
|
||||
atokenbuf:tdynamicarray;anext:treplaystack);
|
||||
atokenbuf:tdynamicarray;change_endian:boolean;anext:treplaystack);
|
||||
begin
|
||||
token:=atoken;
|
||||
idtoken:=aidtoken;
|
||||
@ -2660,6 +2661,7 @@ type
|
||||
end;
|
||||
settings:=asettings;
|
||||
tokenbuf:=atokenbuf;
|
||||
tokenbuf_needs_swapping:=change_endian;
|
||||
next:=anext;
|
||||
end;
|
||||
|
||||
@ -2717,11 +2719,8 @@ type
|
||||
lasttoken:=NOTOKEN;
|
||||
nexttoken:=NOTOKEN;
|
||||
ignoredirectives:=TFPHashList.Create;
|
||||
if (current_module is tppumodule) and assigned(tppumodule(current_module).ppufile) then
|
||||
change_endian_for_tokens:=tppumodule(current_module).ppufile.change_endian
|
||||
else
|
||||
change_endian_for_tokens:=false;
|
||||
end;
|
||||
change_endian_for_replay:=false;
|
||||
end;
|
||||
|
||||
|
||||
procedure tscannerfile.firstfile;
|
||||
@ -2921,7 +2920,7 @@ type
|
||||
val : asizeint;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(asizeint));
|
||||
if change_endian_for_tokens then
|
||||
if change_endian_for_replay then
|
||||
val:=swapendian(val);
|
||||
result:=val;
|
||||
end;
|
||||
@ -2931,7 +2930,7 @@ type
|
||||
val : longword;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(longword));
|
||||
if change_endian_for_tokens then
|
||||
if change_endian_for_replay then
|
||||
val:=swapendian(val);
|
||||
result:=val;
|
||||
end;
|
||||
@ -2941,7 +2940,7 @@ type
|
||||
val : longint;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(longint));
|
||||
if change_endian_for_tokens then
|
||||
if change_endian_for_replay then
|
||||
val:=swapendian(val);
|
||||
result:=val;
|
||||
end;
|
||||
@ -2967,7 +2966,7 @@ type
|
||||
val : smallint;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(smallint));
|
||||
if change_endian_for_tokens then
|
||||
if change_endian_for_replay then
|
||||
val:=swapendian(val);
|
||||
result:=val;
|
||||
end;
|
||||
@ -2977,7 +2976,7 @@ type
|
||||
val : word;
|
||||
begin
|
||||
replaytokenbuf.read(val,sizeof(word));
|
||||
if change_endian_for_tokens then
|
||||
if change_endian_for_replay then
|
||||
val:=swapendian(val);
|
||||
result:=val;
|
||||
end;
|
||||
@ -2999,7 +2998,7 @@ type
|
||||
i : longint;
|
||||
begin
|
||||
replaytokenbuf.read(b,size);
|
||||
if change_endian_for_tokens then
|
||||
if change_endian_for_replay then
|
||||
for i:=0 to size-1 do
|
||||
Pbyte(@b)[i]:=reverse_byte(Pbyte(@b)[i]);
|
||||
end;
|
||||
@ -3315,18 +3314,22 @@ type
|
||||
end;
|
||||
|
||||
|
||||
procedure tscannerfile.startreplaytokens(buf:tdynamicarray);
|
||||
procedure tscannerfile.startreplaytokens(buf:tdynamicarray; change_endian:boolean);
|
||||
begin
|
||||
if not assigned(buf) then
|
||||
internalerror(200511175);
|
||||
|
||||
{ save current scanner state }
|
||||
replaystack:=treplaystack.create(token,idtoken,orgpattern,pattern,
|
||||
cstringpattern,patternw,current_settings,replaytokenbuf,replaystack);
|
||||
cstringpattern,patternw,current_settings,replaytokenbuf,change_endian_for_replay,replaystack);
|
||||
if assigned(inputpointer) then
|
||||
dec(inputpointer);
|
||||
{ install buffer }
|
||||
replaytokenbuf:=buf;
|
||||
|
||||
{ Initialize value of change_endian_for_replay variable }
|
||||
change_endian_for_replay:=change_endian;
|
||||
|
||||
{ reload next token }
|
||||
replaytokenbuf.seek(0);
|
||||
replaytoken;
|
||||
@ -3368,6 +3371,7 @@ type
|
||||
move(replaystack.patternw^.data^,patternw^.data^,replaystack.patternw^.len*sizeof(tcompilerwidechar));
|
||||
cstringpattern:=replaystack.cstringpattern;
|
||||
replaytokenbuf:=replaystack.tokenbuf;
|
||||
change_endian_for_replay:=replaystack.tokenbuf_needs_swapping;
|
||||
{ restore compiler settings }
|
||||
current_settings:=replaystack.settings;
|
||||
popreplaystack;
|
||||
|
||||
@ -126,6 +126,7 @@ interface
|
||||
genericdef : tstoreddef;
|
||||
genericdefderef : tderef;
|
||||
generictokenbuf : tdynamicarray;
|
||||
generic_buf_needs_swapping : boolean;
|
||||
{ this list contains references to the symbols that make up the
|
||||
generic parameters; the symbols are not owned by this list
|
||||
Note: this list is allocated on demand! }
|
||||
@ -1889,6 +1890,7 @@ implementation
|
||||
fileinfo := current_filepos;
|
||||
{$endif}
|
||||
generictokenbuf:=nil;
|
||||
generic_buf_needs_swapping:=false;
|
||||
genericdef:=nil;
|
||||
typesymderef.reset;
|
||||
genericdefderef.reset;
|
||||
@ -1983,6 +1985,7 @@ implementation
|
||||
begin
|
||||
sizeleft:=ppufile.getlongint;
|
||||
initgeneric;
|
||||
generic_buf_needs_swapping:=ppufile.change_endian;
|
||||
while sizeleft>0 do
|
||||
begin
|
||||
if sizeleft>sizeof(buf) then
|
||||
@ -6024,6 +6027,7 @@ implementation
|
||||
import_nr:=0;
|
||||
inlininginfo:=nil;
|
||||
deprecatedmsg:=nil;
|
||||
genericdecltokenbuf:=nil;
|
||||
if cs_opt_fastmath in current_settings.optimizerswitches then
|
||||
include(implprocoptions, pio_fastmath);
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user