Last question I have I think.
Is this the best way to get "pretty name" string for a set? Having to loop
through the entire range of the set is not so great but I don’t see another
way. I feel like there should be some utility functions to get names for ord
defs also but I just did a crude string conversion for now.
new(ps);
ps^:=tsetconstnode(node).value_set^;
sym:=cconstsym.create_ptr(undefinedname,constset,ps,fromdef);
setdef:=tsetdef(tsetconstnode(node).resultdef);
enumdef:=tenumdef(setdef.elementdef);
prettyname:='[';
for i := setdef.setbase to setdef.setmax do
if i in tsetconstnode(node).value_set^ then
begin
enumsym:=enumdef.int2enumsym(i);
if assigned(enumsym) then
enumname:=enumsym.realname
else if enumdef.typ=orddef then
begin
if torddef(enumdef).ordtype=uchar then
enumname:=chr(i)
else
enumname:=tostr(i);
end
else
enumname:=tostr(i);
if length(prettyname) > 1 then
prettyname:=prettyname+','+enumname
else
prettyname:=prettyname+enumname;
end;
prettyname:=prettyname+']';
Regards,
Ryan Joseph
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal