On 8/27/12, Laurynas Biveinis <laurynas.bivei...@gmail.com> wrote:
> I don't have an opinion from the rest of compiler point of view, but
> gengtype implementation-wise, it certainly looks doable. One minor
> comment below -
>
>> 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

Reply via email to