[Dwarf-discuss] Encoding variant records: request for clarification.

Paul Hilfinger hilfingr
Fri Aug 18 08:10:32 GMT 2006


I'm finding the description of variants a little difficult to
interpret and apply, and I wonder if someone could supply me with an
example.  Let's consider specifically the Ada record type R,
defined

    type R (N : Integer) is record
       Data : String (1 .. N);
       case N is
       when 0 =>
           Name : String (1 .. N);
       when 1..20 =>
           Id, Port : Integer;
       when others =>
           null;
       end case;
    end record;

N here is basically a member of R.  As you can see, it is referred to
in Data.  According to the standard, however, there is ALSO a child of
the variant part for N.  What is the relationship between the two (the
child of R representing N and the child of the variant child of R
representing N)?  How exactly is type R to be encoded?

Thanks in advance.

Paul Hilfinger
AdaCore, Inc. & UC Berkeley


     





More information about the Dwarf-discuss mailing list