Thoughts on Gengtype and Single Inheritance
Lawrence Crowl
crowl@googlers.com
Tue Sep 4 19:37:00 GMT 2012
On 8/31/12, Laurynas Biveinis <laurynas.biveinis@gmail.com> wrote:
>>>> GRAMMAR
>>>>
>>>> Support adding a second discriminator. This support is not for
>>>> multiple inheritance, but for single inheritance when a second
>>>> discriminator is used to further refine it. Look at struct
>>>> tree_omp_clause. It contains a sub union. We can represent the
>>>> hierarchy like:
>>>>
>>>> struct tree_omp_clause : tree_common {
>>>> location_t locus;
>>>> enum omp_clause_code code;
>>>> };
>>>>
>>>> struct tree_omp_default_clause : tree_omp_clause {
>>>> enum omp_clause_default_kind default_kind;
>>>> };
>>>>
>>>> struct tree_omp_schedule_clause : tree_omp_clause {
>>>> enum omp_clause_schedule_kind schedule_kind;
>>>> };
>>>>
>>>> struct tree_omp_reduction_clause : tree_omp_clause {
>>>> enum tree_code reduction_code;
>>>> };
>>>>
>>>> We use TREE_CODE to understand that we have at least a tree_omp_clause
>>>> and then we use tree_common.code to to distinguish these last three.
>>>>
>>>> Another possible case is tree_type_symtab inside tree_type_common.
>>>>
>>>> The syntax would be something like the following.
>>>>
>>>> enum F { F1, F2, F3, F4, F5 };
>>>>
>>>> class CTYPE GTY ((desc ("%h.kind"), tag ("F1")))
>>>> : GTY ((tag ("EC"))) public BTYPE
>>>> { public: enum F kind; something *pq; ... };
>>>>
>>>> class FTYPE : GTY ((tag ("F2"))) public CTYPE { ... };
>>>
>>> I wonder if the second discriminator support is easily generalizable
>>> to enabling any derived class being a root class on it own with its
>>> own subtree? If I understand correctly, the GTY syntax would be the
>>> same.
>>
>> If I understand correctly, you are suggesting multiple inheritance
>> via enums. I think it is possible, but I think the tag syntax
>> would need to be changed to more directly associate the tag with
>> the variable.
>>
>> --
>> Lawrence Crowl
>
> I was trying to talk about single inheritance, not multiple
> inheritance nor composition here, but perhaps I misunderstood it
> myself.
>
> As I saw it, there is a hierarchy rooted at tree_common. For its child
> tree_omp_clause there is further sub-hierarchy. It's all single
> inheritance, and the second discriminator here would be the first
> discriminator, if tree_omp_clause were not a child of other class.
Yes, that is correct.
--
Lawrence Crowl
More information about the Gcc
mailing list