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:
svenbarth 2011-05-02 19:42:40 +00:00
parent dd60ae0203
commit 39d702f79d

View File

@ -110,13 +110,19 @@ interface
end;
ttypesym = class(Tstoredsym)
protected
fgendeflist : TFPObjectList;
fgendefdereflist : TFPList;
public
typedef : tdef;
typedefderef : tderef;
constructor create(const n : string;def:tdef);
destructor destroy; override;
constructor ppuload(ppufile:tcompilerppufile);
procedure ppuwrite(ppufile:tcompilerppufile);override;
procedure buildderef;override;
procedure deref;override;
property gendeflist: TFPObjectList read fgendeflist;
end;
tabstractvarsym = class(tstoredsym)
@ -1843,32 +1849,95 @@ implementation
(typedef.typ<>errordef) and
not(assigned(typedef.typesym)) then
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;
constructor ttypesym.ppuload(ppufile:tcompilerppufile);
var
gdderef : tderef;
i,
gdcnt : longint;
begin
inherited ppuload(typesym,ppufile);
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;
procedure ttypesym.buildderef;
var
i : longint;
d : tderef;
gd : tdef;
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;
procedure ttypesym.deref;
var
i : longint;
gd : tdef;
d : tderef;
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;
procedure ttypesym.ppuwrite(ppufile:tcompilerppufile);
var
i : longint;
d : tderef;
begin
inherited ppuwrite(ppufile);
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);
end;