with Instrument;
use Instrument;

---------------------
-- Record Representation
---------------------

-- This test evaluates the code efficiency of elaborating an object
-- declaration of a simple record type that has an associated record
-- representation clause.

-- The test and noise versions for this evaluation are structurally
-- identical and consist of a procedure that encloses and calls the
-- function that declares and initializes a record variable, Local.
-- The function returns the size of the record variable, although
-- this is not used in the evaluation.

procedure Srtea1 is

    type Enum is (Monday, Tuesday, Wednesday,
                  Thursday, Friday, Saturday, Sunday);
    type Fixed is delta 0.01 range -100.0 .. 100.0;
    subtype Int is Integer range -1000 .. 1000;

    type Representation_Record is

        record
            Enum_Comp : Enum := Enum'Last;
            Int_Comp : Int := Int'Last;
            Fixed_Comp : Fixed := 0.0;
            Bool_Comp : Boolean := True;
        end record;

    type Conventional_Record is

        record
            Enum_Comp : Enum := Enum'Last;
            Int_Comp : Int := Int'Last;
            Fixed_Comp : Fixed := 0.0;
            Bool_Comp : Boolean := True;
        end record;

    -- Representation clause is commented out because it is not
    -- currently supported by a validated compiler.

    --  Storage_Unit : constant := 8;
    --  Word         : constant POSITIVE := 2 * Storage_Unit;
    --
    --  for  REPRESENTATION_RECORD use
    --
    --    record at mod Storage_Unit;
    --      Enum_Comp  at 0 * Word range  0 .. 2;
    --      Int_Comp   at 0 * Word range  3 .. 14;
    --      Fixed_Comp at <storage allocated by compiler>
    --      Bool_Comp  at 1 * Word range 15 .. 15;
    --    end record;

    package New_Procs is new Procs (Boolean);
    use New_Procs;

    Local : Integer;

    function Elaborate_Record_Declaration return Integer is

        --    Local : REPRESENTATION_RECORD;        -- included in test version
        Local : Conventional_Record;          -- included in control version

    begin

        Let (Global, Ident (Global));
        return Local'Size;

    end Elaborate_Record_Declaration;

begin

    Start ("SRTEA1", "Simple Record Type Elaboration (control)");
    for I in 1 .. 10000 loop

        Local := Elaborate_Record_Declaration;
        Let (Global, Ident (Global));

    end loop;
    Stop;

end Srtea1;