* changed TIDString and tsymentry.realname to TSymStr

o for TIDString: prevents shortstring -> ansistring conversions with
     -dsymansistr when looking up symbols
   o for realname: consistency with name

git-svn-id: trunk@47301 -
This commit is contained in:
Jonas Maebe 2020-11-03 21:34:22 +00:00
parent 38a059f039
commit 312f1436b1
6 changed files with 97 additions and 69 deletions

View File

@ -787,7 +787,11 @@ interface
TRADirection = (rad_forward, rad_backwards, rad_backwards_reinit);
type
{$ifndef symansistr}
TIDString = string[maxidlen];
{$else}
TIDString = TSymStr;
{$endif}
tnormalset = set of byte; { 256 elements set }
pnormalset = ^tnormalset;

View File

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

View File

@ -71,15 +71,15 @@ interface
{ this object is the base for all symbol objects }
TSymEntry = class(TFPHashObject)
private
FRealName : pshortstring;
function GetRealname:shortstring;
procedure SetRealname(const ANewName:shortstring);
FRealName : {$ifdef symansistr}TSymStr{$else}pshortstring{$endif};
function GetRealname: TSymStr;
procedure SetRealname(const ANewName: TSymStr);
public
typ : tsymtyp;
SymId : longint;
Owner : TSymtable;
destructor destroy;override;
property RealName:shortstring read GetRealName write SetRealName;
property RealName: TSymStr read GetRealName write SetRealName;
end;
{************************************************
@ -167,6 +167,10 @@ implementation
procedure THashedIDString.SetId(const s:TIDString);
begin
FId:=s;
{$ifdef symansistr}
if length(FId)>maxidlen then
SetLength(FId,maxidlen);
{$endif}
FHash:=FPHash(s);
end;
@ -180,7 +184,9 @@ implementation
{$ifdef MEMDEBUG}
memrealnames.start;
{$endif MEMDEBUG}
{$ifndef symansistr}
stringdispose(Frealname);
{$endif}
{$ifdef MEMDEBUG}
memrealnames.stop;
{$endif MEMDEBUG}
@ -188,24 +194,34 @@ implementation
end;
function TSymEntry.GetRealname:shortstring;
function TSymEntry.GetRealname:TSymStr;
begin
{$ifndef symansistr}
if not assigned(FRealname) then
internalerror(200611011);
result:=FRealname^;
{$else}
if FRealName='' then
internalerror(200611011);
result:=FRealName;
{$endif}
end;
procedure TSymEntry.SetRealname(const ANewName:shortstring);
procedure TSymEntry.SetRealname(const ANewName:TSymStr);
begin
{$ifndef symansistr}
stringdispose(FRealname);
FRealname:=stringdup(ANewName);
{$else}
FRealname:=ANewName;
{$endif}
if Hash<>$ffffffff then
begin
if FRealname^[1]='$' then
Rename(Copy(FRealname^,2,255))
if ANewName[1]='$' then
Rename(Copy(ANewName,2,length(ANewName)))
else
Rename(Upper(FRealname^));
Rename(Upper(ANewName));
end;
end;

View File

@ -48,7 +48,7 @@ interface
public
{ this is Nil if the symbol has no RTTI attributes }
rtti_attribute_list : trtti_attribute_list;
constructor create(st:tsymtyp;const n : string);
constructor create(st:tsymtyp;const n : TSymStr);
constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
destructor destroy;override;
procedure ppuwrite(ppufile:tcompilerppufile);virtual;
@ -76,7 +76,7 @@ interface
{ when the label is defined in an asm block, this points to the
generated asmlabel }
asmblocklabel : tasmlabel;
constructor create(const n : string);virtual;
constructor create(const n : TSymStr);virtual;
constructor ppuload(ppufile:tcompilerppufile);
{ do not override this routine in platform-specific subclasses,
override ppuwrite_platform instead }
@ -87,7 +87,7 @@ interface
tunitsym = class(Tstoredsym)
module : tobject; { tmodule }
constructor create(const n : string;amodule : tobject);virtual;
constructor create(const n : TSymStr;amodule : tobject);virtual;
constructor ppuload(ppufile:tcompilerppufile);
destructor destroy;override;
{ do not override this routine in platform-specific subclasses,
@ -98,7 +98,7 @@ interface
tprogramparasym = class(Tstoredsym)
isoindex : dword;
constructor create(const n : string;i : dword);virtual;
constructor create(const n : TSymStr;i : dword);virtual;
constructor ppuload(ppufile:tcompilerppufile);
destructor destroy;override;
{ do not override this routine in platform-specific subclasses,
@ -110,7 +110,7 @@ interface
tnamespacesym = class(Tstoredsym)
unitsym:tsym;
unitsymderef:tderef;
constructor create(const n : string);virtual;
constructor create(const n : TSymStr);virtual;
constructor ppuload(ppufile:tcompilerppufile);
{ do not override this routine in platform-specific subclasses,
override ppuwrite_platform instead }
@ -132,7 +132,7 @@ interface
FProcdefList : TFPObjectList;
FProcdefDerefList : TFPList;
public
constructor create(const n : string);virtual;
constructor create(const n : TSymStr);virtual;
constructor ppuload(ppufile:tcompilerppufile);
destructor destroy;override;
{ writes all declarations except the specified one }
@ -162,7 +162,7 @@ interface
typedef : tdef;
typedefderef : tderef;
fprettyname : ansistring;
constructor create(const n : string;def:tdef);virtual;
constructor create(const n : TSymStr;def:tdef);virtual;
destructor destroy;override;
constructor ppuload(ppufile:tcompilerppufile);
{ do not override this routine in platform-specific subclasses,
@ -182,7 +182,7 @@ interface
{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 create(st:tsymtyp;const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
procedure ppuwrite(ppufile:tcompilerppufile);override;
procedure buildderef;override;
@ -226,7 +226,7 @@ interface
{$else symansistr}
cachedmangledname: pshortstring; { mangled name for ObjC or Java }
{$endif symansistr}
constructor create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
constructor create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
constructor ppuload(ppufile:tcompilerppufile);
{ do not override this routine in platform-specific subclasses,
override ppuwrite_platform instead }
@ -249,7 +249,7 @@ interface
{ the variable is not living at entry of the scope, so it does not need to be initialized if it is a reg. var
(not written to ppu, because not important and would change interface crc) }
noregvarinitneeded : boolean;
constructor create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor create(st:tsymtyp;const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
function globalasmsym: boolean;
procedure ppuwrite(ppufile:tcompilerppufile);override;
@ -258,7 +258,7 @@ interface
end;
tlocalvarsym = class(tabstractnormalvarsym)
constructor create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
constructor create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
constructor ppuload(ppufile:tcompilerppufile);
{ do not override this routine in platform-specific subclasses,
override ppuwrite_platform instead }
@ -276,7 +276,7 @@ interface
{$ifdef EXTDEBUG}
eqval : tequaltype;
{$endif EXTDEBUG}
constructor create(const n : string;nr:word;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
constructor create(const n : TSymStr;nr:word;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
constructor ppuload(ppufile:tcompilerppufile);
destructor destroy;override;
{ do not override this routine in platform-specific subclasses,
@ -306,10 +306,10 @@ interface
to the symbol of the corresponding class field }
fieldvarsym : tfieldvarsym;
fieldvarsymderef : tderef;
constructor create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
constructor create_dll(const n : string;vsp:tvarspez;def:tdef);virtual;
constructor create_C(const n: string; const mangled : TSymStr;vsp:tvarspez;def:tdef);virtual;
constructor create_from_fieldvar(const n:string;fieldvar:tfieldvarsym);virtual;
constructor create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual;
constructor create_dll(const n : TSymStr;vsp:tvarspez;def:tdef);virtual;
constructor create_C(const n: TSymStr; const mangled : TSymStr;vsp:tvarspez;def:tdef);virtual;
constructor create_from_fieldvar(const n: TSymStr;fieldvar:tfieldvarsym);virtual;
constructor ppuload(ppufile:tcompilerppufile);
destructor destroy;override;
{ do not override this routine in platform-specific subclasses,
@ -331,8 +331,8 @@ interface
asmname : pshortstring;
addroffset : PUint;
ref : tpropaccesslist;
constructor create(const n : string;def:tdef);virtual;
constructor create_ref(const n : string;def:tdef;_ref:tpropaccesslist);virtual;
constructor create(const n : TSymStr;def:tdef);virtual;
constructor create_ref(const n : TSymStr;def:tdef;_ref:tpropaccesslist);virtual;
destructor destroy;override;
constructor ppuload(ppufile:tcompilerppufile);
procedure buildderef;override;
@ -362,7 +362,7 @@ interface
dispid : longint;
propaccesslist: array[tpropaccesslisttypes] of tpropaccesslist;
parast : tsymtable;
constructor create(const n : string);virtual;
constructor create(const n : TSymStr);virtual;
destructor destroy;override;
constructor ppuload(ppufile:tcompilerppufile);
function getsize : asizeint;
@ -397,12 +397,12 @@ interface
constdefderef : tderef;
consttyp : tconsttyp;
value : tconstvalue;
constructor create_ord(const n : string;t : tconsttyp;v : tconstexprint;def:tdef);virtual;
constructor create_ordptr(const n : string;t : tconsttyp;v : tconstptruint;def:tdef);virtual;
constructor create_ptr(const n : string;t : tconsttyp;v : pointer;def:tdef);virtual;
constructor create_string(const n : string;t : tconsttyp;str:pchar;l:longint;def:tdef);virtual;
constructor create_wstring(const n : string;t : tconsttyp;pw:pcompilerwidestring);virtual;
constructor create_undefined(const n : string;def:tdef);virtual;
constructor create_ord(const n : TSymStr;t : tconsttyp;v : tconstexprint;def:tdef);virtual;
constructor create_ordptr(const n : TSymStr;t : tconsttyp;v : tconstptruint;def:tdef);virtual;
constructor create_ptr(const n : TSymStr;t : tconsttyp;v : pointer;def:tdef);virtual;
constructor create_string(const n : TSymStr;t : tconsttyp;str:pchar;l:longint;def:tdef);virtual;
constructor create_wstring(const n : TSymStr;t : tconsttyp;pw:pcompilerwidestring);virtual;
constructor create_undefined(const n : TSymStr;def:tdef);virtual;
constructor ppuload(ppufile:tcompilerppufile);
destructor destroy;override;
procedure buildderef;override;
@ -417,7 +417,7 @@ interface
value : longint;
definition : tenumdef;
definitionderef : tderef;
constructor create(const n : string;def : tenumdef;v : longint);virtual;
constructor create(const n : TSymStr;def : tenumdef;v : longint);virtual;
constructor ppuload(ppufile:tcompilerppufile);
{ do not override this routine in platform-specific subclasses,
override ppuwrite_platform instead }
@ -429,7 +429,7 @@ interface
tsyssym = class(Tstoredsym)
number : tinlinenumber;
constructor create(const n : string;l : tinlinenumber);virtual;
constructor create(const n : TSymStr;l : tinlinenumber);virtual;
constructor ppuload(ppufile:tcompilerppufile);
destructor destroy;override;
{ do not override this routine in platform-specific subclasses,
@ -458,7 +458,7 @@ interface
is_used : boolean;
buftext : pchar;
buflen : longint;
constructor create(const n : string);
constructor create(const n : TSymStr);
constructor ppuload(ppufile:tcompilerppufile);
{ do not override this routine in platform-specific subclasses,
override ppuwrite_platform instead }
@ -585,7 +585,7 @@ implementation
TSYM (base for all symtypes)
****************************************************************************}
constructor tstoredsym.create(st:tsymtyp;const n : string);
constructor tstoredsym.create(st:tsymtyp;const n : TSymStr);
begin
inherited create(st,n);
end;
@ -593,7 +593,11 @@ implementation
constructor tstoredsym.ppuload(st:tsymtyp;ppufile:tcompilerppufile);
begin
{$ifdef symansistr}
inherited Create(st,ppufile.getansistring);
{$else symansistr}
inherited Create(st,ppufile.getstring);
{$endif symansistr}
SymId:=ppufile.getlongint;
current_module.symlist[SymId]:=self;
ppufile.getposinfo(fileinfo);
@ -611,7 +615,11 @@ implementation
var
oldintfcrc : boolean;
begin
{$ifdef symansistr}
ppufile.putansistring(realname);
{$else}
ppufile.putstring(realname);
{$endif}
ppufile.putlongint(SymId);
ppufile.putposinfo(fileinfo);
ppufile.putbyte(byte(visibility));
@ -705,7 +713,7 @@ implementation
TLABELSYM
****************************************************************************}
constructor tlabelsym.create(const n : string);
constructor tlabelsym.create(const n : TSymStr);
begin
inherited create(labelsym,n);
used:=false;
@ -754,7 +762,7 @@ implementation
TUNITSYM
****************************************************************************}
constructor tunitsym.create(const n : string;amodule : tobject);
constructor tunitsym.create(const n : TSymStr;amodule : tobject);
begin
inherited create(unitsym,n);
module:=amodule;
@ -783,7 +791,7 @@ implementation
TPROGRAMPARASYM
****************************************************************************}
constructor tprogramparasym.create(const n : string; i : dword);
constructor tprogramparasym.create(const n : TSymStr; i : dword);
begin
inherited create(programparasym,n);
isoindex:=i;
@ -811,7 +819,7 @@ implementation
TNAMESPACESYM
****************************************************************************}
constructor tnamespacesym.create(const n : string);
constructor tnamespacesym.create(const n : TSymStr);
begin
inherited create(namespacesym,n);
unitsym:=nil;
@ -849,7 +857,7 @@ implementation
TPROCSYM
****************************************************************************}
constructor tprocsym.create(const n : string);
constructor tprocsym.create(const n : TSymStr);
var
i: longint;
begin
@ -1387,7 +1395,7 @@ implementation
end;
constructor tpropertysym.create(const n : string);
constructor tpropertysym.create(const n : TSymStr);
var
pap : tpropaccesslisttypes;
begin
@ -1650,7 +1658,7 @@ implementation
TABSTRACTVARSYM
****************************************************************************}
constructor tabstractvarsym.create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor tabstractvarsym.create(st:tsymtyp;const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
begin
inherited create(st,n);
vardef:=def;
@ -1846,7 +1854,7 @@ implementation
TFIELDVARSYM
****************************************************************************}
constructor tfieldvarsym.create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor tfieldvarsym.create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
begin
inherited create(fieldvarsym,n,vsp,def,vopts);
fieldoffset:=-1;
@ -1936,7 +1944,7 @@ implementation
TABSTRACTNORMALVARSYM
****************************************************************************}
constructor tabstractnormalvarsym.create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor tabstractnormalvarsym.create(st:tsymtyp;const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
begin
inherited create(st,n,vsp,def,vopts);
fillchar(localloc,sizeof(localloc),0);
@ -1998,7 +2006,7 @@ implementation
Tstaticvarsym
****************************************************************************}
constructor tstaticvarsym.create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor tstaticvarsym.create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
begin
inherited create(staticvarsym,n,vsp,def,vopts);
fieldvarsymderef.reset;
@ -2010,20 +2018,20 @@ implementation
end;
constructor tstaticvarsym.create_dll(const n : string;vsp:tvarspez;def:tdef);
constructor tstaticvarsym.create_dll(const n : TSymStr;vsp:tvarspez;def:tdef);
begin
tstaticvarsym(self).create(n,vsp,def,[vo_is_dll_var]);
end;
constructor tstaticvarsym.create_C(const n: string; const mangled : TSymStr;vsp:tvarspez;def:tdef);
constructor tstaticvarsym.create_C(const n: TSymStr; const mangled : TSymStr;vsp:tvarspez;def:tdef);
begin
tstaticvarsym(self).create(n,vsp,def,[]);
set_mangledname(mangled);
end;
constructor tstaticvarsym.create_from_fieldvar(const n: string;fieldvar:tfieldvarsym);
constructor tstaticvarsym.create_from_fieldvar(const n: TSymStr;fieldvar:tfieldvarsym);
begin
create(internal_static_field_name(n),fieldvar.varspez,fieldvar.vardef,[]);
fieldvarsym:=fieldvar;
@ -2194,7 +2202,7 @@ implementation
TLOCALVARSYM
****************************************************************************}
constructor tlocalvarsym.create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor tlocalvarsym.create(const n : TSymStr;vsp:tvarspez;def:tdef;vopts:tvaroptions);
begin
inherited create(localvarsym,n,vsp,def,vopts);
end;
@ -2218,7 +2226,7 @@ implementation
TPARAVARSYM
****************************************************************************}
constructor tparavarsym.create(const n : string;nr:word;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor tparavarsym.create(const n : TSymStr;nr:word;vsp:tvarspez;def:tdef;vopts:tvaroptions);
begin
inherited create(paravarsym,n,vsp,def,vopts);
if (vsp in [vs_var,vs_value,vs_const,vs_constref]) and
@ -2313,14 +2321,14 @@ implementation
TABSOLUTEVARSYM
****************************************************************************}
constructor tabsolutevarsym.create(const n : string;def:tdef);
constructor tabsolutevarsym.create(const n : TSymStr;def:tdef);
begin
inherited create(absolutevarsym,n,vs_value,def,[]);
ref:=nil;
end;
constructor tabsolutevarsym.create_ref(const n : string;def:tdef;_ref:tpropaccesslist);
constructor tabsolutevarsym.create_ref(const n : TSymStr;def:tdef;_ref:tpropaccesslist);
begin
inherited create(absolutevarsym,n,vs_value,def,[]);
ref:=_ref;
@ -2403,7 +2411,7 @@ implementation
TCONSTSYM
****************************************************************************}
constructor tconstsym.create_ord(const n : string;t : tconsttyp;v : tconstexprint;def:tdef);
constructor tconstsym.create_ord(const n : TSymStr;t : tconsttyp;v : tconstexprint;def:tdef);
begin
inherited create(constsym,n);
fillchar(value, sizeof(value), #0);
@ -2414,7 +2422,7 @@ implementation
end;
constructor tconstsym.create_ordptr(const n : string;t : tconsttyp;v : tconstptruint;def:tdef);
constructor tconstsym.create_ordptr(const n : TSymStr;t : tconsttyp;v : tconstptruint;def:tdef);
begin
inherited create(constsym,n);
fillchar(value, sizeof(value), #0);
@ -2425,7 +2433,7 @@ implementation
end;
constructor tconstsym.create_ptr(const n : string;t : tconsttyp;v : pointer;def:tdef);
constructor tconstsym.create_ptr(const n : TSymStr;t : tconsttyp;v : pointer;def:tdef);
begin
inherited create(constsym,n);
fillchar(value, sizeof(value), #0);
@ -2436,7 +2444,7 @@ implementation
end;
constructor tconstsym.create_string(const n : string;t : tconsttyp;str:pchar;l:longint;def: tdef);
constructor tconstsym.create_string(const n : TSymStr;t : tconsttyp;str:pchar;l:longint;def: tdef);
begin
inherited create(constsym,n);
fillchar(value, sizeof(value), #0);
@ -2451,7 +2459,7 @@ implementation
end;
constructor tconstsym.create_wstring(const n : string;t : tconsttyp;pw:pcompilerwidestring);
constructor tconstsym.create_wstring(const n : TSymStr;t : tconsttyp;pw:pcompilerwidestring);
begin
inherited create(constsym,n);
fillchar(value, sizeof(value), #0);
@ -2463,7 +2471,7 @@ implementation
end;
constructor tconstsym.create_undefined(const n : string;def: tdef);
constructor tconstsym.create_undefined(const n : TSymStr;def: tdef);
begin
inherited create(constsym,n);
fillchar(value,sizeof(value),#0);
@ -2659,7 +2667,7 @@ implementation
TENUMSYM
****************************************************************************}
constructor tenumsym.create(const n : string;def : tenumdef;v : longint);
constructor tenumsym.create(const n : TSymStr;def : tenumdef;v : longint);
begin
inherited create(enumsym,n);
definition:=def;
@ -2703,7 +2711,7 @@ implementation
****************************************************************************}
constructor ttypesym.create(const n : string;def:tdef);
constructor ttypesym.create(const n : TSymStr;def:tdef);
begin
inherited create(typesym,n);
@ -2771,7 +2779,7 @@ implementation
syssym_list : TFPHashObjectList;
constructor tsyssym.create(const n : string;l : tinlinenumber);
constructor tsyssym.create(const n : TSymStr;l : tinlinenumber);
var
s : shortstring;
begin
@ -2821,7 +2829,7 @@ implementation
TMacro
*****************************************************************************}
constructor tmacro.create(const n : string);
constructor tmacro.create(const n : TSymStr);
begin
inherited create(macrosym,n);
owner:=nil;

View File

@ -1813,9 +1813,9 @@ end;
procedure readcommonsym(const s:string; Def: TPpuDef = nil);
var
i: integer;
n: string;
n: ansistring;
begin
n:=ppufile.getstring;
n:=readsymstr(ppufile);
if Def <> nil then
Def.Name:=n;
i:=ppufile.getlongint;

View File

@ -122,7 +122,7 @@ type
public
DefType: TPpuDefType;
Name: string;
Name: ansistring;
FilePos: TPpuFilePos;
// Symbol/definition reference
Ref: TPpuRef;