Next: , Previous: Attribute Safe_Large, Up: Implementation Defined Attributes


Attribute Scalar_Storage_Order

For every array or record type S, the representation attribute Scalar_Storage_Order denotes the order in which storage elements that make up scalar components are ordered within S:

        --  Component type definitions
     
        subtype Yr_Type is Natural range 0 .. 127;
        subtype Mo_Type is Natural range 1 .. 12;
        subtype Da_Type is Natural range 1 .. 31;
     
        --  Record declaration
     
        type Date is record
           Years_Since_1980 : Yr_Type;
           Month            : Mo_Type;
           Day_Of_Month     : Da_Type;
        end record;
     
        --  Record representation clause
     
        for Date use record
           Years_Since_1980 at 0 range 0  ..  6;
           Month            at 0 range 7  .. 10;
           Day_Of_Month     at 0 range 11 .. 15;
        end record;
     
        --  Attribute definition clauses
     
        for Date'Bit_Order use System.High_Order_First;
        for Date'Scalar_Storage_Order use System.High_Order_First;
        --  If Scalar_Storage_Order is specified, it must be consistent with
        --  Bit_Order, so it's best to always define the latter explicitly if
        --  the former is used.

Other properties are as for standard representation attribute Bit_Order, as defined by Ada RM 13.5.3(4). The default is System.Default_Bit_Order.

For a record type S, if S'Scalar_Storage_Order is specified explicitly, it shall be equal to S'Bit_Order. Note: this means that if a Scalar_Storage_Order attribute definition clause is not confirming, then the type's Bit_Order shall be specified explicitly and set to the same value.

For a record extension, the derived type shall have the same scalar storage order as the parent type.

If a component of S has itself a record or array type, then it shall also have a Scalar_Storage_Order attribute definition clause. In addition, if the component is a packed array, or does not start on a byte boundary, then the scalar storage order specified for S and for the nested component type shall be identical.

If S appears as the type of a record or array component, the enclosing record or array shall also have a Scalar_Storage_Order attribute definition clause.

No component of a type that has a Scalar_Storage_Order attribute definition may be aliased.

A confirming Scalar_Storage_Order attribute definition clause (i.e. with a value equal to System.Default_Bit_Order) has no effect.

If the opposite storage order is specified, then whenever the value of a scalar component of an object of type S is read, the storage elements of the enclosing machine scalar are first reversed (before retrieving the component value, possibly applying some shift and mask operatings on the enclosing machine scalar), and the opposite operation is done for writes.

In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components are relaxed. Instead, the following rules apply: