* packed tabstractvarsym.addr_taken/different_scope fields into a set

git-svn-id: trunk@43450 -
This commit is contained in:
Jonas Maebe 2019-11-11 09:26:51 +00:00
parent 5f3050961f
commit 2f914ee2d8
4 changed files with 78 additions and 12 deletions

View File

@ -50,7 +50,7 @@ const
CurrentPPUVersion = 207;
{ for any other changes to the ppu format, increase this version number
(it's a cardinal) }
CurrentPPULongVersion = 7;
CurrentPPULongVersion = 8;
{ unit flags }
uf_big_endian = $000004;

View File

@ -611,6 +611,15 @@ type
);
tvaroptions=set of tvaroption;
{ variable symbol access flags }
tvarsymaccessflag = (
{ this symbol's address has been taken }
vsa_addr_taken,
{ this symbol is accessed from a different scope }
vsa_different_scope
);
tvarsymaccessflags = set of tvarsymaccessflag;
tmanagementoperator=(mop_none,
mop_initialize,
mop_finalize,

View File

@ -179,13 +179,9 @@ interface
varspez : tvarspez; { sets the type of access }
varregable : tvarregable;
varstate : tvarstate;
{ Has the address of this variable potentially escaped the
block in which is was declared?
could also be part of tabstractnormalvarsym, but there's
one byte left here till the next 4 byte alignment }
addr_taken : boolean;
{ true if the variable is accessed in a different scope }
different_scope : boolean;
{could also be part of tabstractnormalvarsym, but there's
one byte left here till the next 4 byte alignment }
varsymaccess : tvarsymaccessflags;
constructor create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
procedure ppuwrite(ppufile:tcompilerppufile);override;
@ -198,11 +194,17 @@ interface
_vardef : tdef;
vardefderef : tderef;
function get_addr_taken: boolean;
function get_different_scope: boolean;
procedure setregable;
procedure setvardef(const def: tdef);
procedure setvardef_and_regable(def:tdef);
procedure set_addr_taken(AValue: boolean);
procedure set_different_scope(AValue: boolean);
public
property vardef: tdef read _vardef write setvardef_and_regable;
property addr_taken: boolean read get_addr_taken write set_addr_taken;
property different_scope: boolean read get_different_scope write set_different_scope;
end;
tfieldvarsym = class(tabstractvarsym)
@ -1638,8 +1640,7 @@ implementation
varstate:=vs_readwritten;
varspez:=tvarspez(ppufile.getbyte);
varregable:=tvarregable(ppufile.getbyte);
addr_taken:=ppufile.getboolean;
different_scope:=ppufile.getboolean;
ppufile.getset(tppuset1(varsymaccess));
ppufile.getderef(vardefderef);
ppufile.getset(tppuset4(varoptions));
end;
@ -1671,8 +1672,7 @@ implementation
oldintfcrc:=ppufile.do_crc;
ppufile.do_crc:=false;
ppufile.putbyte(byte(varregable));
ppufile.putboolean(addr_taken);
ppufile.putboolean(different_scope);
ppufile.putset(tppuset1(varsymaccess));
ppufile.do_crc:=oldintfcrc;
ppufile.putderef(vardefderef);
ppufile.putset(tppuset4(varoptions));
@ -1731,6 +1731,24 @@ implementation
end;
procedure tabstractvarsym.set_addr_taken(AValue: boolean);
begin
if AValue then
include(varsymaccess, vsa_addr_taken)
else
exclude(varsymaccess, vsa_addr_taken);
end;
procedure tabstractvarsym.set_different_scope(AValue: boolean);
begin
if AValue then
include(varsymaccess, vsa_different_scope)
else
exclude(varsymaccess, vsa_different_scope);
end;
procedure tabstractvarsym.setregable;
begin
if vo_volatile in varoptions then
@ -1771,6 +1789,18 @@ implementation
end;
function tabstractvarsym.get_addr_taken: boolean;
begin
result:=vsa_addr_taken in varsymaccess;
end;
function tabstractvarsym.get_different_scope: boolean;
begin
result:=vsa_different_scope in varsymaccess;
end;
procedure tabstractvarsym.setvardef(const def: tdef);
begin
_vardef := def;

View File

@ -3070,8 +3070,20 @@ const
(mask:vo_is_default_var; str:'DefaultIntrinsicVar'),
(mask:vo_is_far; str:'IsFar')
);
type
tvaraccessdesc=record
mask: tvarsymaccessflag;
str: string[30];
end;
const
varaccessstr : array[ord(low(tvarsymaccessflag))..ord(high(tvarsymaccessflag))] of tvaraccessdesc=(
(mask: vsa_addr_taken; str:'Address taken'),
(mask: vsa_different_scope; str:'Accessed from different scope')
);
var
i : longint;
accessflag: tvarsymaccessflag;
varsymaccessflags: tvarsymaccessflags;
first : boolean;
begin
readcommonsym(s, VarDef);
@ -3087,6 +3099,21 @@ begin
end;
writeln([space,' Spez : ',Varspez2Str(i)]);
writeln([space,' Regable : ',Varregable2Str(ppufile.getbyte)]);
ppufile.getset(tppuset1(varsymaccessflags));
write([space, ' Access Flags : ']);
first:=true;
for i:=low(varaccessstr) to high(varaccessstr) do
begin
if varaccessstr[i].mask in varsymaccessflags then
begin
if first then
first:=false
else
write([', ']);
write([varaccessstr[i].str]);
end
end;
writeln;
writeln([space,' Addr Taken : ',(ppufile.getbyte<>0)]);
writeln([space,'Escaped Scope : ',(ppufile.getbyte<>0)]);
write ([space,' Var Type : ']);