[fpc-pascal] Constants in generics
Ryan Joseph
ryan at thealchemistguild.com
Thu Nov 29 02:46:01 CET 2018
> On Nov 29, 2018, at 5:15 AM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
> Looks better.
> The next thing to nuke is the tgenericparamdef. The parameters stored in tdef.genericparas are the parameter symbols, so there should be no need for defs. If necessary some of the code in pgenutil (and related functions) will need to be changed from handling a list of defs to a list of syms.
I added that extra type so that it would be compatible with genericdeflist. I don’t see how that can be removed. The const sym is pulled out in generate_specialization_phase2 and renamed (which I forget why already).
So the tgenericparamdef is just a vessel to hold the constsym until generate_specialization_phase2? Either way removing it means breaking genericdeflist right?
if typeparam.nodetype <> typen then
begin
{ the typesym from paramdef will be added to the list in generate_specialization_phase2 }
paramdef := tgenericparamdef.create(typeparam.resultdef,typeparam,constprettyname);
genericdeflist.Add(paramdef);
end
else
begin
constprettyname := '';
genericdeflist.Add(typeparam.resultdef);
end;
from generate_specialization_phase2:
for i:=0 to genericdef.genericparas.Count-1 do
begin
srsym:=tsym(genericdef.genericparas[i]);
if not (sp_generic_para in srsym.symoptions) then
internalerror(2013092602);
// note: ryan
{ set the generic param name of the constsym of tgenericparamdef }
typedef := tstoreddef(context.genericdeflist[i]);
if typedef.typ = genericconstdef then
tgenericparamdef(typedef).typesym.realname := srsym.realname;
generictypelist.add(srsym.realname,typedef.typesym);
end;
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list