Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help


13.3 Representation Attributes

(1)
The values of certain implementation-dependent characteristics can be obtained by interrogating appropriate representation attributes. Some of these attributes are specifiable via an attribute_definition_clause.
Syntax
(2)
       attribute_definition_clause ::=
             for local_name'attribute_designator use expression;
           | for local_name'attribute_designator use name;
Name Resolution Rules
(3)
For an attribute_definition_clause that specifies an attribute that denotes a value, the form with an expression shall be used. Otherwise, the form with a name shall be used.
(4)
For an attribute_definition_clause that specifies an attribute that denotes a value or an object, the expected type for the expression or name is that of the attribute. For an attribute_definition_clause that specifies an attribute that denotes a subprogram, the expected profile for the name is the profile required for the attribute. For an attribute_definition_clause that specifies an attribute that denotes some other kind of entity, the name shall resolve to denote an entity of the appropriate kind.
Legality Rules
(5)
An attribute_designator is allowed in an attribute_definition_clause only if this International Standard explicitly allows it, or for an implementation-defined attribute if the implementation allows it. Each specifiable attribute constitutes an aspect of representation.
(6)
For an attribute_definition_clause that specifies an attribute that denotes a subprogram, the profile shall be mode conformant with the one required for the attribute, and the convention shall be Ada. Additional requirements are defined for particular attributes.
Static Semantics
(7)
A Size clause is an attribute_definition_clause whose attribute_designator is Size. Similar definitions apply to the other specifiable attributes.
(8)
A storage element is an addressable element of storage in the machine. A word is the largest amount of storage that can be conveniently and efficiently manipulated by the hardware, given the implementation's run-time model. A word consists of an integral number of storage elements.
(9)
The following attributes are defined:
(10)
For a prefix X that denotes an object, program unit, or label:
(11)
X'Address
(12)
Erroneous Execution
(13)
If an Address is specified, it is the programmer's responsibility to ensure that the address is valid; otherwise, program execution is erroneous.
Implementation Advice
(14)
For an array X, X'Address should point at the first component of the array, and not at the array bounds.
(15)
The recommended level of support for the Address attribute is:
(16)
(17)
(18)
(19)

(20)
(21)
Static Semantics
(22)
For a prefix X that denotes a subtype or object:
(23)
X'Alignment
(24)
(25)
(26)
Erroneous Execution
(27)
Program execution is erroneous if an Address clause is given that conflicts with the Alignment.
(28)
If the Alignment is specified for an object that is not allocated under control of the implementation, execution is erroneous if the object is not aligned according to the Alignment.
Implementation Advice
(29)
The recommended level of support for the Alignment attribute for subtypes is:
(30)
(31)
(32)
(33)
The recommended level of support for the Alignment attribute for objects is:
(34)
(35)

(36)
(37)
(38)
Static Semantics
(39)
For a prefix X that denotes an object:
(40)
X'Size
(41)
Implementation Advice
(42)
The recommended level of support for the Size attribute of objects is:
(43)
Static Semantics
(44)
For every subtype S:
(45)
S'Size
(46)
(47)
(48)
Implementation Requirements
(49)
In an implementation, Boolean'Size shall be 1.
Implementation Advice
(50)
If the Size of a subtype is specified, and allows for efficient independent addressability (see 9.10) on the target architecture, then the Size of the following objects of the subtype should equal the Size of the subtype:
(51)
(52)
(53)
A Size clause on a composite subtype should not affect the internal layout of components.
(54)
The recommended level of support for the Size attribute of subtypes is:
(55)
(56)

(57)
(58)
Static Semantics
(59)
For a prefix T that denotes a task object (after any implicit dereference):
(60)
T'Storage_Size
(61)
A pragma Storage_Size specifies the amount of storage to be reserved for the execution of a task.
Syntax
(62)
(63)
         pragma Storage_Size(expression);
(64)
Name Resolution Rules
(65)
The expression of a pragma Storage_Size is expected to be of any integer type.
Dynamic Semantics
(66)
A pragma Storage_Size is elaborated when an object of the type defined by the immediately enclosing task_definition is created. For the elaboration of a pragma Storage_Size, the expression is evaluated; the Storage_Size attribute of the newly created task object is at least the value of the expression.
(67)
At the point of task object creation, or upon task activation, Storage_Error is raised if there is insufficient free storage to accommodate the requested Storage_Size.
Static Semantics
(68)
For a prefix X that denotes an array subtype or array object (after any implicit dereference):
(69)
X'Component_Size
(70)
Implementation Advice
(71)
The recommended level of support for the Component_Size attribute is:
(72)
(73)
Static Semantics
(74)
For every subtype S of a tagged type T (specific or class-wide), the following attribute is defined:
(75)
S'External_Tag
Implementation Requirements
(76)
In an implementation, the default external tag for each specific tagged type declared in a partition shall be distinct, so long as the type is declared outside an instance of a generic body. If the compilation unit in which a given tagged type is declared, and all compilation units on which it semantically depends, are the same in two different partitions, then the external tag for the type shall be the same in the two partitions. What it means for a compilation unit to be the same in two different partitions is implementation defined. At a minimum, if the compilation unit is not recompiled between building the two different partitions that include it, the compilation unit is considered the same in the two partitions.

(77)
(78)
Examples
(79)
Examples of attribute definition clauses:
(80)
       Byte : constant := 8;
       Page : constant := 2**12;
(81)
       type Medium is range 0 .. 65_000;
       for Medium'Size use 2*Byte;
       for Medium'Alignment use 2;
       Device_Register : Medium;
       for Device_Register'Size use Medium'Size;
       for Device_Register'Address use System.Storage_Elements.To_Address(16#FFFF_0020#);
(82)
       type Short is delta 0.01 range -100.0 .. 100.0;
       for Short'Size use 15;
(83)
       for Car_Name'Storage_Size use -- specify access type's storage pool size
               2000*((Car'Size/System.Storage_Unit) +1); -- approximately 2000 cars
(84)
       function My_Read(Stream : access Ada.Streams.Root_Stream_Type'Class)
         return T;
       for T'Read use My_Read; -- see 13.13.2

(85)


Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help

Ada WWW Home -- Email comments, additions, corrections, gripes, kudos, etc. to:

Magnus Kempe -- Magnus.Kempe@di.epfl.ch
Copyright statement
Page last generated: 95-03-12