mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 11:08:02 +02:00
* move code to add a symbol to the current module's generic dummy symbols into a new function pgenutil.add_generic_dummysym()
git-svn-id: trunk@36466 -
This commit is contained in:
parent
abd765da40
commit
06d7e26df0
@ -49,6 +49,7 @@ uses
|
||||
procedure maybe_insert_generic_rename_symbol(const name:tidstring;genericlist:tfphashobjectlist);
|
||||
function generate_generic_name(const name:tidstring;specializename:ansistring;owner_hierarchy:string):tidstring;
|
||||
procedure split_generic_name(const name:tidstring;out nongeneric:string;out count:longint);
|
||||
procedure add_generic_dummysym(sym:tsym);
|
||||
function resolve_generic_dummysym(const name:tidstring):tsym;
|
||||
function could_be_generic(const name:tidstring):boolean;inline;
|
||||
|
||||
@ -1502,6 +1503,50 @@ uses
|
||||
end;
|
||||
|
||||
|
||||
procedure add_generic_dummysym(sym:tsym);
|
||||
var
|
||||
list: TFPObjectList;
|
||||
srsym : tsym;
|
||||
srsymtable : tsymtable;
|
||||
entry : tgenericdummyentry;
|
||||
begin
|
||||
if sp_generic_dummy in sym.symoptions then
|
||||
begin
|
||||
{ did we already search for a generic with that name? }
|
||||
list:=tfpobjectlist(current_module.genericdummysyms.find(sym.name));
|
||||
if not assigned(list) then
|
||||
begin
|
||||
list:=tfpobjectlist.create(true);
|
||||
current_module.genericdummysyms.add(sym.name,list);
|
||||
end;
|
||||
{ is the dummy sym still "dummy"? }
|
||||
if (sym.typ=typesym) and
|
||||
(
|
||||
{ dummy sym defined in mode Delphi }
|
||||
(ttypesym(sym).typedef.typ=undefineddef) or
|
||||
{ dummy sym defined in non-Delphi mode }
|
||||
(tstoreddef(ttypesym(sym).typedef).is_generic)
|
||||
) then
|
||||
begin
|
||||
{ do we have a non-generic type of the same name
|
||||
available? }
|
||||
if not searchsym_with_flags(sym.name,srsym,srsymtable,[ssf_no_addsymref]) then
|
||||
srsym:=nil;
|
||||
end
|
||||
else
|
||||
{ dummy symbol is already not so dummy anymore }
|
||||
srsym:=nil;
|
||||
if assigned(srsym) then
|
||||
begin
|
||||
entry:=tgenericdummyentry.create;
|
||||
entry.resolvedsym:=srsym;
|
||||
entry.dummysym:=sym;
|
||||
list.add(entry);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function resolve_generic_dummysym(const name:tidstring):tsym;
|
||||
var
|
||||
list : tfpobjectlist;
|
||||
|
@ -1488,42 +1488,8 @@ implementation
|
||||
end
|
||||
else
|
||||
begin
|
||||
if addgenerics and
|
||||
(sp_generic_dummy in sym.symoptions)
|
||||
then
|
||||
begin
|
||||
{ did we already search for a generic with that name? }
|
||||
list:=tfpobjectlist(current_module.genericdummysyms.find(sym.name));
|
||||
if not assigned(list) then
|
||||
begin
|
||||
list:=tfpobjectlist.create(true);
|
||||
current_module.genericdummysyms.add(sym.name,list);
|
||||
end;
|
||||
{ is the dummy sym still "dummy"? }
|
||||
if (sym.typ=typesym) and
|
||||
(
|
||||
{ dummy sym defined in mode Delphi }
|
||||
(ttypesym(sym).typedef.typ=undefineddef) or
|
||||
{ dummy sym defined in non-Delphi mode }
|
||||
(tstoreddef(ttypesym(sym).typedef).is_generic)
|
||||
) then
|
||||
begin
|
||||
{ do we have a non-generic type of the same name
|
||||
available? }
|
||||
if not searchsym_with_flags(sym.name,srsym,srsymtable,[ssf_no_addsymref]) then
|
||||
srsym:=nil;
|
||||
end
|
||||
else
|
||||
{ dummy symbol is already not so dummy anymore }
|
||||
srsym:=nil;
|
||||
if assigned(srsym) then
|
||||
begin
|
||||
entry:=tgenericdummyentry.create;
|
||||
entry.resolvedsym:=srsym;
|
||||
entry.dummysym:=sym;
|
||||
list.add(entry);
|
||||
end;
|
||||
end;
|
||||
if addgenerics then
|
||||
add_generic_dummysym(sym);
|
||||
{ add nested helpers as well }
|
||||
if (def.typ in [recorddef,objectdef]) and
|
||||
(sto_has_helper in tabstractrecorddef(def).symtable.tableoptions) then
|
||||
|
Loading…
Reference in New Issue
Block a user