mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 02:59:13 +02:00
Extend ttypesym by a list that will contain all generic "overloads" of this symbol.
git-svn-id: branches/svenbarth/generics@17392 -
This commit is contained in:
parent
dd60ae0203
commit
39d702f79d
@ -110,13 +110,19 @@ interface
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
ttypesym = class(Tstoredsym)
|
ttypesym = class(Tstoredsym)
|
||||||
|
protected
|
||||||
|
fgendeflist : TFPObjectList;
|
||||||
|
fgendefdereflist : TFPList;
|
||||||
|
public
|
||||||
typedef : tdef;
|
typedef : tdef;
|
||||||
typedefderef : tderef;
|
typedefderef : tderef;
|
||||||
constructor create(const n : string;def:tdef);
|
constructor create(const n : string;def:tdef);
|
||||||
|
destructor destroy; override;
|
||||||
constructor ppuload(ppufile:tcompilerppufile);
|
constructor ppuload(ppufile:tcompilerppufile);
|
||||||
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
||||||
procedure buildderef;override;
|
procedure buildderef;override;
|
||||||
procedure deref;override;
|
procedure deref;override;
|
||||||
|
property gendeflist: TFPObjectList read fgendeflist;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
tabstractvarsym = class(tstoredsym)
|
tabstractvarsym = class(tstoredsym)
|
||||||
@ -1843,32 +1849,95 @@ implementation
|
|||||||
(typedef.typ<>errordef) and
|
(typedef.typ<>errordef) and
|
||||||
not(assigned(typedef.typesym)) then
|
not(assigned(typedef.typesym)) then
|
||||||
typedef.typesym:=self;
|
typedef.typesym:=self;
|
||||||
|
fgendeflist:=TFPObjectList.Create(false);
|
||||||
|
fgendefdereflist:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor ttypesym.destroy;
|
||||||
|
begin
|
||||||
|
fgendeflist.free;
|
||||||
|
if assigned(fgendefdereflist) then
|
||||||
|
fgendefdereflist.free;
|
||||||
|
inherited destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
constructor ttypesym.ppuload(ppufile:tcompilerppufile);
|
constructor ttypesym.ppuload(ppufile:tcompilerppufile);
|
||||||
|
var
|
||||||
|
gdderef : tderef;
|
||||||
|
i,
|
||||||
|
gdcnt : longint;
|
||||||
begin
|
begin
|
||||||
inherited ppuload(typesym,ppufile);
|
inherited ppuload(typesym,ppufile);
|
||||||
ppufile.getderef(typedefderef);
|
ppufile.getderef(typedefderef);
|
||||||
|
fgendeflist:=TFPObjectList.Create(false);
|
||||||
|
fgendefdereflist:=TFPList.Create;
|
||||||
|
gdcnt:=ppufile.getword;
|
||||||
|
for i:=1 to gdcnt do
|
||||||
|
begin
|
||||||
|
ppufile.getderef(gdderef);
|
||||||
|
fgendefdereflist.Add(Pointer(PtrInt(gdderef.dataidx)));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure ttypesym.buildderef;
|
procedure ttypesym.buildderef;
|
||||||
|
var
|
||||||
|
i : longint;
|
||||||
|
d : tderef;
|
||||||
|
gd : tdef;
|
||||||
begin
|
begin
|
||||||
typedefderef.build(typedef);
|
typedefderef.build(typedef);
|
||||||
|
if not assigned(fgendefdereflist) then
|
||||||
|
fgendefdereflist:=TFPList.Create
|
||||||
|
else
|
||||||
|
fgendefdereflist.Clear;
|
||||||
|
for i:=0 to fgendeflist.Count-1 do
|
||||||
|
begin
|
||||||
|
gd:=tdef(fgendeflist[i]);
|
||||||
|
{ only write the type definitions that belong to this typesym }
|
||||||
|
if gd.owner=owner then
|
||||||
|
begin
|
||||||
|
d.build(gd);
|
||||||
|
fgendefdereflist.Add(Pointer(PtrInt(d.dataidx)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure ttypesym.deref;
|
procedure ttypesym.deref;
|
||||||
|
var
|
||||||
|
i : longint;
|
||||||
|
gd : tdef;
|
||||||
|
d : tderef;
|
||||||
begin
|
begin
|
||||||
typedef:=tdef(typedefderef.resolve);
|
typedef:=tdef(typedefderef.resolve);
|
||||||
|
{ Clear all typedefs }
|
||||||
|
fgendeflist.Clear;
|
||||||
|
if not assigned(fgendefdereflist) then
|
||||||
|
internalerror(201104211);
|
||||||
|
for i:=0 to fgendefdereflist.Count-1 do
|
||||||
|
begin
|
||||||
|
d.dataidx:=PtrInt(fgendefdereflist[i]);
|
||||||
|
gd:=tdef(d.resolve);
|
||||||
|
fgendeflist.Add(gd);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure ttypesym.ppuwrite(ppufile:tcompilerppufile);
|
procedure ttypesym.ppuwrite(ppufile:tcompilerppufile);
|
||||||
|
var
|
||||||
|
i : longint;
|
||||||
|
d : tderef;
|
||||||
begin
|
begin
|
||||||
inherited ppuwrite(ppufile);
|
inherited ppuwrite(ppufile);
|
||||||
ppufile.putderef(typedefderef);
|
ppufile.putderef(typedefderef);
|
||||||
|
ppufile.putword(fgendefdereflist.Count);
|
||||||
|
for i:=0 to fgendefdereflist.Count-1 do
|
||||||
|
begin
|
||||||
|
d.dataidx:=PtrInt(fgendefdereflist[i]);
|
||||||
|
ppufile.putderef(d);
|
||||||
|
end;
|
||||||
ppufile.writeentry(ibtypesym);
|
ppufile.writeentry(ibtypesym);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user