This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Thoughts on Gengtype and Single Inheritance
- From: Lawrence Crowl <crowl at googlers dot com>
- To: Laurynas Biveinis <laurynas dot biveinis at gmail dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Tue, 4 Sep 2012 12:36:50 -0700
- Subject: Re: Thoughts on Gengtype and Single Inheritance
- References: <CAGqM8fZMUPo7pUUF7_RrLYm+fkrukjZenE=UyZu7FrC7BTU9bQ@mail.gmail.com> <CAHkCEVeD+Lm5ZTu0AVTZApPDSN15kGM8mcEepqzetYdgOEi5ig@mail.gmail.com> <CAGqM8fbsSW8HerxnW5XgaTc6Tj1BwjNy__k8A5FT5j6S3uYDwA@mail.gmail.com> <CAHkCEVc+WLRBLYYikSkVaWNn0XnDsy4=iFGoU4Cr6e+PDMCVew@mail.gmail.com>
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