symdef.pas, tprocdef:

+ new token buffer that holds the declaration of the generic function/method while the one from tdef contains the body
ppu.pas:
  * increase PPU version
utils/ppuutils/ppudump.pp:
  * also read the declaration token buffer, it's however not printed yet (ToDo!)

git-svn-id: trunk@31759 -
This commit is contained in:
svenbarth 2015-09-18 13:46:50 +00:00
parent e8c68a09c1
commit e44a51f10d
3 changed files with 65 additions and 4 deletions

View File

@ -43,7 +43,7 @@ type
{$endif Test_Double_checksum}
const
CurrentPPUVersion = 177;
CurrentPPUVersion = 178;
{ buffer sizes }
maxentrysize = 1024;

View File

@ -721,6 +721,8 @@ interface
{$endif}
symoptions : tsymoptions;
deprecatedmsg : pshortstring;
{ generic support }
genericdecltokenbuf : tdynamicarray;
{ symbol owning this definition }
procsym : tsym;
procsymderef : tderef;
@ -779,6 +781,7 @@ interface
function is_methodpointer:boolean;override;
function is_addressonly:boolean;override;
procedure make_external;
procedure init_genericdecl;
{ aliases to fields only required when a function is implemented in
the current unit }
@ -5182,8 +5185,9 @@ implementation
constructor tprocdef.ppuload(ppufile:tcompilerppufile);
var
i,aliasnamescount : longint;
i,aliasnamescount,sizeleft : longint;
level : byte;
buf : array[0..255] of byte;
begin
inherited ppuload(procdef,ppufile);
{$ifdef symansistr}
@ -5245,6 +5249,23 @@ implementation
for i:=1 to aliasnamescount do
aliasnames.insert(ppufile.getstring);
{ load the token stream containing the declaration }
sizeleft:=ppufile.getlongint;
if sizeleft>0 then
begin
init_genericdecl;
while sizeleft>0 do
begin
if sizeleft>sizeof(buf) then
i:=sizeof(buf)
else
i:=sizeleft;
ppufile.getdata(buf,i);
genericdecltokenbuf.write(buf,i);
dec(sizeleft,i);
end;
end;
ppuload_platform(ppufile);
{ load para symtable }
@ -5305,6 +5326,8 @@ implementation
freemem(implprocdefinfo);
implprocdefinfo:=nil;
end;
genericdecltokenbuf.free;
genericdecltokenbuf:=nil;
stringdispose(import_dll);
stringdispose(import_name);
stringdispose(deprecatedmsg);
@ -5329,8 +5352,9 @@ implementation
procedure tprocdef.ppuwrite(ppufile:tcompilerppufile);
var
oldintfcrc : boolean;
aliasnamescount : longint;
aliasnamescount,i,sizeleft : longint;
item : TCmdStrListItem;
buf : array[0..255] of byte;
begin
{ released procdef? }
if not assigned(parast) then
@ -5397,6 +5421,26 @@ implementation
ppufile.do_crc:=oldintfcrc;
{ generic tokens for the declaration }
if assigned(genericdecltokenbuf) and (genericdecltokenbuf.size>0) then
begin
sizeleft:=genericdecltokenbuf.size;
genericdecltokenbuf.seek(0);
ppufile.putlongint(sizeleft);
while sizeleft>0 do
begin
if sizeleft>sizeof(buf) then
i:=sizeof(buf)
else
i:=sizeleft;
genericdecltokenbuf.read(buf,i);
ppufile.putdata(buf,i);
dec(sizeleft,i);
end;
end
else
ppufile.putlongint(0);
{ write this entry }
writeentry(ppufile,ibprocdef);
@ -5532,6 +5576,14 @@ implementation
end;
procedure tprocdef.init_genericdecl;
begin
if assigned(genericdecltokenbuf) then
internalerror(2015061901);
genericdecltokenbuf:=tdynamicarray.create(256);
end;
function tprocdef.GetSymtable(t:tGetSymtable):TSymtable;
begin
case t of

View File

@ -2718,7 +2718,8 @@ procedure readdefinitions(const s:string; ParentDef: TPpuContainerDef);
{ type tvarianttype is in symconst unit }
var
b : byte;
l,j : longint;
l,j,tokenbufsize : longint;
tokenbuf : pbyte;
calloption : tproccalloption;
procoptions : tprocoptions;
implprocoptions: timplprocoptions;
@ -3029,6 +3030,14 @@ begin
end;
writeln;
end;
tokenbufsize:=ppufile.getlongint;
if tokenbufsize<>0 then
begin
write ([space,' Declaration token buffer : TODO']);
tokenbuf:=allocmem(tokenbufsize);
ppufile.getdata(tokenbuf^,tokenbufsize);
freemem(tokenbuf);
end;
if not EndOfEntry then
HasMoreInfos;
space:=' '+space;