home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 3 / CDASC03.ISO / sorties / 118 / lrm_13 < prev    next >
Text File  |  1993-04-01  |  47KB  |  1,007 lines

  1.  
  2. Copyright 1980, 1982, 1983, owned by the United States Government as 
  3. represented by the Under Secretary of Defense, Research and Engineering.  All 
  4. rights resrved.  Provided that notice of copyright is included on the first 
  5. page, this document may be copied in its entirety without alteration or as 
  6. altered by (1) adding text that is clearly marked as an insertion; (2) shading 
  7. or alteration or highlighting existing text; (3) deleting examples.  
  8. Permission to publish other excerpts should be obtained from the Ada Joint 
  9. Program Office, OUSDRE(R&AT), The Pentagon, Washington, D.C. 20301, U.S.A.
  10.  
  11. ------------------------------------------------------------------------------
  12. ------------------------------------------------------------------------------       
  13.  
  14.  
  15.    13.1 Representation Clauses and Implementation-Dependent Features
  16.  
  17. This chapter describes representation clauses, certain implementation-
  18. dependent features, and other features that are used in system 
  19. programming.
  20.  
  21. 13.1 Representation Clauses
  22.  
  23. Representation clauses specify how the types of the language are to be 
  24. mapped onto the underlying machine.  They can be provided to give more 
  25. efficient representation or to interface with features that are outside 
  26. the domain of the language (for example, peripheral hardware).
  27.  
  28.         representation_clause ::=
  29.               type_representation_clause | address_clause
  30.  
  31.         type_representation_clause ::= length_clause
  32.               | enumeration_representation_clause 
  33.               |record_representation_clause
  34.  
  35. A type representation clause applies either to a type or to a first 
  36. named subtype (that is, to a subtype declared by a type declaration, 
  37. the base type being therefore anonymous).  Such a representation 
  38. clause applies to  all objects that have this type or this first named 
  39. subtype.  At most one enumeration or record representation clause is 
  40. allowed for a given type: an enumeration representation clause is only 
  41. allowed for an enumeration type; a record representation clause, only 
  42. for a record type.  (On the other hand, more than one length clause 
  43. can be provided for a given type; moreover, both a length clause and 
  44. an enumeration or record representation clause can be provided.)  A 
  45. length clause is the only form of representation clause allowed for a 
  46. type derived from a parent type that has (user-defined) derivable 
  47. subprograms.
  48.  
  49. An address clause applies either to an object; to a subprogram, 
  50. package, or task unit; or to an entry.  At most one address clause is 
  51. allowed for any of these entities.
  52.  
  53. A representation clause and declaration of the entity to which the 
  54. clause applies must both occur immediately within the same declarative 
  55. part, package specification, or task specification; the declaration 
  56. must occur before the clause.  In the absence of a representation 
  57. clause for a given declaration, a default representation of this 
  58. declaration is determined by the implementation.  Such a default 
  59. determination occurs no later than the end of the immediately 
  60. enclosing declarative part, package specification, or task 
  61. specification.  For a declaration given in a declarative part, this 
  62. default determination occurs before any enclosed body.
  63.  
  64. In the case of a type, certain occurrences of its name imply that the 
  65. representation of the type must already have been determined.  
  66. Consequently these occurrences force the default determination of any 
  67. aspect of the representation not already determined by a prior type 
  68. representation clause.  This default determination is also forced by 
  69. similar occurrences of the name of a subtype of the type, or of the 
  70. name of any type or subtype that has subcomponents of the type.  A
  71. forcing occurence is any occurrence other than in a type or subtype 
  72. declaration, a subprogram specification, an entry declaration, a deferred 
  73. constant declaration, a pragma, or a representation clause for the type 
  74. itself. In any case, an occurrence within an expression is always forcing.
  75. 
  76.  
  77. A representation clause for a given entity must not appear after an 
  78. occurrence of the name of the entity if this occurrence forces a 
  79. default determination of representation for the entity.
  80.  
  81. Similar restrictions exist for address clauses. For an object, any 
  82. occurrence of its name (after the object declaration) is a forcing 
  83. occurrence.  For a subprogram, package, task unit, or entry, any 
  84. occurrence of a representation attribute of such an entity is a 
  85. forcing occurrence.
  86.  
  87. The effect of the elaboration of a representation clause is to define 
  88. the corresponding aspects of the representation. 
  89.  
  90. The interpretation of some of the expressions that appear in 
  91. representation clauses is implementation_dependent, for example, 
  92. expressions specifying addresses.  An implementation may limit its 
  93. acceptance of representation clauses to those that can be handled 
  94. simply by the underlying hardware.  If a representation clause is 
  95. accepted by an implementation, the compiler must guarantee that the 
  96. net effect of the program is not changed by the presence of the clause, except 
  97. for address clauses and for parts of the program that interrogate
  98. representation attributes. If a program contains a representation clause 
  99. that is not accepted, the program is illegal.  For each implementation, 
  100. the allowed representation clauses, and the conventions used for implementation-
  101. dependent expressions, must be documented in Appendix F of the 
  102. reference manual.
  103.  
  104. Whereas a representation clause is used to impose certain 
  105. characteristics of the mapping of an entity onto the underlying 
  106. machine, pragmas can be used to provide an implementation, with 
  107. criteria for its selection of such a mapping.  The pragma PACK 
  108. specifies that storage minimization should be the main criterion when 
  109. selecting the representation of a record or array type.  Its form is 
  110. as follows:
  111.  
  112.         pragma PACK (type_simple_name);
  113.  
  114. Packing means that gaps between the storage areas allocated to 
  115. consecutive components should be minimized.  It need not, however, 
  116. affect the mapping of each component onto storage.  This mapping can 
  117. itself be influenced by a pragma (or controlled by a representation 
  118. clause) for the component or component type.  The position of a PACK 
  119. pragma, and the restrictions on the named type, are governed by the 
  120. same rules as for a representation clause; in particular, the pragma 
  121. must appear before any use of a representation attribute of the packed 
  122. entity.
  123.  
  124. The pragma PACK is the only language-defied representation pragma. 
  125. Additional representation pragmas may be provided by an 
  126. implementation; these must be documented in Appendix F. (in contrast 
  127. to representation clauses, a pragma that is not accepted by the 
  128. implementation is ignored).
  129.  
  130. Note:
  131.  
  132. No representation clause is allowed for a generic formal type. 
  133.  
  134. References: address clause 13.5, allow 1.6, body 3.9, component 3.3, 
  135. declaration 3.1, declarative part 3.9, default expression 3.2.1, 
  136. deferred constant declaration 7.4, derivable subprogram 3.4, derived 
  137. type 3.4, entity 3.1, entry 9.5, enumeration representation clause 
  138. 13.3, expression 4.4, generic formal type 12.1.2, illegal 1.6, length 
  139. clause 13.2, must 1.6, name 4.1, object 3.2, occur immediately within 
  140. 8.1, package 7, package specification 7.1, parent type 3.4, pragma 
  141. 2.8, record representation clause 13.4, representation attribute 
  142. 13.7.2, 13.7.3, subcomponent 3.3, subprogram 6, subtype 3.3, subtype 
  143. declaration 3.3.2, task specification 9.1, task unit 9, type 3.3, type 
  144. declaration 3.3.1
  145.  
  146. 13.2 Length Clauses
  147.  
  148. A length clause specifies an amount of storage associated with a type.
  149.  
  150. length_clause ::= for attribute use simple_expression;
  151.  
  152. The expression must be of some numeric type and is evaluated during the 
  153. elaboration of the length clause (unless it is a static expression).  The 
  154. prefix of the attribute must denote either a type or a first named subtype.  
  155. The prefix is called T in what follows.  The only allowed attribute 
  156. designators in a length clause are SIZE, STORAGE_SIZE, and SMALL.  The effect 
  157. of the length clause depends on the attribute designator:
  158.  
  159. (a)  Size specification: T'SIZE
  160.  
  161.      The expression must be a static expression of some integer type.  The
  162.      value of the expression specifies an upper bound for the number of bits 
  163.      to be allocated to objects of the type or first named subtype T.  The
  164.      size specification must allow for enough storage space to accommodate
  165.      every allowable value of these objects.  A size specification for a 
  166.      composite type may affect the size of the gaps between the storage areas 
  167.      allocated to consecutive components. On the other hand, it need not 
  168.      affect the size of the storage area allocated to each component.
  169.  
  170.      The size specification is only allowed if the constraints on T and on its 
  171.      subcomponents (if any) are static.  In the case of an unconstrained 
  172.      array type, the index subtypes must also be static.  
  173.  
  174. (b)  Specification of collection size: T'STORAGE_SIZE
  175.  
  176.      The prefix T must denote an access type. The expression must be of some 
  177.      integer type (but need not be static); its value specifies the number of 
  178.      storage units to be reserved for the collection, that is, the storage 
  179.      space needed to contain all objects designated by values of the access 
  180.      type and by values of other types derived form the access type, directly 
  181.      or indirectly.  This form of length clause is not allowed for a type 
  182.      derived from an access type.
  183.  
  184. (c)  Specification of storage for a task activation: T'STORAGE _SIZE
  185.  
  186.      The prefix T must denote a task type.  The expression must be of some 
  187.      integer type (but need not be static); its value specifies the number of 
  188.      storage units to be reserved for an activation (not the code) of a task 
  189.      of the type.
  190.  
  191. (d)  Specification of small for a fixed point type: T'SMALL
  192.  
  193.      The prefix T must denote the first named subtype of a fixed point type.  
  194.      The expression must be a static expression of some real type; its value 
  195.      must be greater than the delta of the first named subtype.  The effect of 
  196.      the length clause is to use this value of small for the representation of 
  197.      values of the fixed point base type.  (The length clause thereby also 
  198.      affects the amount of storage for objects that have this type).
  199.  
  200.  
  201. Notes:
  202.  
  203. A size specification is allowed for an access, task, or fixed point type, 
  204. whether or not another form of length clause is also given for the type.  
  205.  
  206. What is considered to be part of the storage reserved for a collection or 
  207. for an activation of a task is implementation-dependent.  The control 
  208. afforded by length clauses is therefore relative to the implementation
  209. conventions.  For example, the language does not define whether the storage 
  210. reserved for an activation of a task includes any storage needed for the 
  211. collection associated with an access type declared within the task body.  
  212. Neither does it define the method of allocation for objects denoted by 
  213. values of an access type.  For example, the space allocated could be on a 
  214. stack; alternatively, a general dynamic aliocation scheme or fixed storage 
  215. could be used.  
  216.  
  217. The objects allocated in a collection need not have the same size if the 
  218. designated type is an unconstrained array type or an unconstrained type with 
  219. discriminants.  Note also that the allocator itself may require some space 
  220. for internal tables and links.  Hence a length clause for the collection of 
  221. an access type does not always give precise control over the maximum number 
  222. of allocated objects.
  223.  
  224. Examples:
  225.  
  226.       --assumed declarations:
  227.  
  228.       type MEDIUM is range 0 .. 65000;
  229.       type SHORT  is delta 0.01 range -100.0 .. 100.0;
  230.       type DEGREE is delta 0.1  range -360.0 .. 360.0;
  231.  
  232.       BYTE  : constant := 8;
  233.       PAGE  : constant := 2000;
  234.  
  235.       --length clauses:
  236.  
  237.       for COLOR'SIZE  use 1*BYTE; -- see 3.5.1
  238.       for MEDIUM'SIZE use 2*BYTE;
  239.       for SHORT'SIZE  use 15;
  240.  
  241.       for CAR_NAME'STORAGE_SIZE use -- approximately 2000 cars
  242.               2000*((CAR'SIZE/SYSTEM.STORAGE_UNIT) +1);
  243.  
  244.       for KEYBOARD_DRIVERS'STORAGE_SIZE use 1*PAGE;
  245.  
  246. for DEGREE'SMALL use 360.0/2**(SYSTEM.STORAGE_UNIT -1);
  247.  
  248. Notes on the examples:
  249.  
  250. In the length clause for SHORT, fifteen bits is the minimum necessary, 
  251. since the type definition requires SHORT'SMALL=2**(-7) and SHORT'MANTISSA = 
  252. 14.  The length clause for DEGREE forces the model numbers to exactly span 
  253. the range of the type.
  254.  
  255. References: access type 3.8, allocator 4.8, allow 1.6, array type 3.6, 
  256. attribute 4.1.4, collection 3.8, composite type 3.3, constraint 3.3, delta 
  257. of a fixed point  type 3.5.9, derived type 3.4, designate 3.8, elaboration 
  258. 3.9, entity 3.1, evaluation 4.5, expression 4.4, first named subtype 13.1, 
  259. fixed point type 3.5.9, index subtype 3.6, integer type 3.5.4, must 1.6, 
  260. numeric type 3.5, object 3.2, real type 3.5.6, record type 3.7, small of a 
  261. fixed point type 3.5.10, static constraint 4.9, static expression 4.9, 
  262. static subtype 4.9, storage unit 13.7, subcomponent 3.3, system package 
  263. 13.7, task 9, task activation 9.3, task specification 9.1, task type 9.2, 
  264. type 3.3, unconstrained array type 3.6           
  265.  
  266. 13.3 Enumeration Representation Clauses
  267.  
  268. An enumeration representation clause specifies the internal codes for the 
  269. literals of the enumeration type that is named in the clause.
  270.  
  271.       enumeration_representation_clause ::= for type_simple_name use 
  272.                aggregate;
  273.  
  274. The aggregate used to specify this mapping is written as a one-dimensional 
  275. aggregate, for which the index subtype is the enumeration type and the 
  276. component type is universal_integer.
  277.  
  278. All literals of the enumeration type must be provided with distinct integer 
  279. codes, and all choices and component values given in the aggregate must be 
  280. static.  The integer codes specified for the enumeration type must satisfy 
  281. the predefined ordering relation of the type.
  282.  
  283. Example:
  284.  
  285.       type MIX_CODE is (ADD, SUB, MUL, LDA, STA, STZ);
  286.  
  287.       for MIX_CODE use
  288.          (ADD => 1, SUB =.2, MUL => 3, LDA => 8, STA => 24, STZ =>33);
  289.  
  290. Notes:
  291.  
  292. The attributes SUCC, PRED, and POS are defined even for enumeration types 
  293. with a noncontiguous representation; their definition corresponds to the 
  294. (logical) type declaration and is not affected by the enumeration 
  295. representation clause.  In the example, because of the need to avoid the 
  296. omitted values, these functions are likely to be less efficiently 
  297. implemented than they could be in the absence of a representation clause.  
  298. Similar considerations apply when such types are used for indexing.
  299.  
  300. References: aggregate 4.3, array aggregate 4.3.2, array type 3.6, attribute 
  301. of an enumeration type 3.5.5, choice 3.7.3, component 3.3, enumeration 
  302. literal 3.5.1, enumeration type 3.5.1, function 6.5, index 3.6, index 
  303. subtype 3.6, literal 4.2, ordering relation of an enumeration type 3.5.1, 
  304. representation clause 13.1, simple name 4.1, static expression 4.9, type 
  305. 3.3, type declaration 3.3.1, universal_integer type 3.5.4
  306.  
  307. 13.4 Record Representation Clauses
  308.  
  309. A record representation clause specifies the storage representation of 
  310. records, that is, the order, position, and size of record components 
  311. (including discriminants, if any).
  312.  
  313.       record_representation_clause ::=
  314.         for type_simple_name use
  315.           record [alignment_clause]
  316.             {component clause}
  317.           end record;
  318.  
  319.       alignment_clause ::= at mod static_simple_expression;
  320.  
  321.       component_clause ::=
  322.         component_name at static_simple_expression range static_range;
  323. 
  324.  
  325. The simple expression given after the reserved words at mod in an alignment 
  326. clause, or after the reserved word at in a component clause, must be a 
  327. static expression of some integer type.  If the bounds of the range of a 
  328. component clause are defined by simple expressions, then each bound of the
  329. range must be defined by a static expression of some integer type, but the 
  330. two bounds need not have the same integer type.
  331.  
  332. An alignment clause forces each record of the given type to be allocated at 
  333. a starting address that is a multiple of the value of the given expression 
  334. (that is, the address modulo the expression must be zero). An 
  335. implementation may place restrictions on the allowable alignments. 
  336.  
  337. A component clause specifies the storage place of a component, relative to 
  338. the start of the record.  The integer defined by the static expression of a 
  339. component clause is a relative address expressed in storage units.  The 
  340. range defines the bit positions of the storage place, relative to the 
  341. storage unit.  The first storage unit of a record is numbered zero.The 
  342. first bit of a storage unit is numbered zero.  The ordering of bits in a 
  343. storage unit is machine_dependent and may extend to adjacent storage units 
  344. (For a specific machine, the size in bits of a storage unit is given by the 
  345. configuration-dependent named number SYSTEM.STORAGE_UNIT.)  Whether a 
  346. component is allowed to overlap a storage boundary, and if so, how, is 
  347. implementation-defined.
  348.  
  349. At most one component clause is allowed for each component of the record 
  350. type, including for each discriminant (component clauses may be given for 
  351. some, all, or none of the components).  If no component clause is given for 
  352. a component, then the choice of the storage place for the component is left 
  353. to the compiler. If component clauses are given for all components, the 
  354. record representation clause completely specifies the representation of the 
  355. record type and must be obeyed exactly by the compiler.
  356.  
  357. Storage places within a record variant must not overlap, but overlap of the 
  358. storage for distinct variants is allowed.  Each component clause must allow 
  359. for enough storage space to accommodate  every allowable value of the 
  360. component.  A component clause is only allowed for a component if any 
  361. constraint on this component or on any of its subcomponents is static.
  362.  
  363. An implementation may generate names that denote implementation-dependent 
  364. components (for example, one containing the offset of another component).  
  365. Such implementation-dependent names can be used in record representation 
  366. clauses (these names need not be simple names; for example, they could be 
  367. implementation-dependent attributes).
  368.  
  369. Example:
  370.  
  371.       WORD : constant := 4;  --  storage unit is byte, 4 bytes per word
  372.  
  373. type STATE         is (A,M,W,P);
  374. type MODE          is (FIX, DEC, EXP, SIGNIF);
  375.  
  376. type BYTE_MASK     is array (0.. 7) of BOOLEAN;
  377. type STATE_MASK    is array (STATE) of BOOLEAN;
  378. type MODE_MASK     is array (MODE)  of BOOLEAN;
  379.  
  380. type PROGRAM_STATUS_WORD is
  381.   record
  382.       SYSTEM_MASK        : BYTE_MASK;
  383.       PROTECTION_KEY     : INTEGER range 0 .. 3;
  384.       MACHINE_STATE      : STATE_MASK;
  385.       INTERRUPT_CAUSE    : INTERRUPTION_CODE;
  386.       ILC                : INTEGER range 0 .. 3;
  387.       CC                 : INTEGER range 0 .. 3;
  388.       PROGRAM_MASK       : MODE_MASK;
  389.       INST_ADDRESS       : ADDRESS;
  390. end record;
  391. 
  392.  
  393.   for PROGRAM_STATUS_WORD use
  394.     record at mod 8;
  395.         SYSTEM_MASK      at 0*WORD range 0  .. 7;  
  396.         PROTECTION_KEY   at 0*WORD range 10 .. 11; -- bits 8,9 unused
  397.         MACHINE_STATE    at 0*WORD range 12 .. 15;
  398.         INTERRUPT_CAUSE  at 0*WORD range 16 .. 31;
  399.         ILC              at 1*WORD range 0  .. 1;  -- second word
  400.         CC               at 1*WORD range 2  .. 3;
  401.         PROGRAM_MASK     at 1*WORD range 4  .. 7;
  402.         INST_ADDRESS     at 1*WORD range 8  .. 31;
  403.     end record;
  404.  
  405.   for PROGRAM_STATUS_WORD'SIZE use 8*SYSTEM.STORAGE_UNIT;
  406.  
  407. Note on the example:
  408.  
  409. The record representation clause defines the record layout.  The length 
  410. clause guarantees that exactly eight storage units are used.
  411.  
  412. References: allow 1.6, attribute 4.1.4, constant 3.2.1, constraint 3.3, 
  413. discriminant 3.7.1, integer type 3.5.4, must 1.6, named number 3.2, range 
  414. 3.5, record component 3.7, record type 3.7, simple expression 4.4, simple 
  415. name 4.1, static constraint 4.9, static expression 4.9, storage unit 13.7, 
  416. subcomponent 3.3, system package 13.7, variant 3.7.3
  417.  
  418. 13.5 Address Clauses
  419.  
  420. An address clause specifies a required address in storage for an entity.
  421.  
  422.       address_clause ::= for simple_name use at simple_expression;
  423.  
  424. The expression given after the reserved word at must be of the type ADDRESS 
  425. defined in the package SYSTEM (see 13.7); this package must be named by a 
  426. with clause that applies to the compilation unit in which the address 
  427. clause occurs.  The conventions that define the interpretation of a value 
  428. of the type ADDRESS as an address, as an interrupt level, or whatever it 
  429. may be, are implementation-dependent.  The allowed nature of the simple 
  430. name and the meaning of the corresponding address are as follows:
  431.  
  432. (a) Name of an object: the address is that required for the object 
  433.     (variable or constant).
  434.  
  435. (b) Name of a subprogram, package, or task unit: the address is that
  436.     required for the machine code associated with the body of the program 
  437.     unit.
  438.  
  439. (c) Name of a single entry: the address specifies a hardware interrupt to 
  440.     which the single entry is to be linked.
  441.  
  442. If the simple name is that of a single task, the address clause is 
  443. understood to refer to the task unit and not to the task object.  In all 
  444. cases, the address clause is only legal if exactly one declaration with 
  445. this identifier occurs earlier, immediately within the same declarative 
  446. part, package specification, or task specification.  A name declared by a 
  447. renaming declaration is not allowed as the simple name.  
  448.  
  449. Address clauses should not be used to achieve overlays of objects or 
  450. overlays of program units. Nor should a given interrupt be linked to more 
  451. than one entry. Any program using address clauses to achieve such effects 
  452. is erroneous.
  453. 
  454.  
  455. Example:
  456.  
  457.     for CONTROL use at 16#0020#; -- assuming that SYSTEM.ADDRESS is an integer 
  458.     type
  459.  
  460. Notes:
  461.  
  462. The above rules imply that if two subprograms overload each other and are 
  463. visible at a given point, an address clause for any of them is not legal at 
  464. this point.  Similarly if a task specification declares entries that 
  465. overload each other, they cannot be interrupt entries.  The syntax does not 
  466. allow an address clause for a library unit.  An implementation may provide 
  467. pragmas for the specification of program overlays. 
  468.  
  469. References: address predefined type 13.7, apply 10.1.1, compilation unit 
  470. 10.1, constant 3.2.1, entity 3.1, entry 9.5, erroneous 1.6, expression 
  471. 4.4, library unit 10.1, name 4.1, object 3.2, package 7, pragma 2.8, 
  472. program unit 6, reserved word 2.9, simple expression 4.4, simple name 4.1, 
  473. subprogram 6, subprogram body 6.3, system package 13.7, task body 9.1, task 
  474. object 9.2, task unit 9, type 3.3, variable 3.2.1, with clause 10.1.1
  475.  
  476. 13.5.1 Interrupts 
  477.  
  478. An address clause given for an entry associates the entry with some device 
  479. that may cause an interrupt; such an entry is referred to in this section 
  480. as an interrupt entry.  If control information is supplied upon an 
  481. interrupt, it is passed to an associated interrupt entry as one or more 
  482. parameters of mode in; only parameters of this mode are allowed.
  483.  
  484. An interrupt acts as an entry call issued by a hardware task whose priority 
  485. is higher than the priority of the main program, and also higher than the 
  486. priority of any user-defined task (that is, any task whose type is declared 
  487. by a task unit in the program).  The entry call may be an ordinary entry 
  488. call, a timed entry call, or a conditional entry call, depending on the 
  489. kind of interrupt and on the implementation.  
  490.  
  491. If a select statement contains both a terminate alternative and an accept 
  492. alternative for an interrupt entry, then an implementation may impose 
  493. further requirements for the selection of the terminate alternative in 
  494. addition to those given in section 9.4.
  495.  
  496. Example:
  497.  
  498.       task INTERRUPT_HANDLER is
  499.         entry DONE;
  500.         for DONE use at 16#40#; assuming that SYSTEM.ADDRESS is an integer 
  501.           type
  502.         end INTERRUPT_HANDLER;
  503.  
  504. Notes: 
  505.  
  506. Interrupt entry calls need only have the semantics described above; they 
  507. may be implemented by having the hardware directly execute the appropriate 
  508. accept statements. 
  509.  
  510. Queued interrupts correspond to ordinary entry calls. Interrupts that are 
  511. lost if not immediately processed correspond to conditional entry calls. It 
  512. is a consequence of the priority rules that an accept statement executed in 
  513. response to an interrupt takes precedence over ordinary, user-defined 
  514. tasks, and can be executed without first invoking a scheduling action.
  515. 
  516. One of the possible effects of an address clause for an interrupt entry is 
  517. to specify the priority of the interrupt (directly or indirectly).  Direct 
  518. calls to an interrupt entry are allowed. 
  519.  
  520. References: accept alternative 9.7.1, accept statement 9.5, address 
  521. predefined type 13.7, allow 1.6, conditional entry call 9.7.2, entry 9.5, 
  522. mode 6.1, parameter of a subprogram 6.2, priority of a task 9.8, select 
  523. alternative 9.7.1, select statement 9.7, system package 13.7, task 9, 
  524. terminate alternative 9.7.1, timed entry call 9.7.3
  525.  
  526. 13.6  Change of Representation
  527.  
  528. At most one representation clause is allowed for a given type and a given 
  529. aspect of its representation. Hence, if an alternative representation is 
  530. needed, it is necessary to declare a second type, derived from the first, 
  531. and to specify a different representation for the second type.
  532.  
  533. Example:
  534.  
  535.   -- PACKED_DESCRIPTOR and DESCRIPTOR are two different types
  536.   -- with identical characteristics, apart from their representation
  537.  
  538.   type DESCRIPTOR is
  539.       record
  540.         -- components of a descriptor
  541.       end record;
  542.  
  543.   type PACKED_DESCRIPTOR is new DESCRIPTOR;
  544.  
  545.   for PACKED_DESCRIPTOR use
  546.       record
  547.         -- component clauses for some or for all components
  548.       end record;
  549.  
  550. Change of representation can now be accomplished by assignment with explicit 
  551. type conversions:
  552.  
  553.       D : DESCRIPTOR;
  554.       P : PACKED_DESCRIPTOR;
  555.  
  556.       P := PACKED_DESCRIPTOR (D); -- pack D
  557.       D := DESCRIPTOR(P);         -- unpack P
  558.  
  559. References: assignment 5.2, derived type 3.4, type 3.3, type conversion 
  560. 4.6, type declaration 3.1, representation clause 13.1
  561.  
  562. 13.7 The Package System
  563.  
  564. For each implementation there is a predefined library package called SYSTEM
  565. which includes the definitions of certain configuration-dependent 
  566. characteristics.  The specification of the package SYSTEM is 
  567. implementation-dependent and must be given in Appendix F.  The visible part 
  568. of this package must contain at least the following declarations.
  569.  
  570. package SYSTEM is 
  571.       type ADDRESS  is implementation_defined;
  572.       type NAME     is implementation_defined_enumeration_type;
  573.  
  574.       SYSTEM_NAME    : constant NAME  := implementation_defined;
  575.  
  576.       STORAGE_UNIT   : constant := implementation_defined;
  577.       MEMORY_SIZE    : constant := implementation_defined;
  578.  
  579.       --System-Dependent Named Numbers:
  580.  
  581.       MIN_INT        : constant := implementation_defined;
  582.       MAX_INT        : constant := implementation_defined;
  583.       MAX_DIGITS     : constant := implementation_defined;
  584.       MAX_MANTISSA   : constant := implementation_defined;
  585.       FINE_DELTA     : constant := implementation_defined;
  586.       TICK           : constant := implementation_defined;
  587.  
  588.       --Other System_Dependent Declarations
  589.  
  590.       subtype PRIORITY is INTEGER range implementation_defined;
  591.  
  592.       ...
  593.   end SYSTEM;
  594.  
  595. The type ADDRESS is the type of the addresses provided in address clauses; 
  596. it is also the type of the result delivered by the attribute ADDRESS. 
  597. Values of the enumeration type NAME are the names of alternative machine 
  598. configurations handled by the implementation; one of these is the constant 
  599. SYSTEM_NAME.  The named number STORAGE_UNIT is the number of bits per 
  600. storage unit; the named number MEMORY_SIZE is the number of available 
  601. storage units in the configuration; these named numbers are of the type 
  602. universal_integer. 
  603.  
  604. An alternative form of the package SYSTEM, with given values for any of 
  605. SYSTEM_NAME, STORAGE_UNIT, and MEMORY_SIZE, can be obtained by means of the 
  606. corresponding pragmas.  These pragmas are only allowed at the start of a 
  607. compilation, before the first compilation unit (if any) of the compilation.
  608.  
  609.       pragma SYSTEM_NAME (enumeration_literal);
  610.  
  611. The effect of the above pragma is to use the enumeration literal with the 
  612. specified identifier for the definition of the constant SYSTEM_NAME. This
  613. pragma is only allowed if the specified identifier corresponds to one of 
  614. the literals of the type NAME.
  615.  
  616.       pragma STORAGE_UNIT (numeric_literal);
  617.  
  618. The effect of the above pragma is to use the value of the specified numeric 
  619. literal for the definition of the named number STORAGE_UNIT.
  620.  
  621.       pragma MEMORY_SIZE (numeric_literal);
  622.  
  623. The effect of the above pragma is to use the value of the specified numeric 
  624. literal for the definition of the named number MEMORY_SIZE.   
  625.  
  626. The compilation of any of these pragmas causes an implicit recompilation of 
  627. the package SYSTEM.  Consequently any compilation unit that names SYSTEM in 
  628. its context clause becomes obsolete after this implicit recompilation. An 
  629. implementation may impose further limitations on the use of these pragmas. 
  630. For example, an implementation may allow them only at the start of the 
  631. first compilation, when creating a new program library.
  632.  
  633. Note: 
  634.  
  635. It is a consequence of the visibility rules that a declaration given in the 
  636. package SYSTEM is not visible in a compilation unit unless this package is 
  637. mentioned by a with clause that applies (directly or indirectly) to the 
  638. compilation unit.
  639.  
  640. References: address clause 13.5, apply 10.1.1, attribute 4.1.4, compilation 
  641. unit 10.1, must 1.6, named number 3.2, number declaration 3.2.2, numeric 
  642. literal 2.4, package 7, package specification 7.1, pragma 2.8, program 
  643. library 10.1, type 3.3, visibility 8.3, visible part 7.2, with clause 
  644. 10.1.1
  645.  
  646. 13.7.1 System-dependent Named Numbers
  647.  
  648. Within the package SYSTEM, the following named numbers are declared.  The 
  649. numbers FINE_DELTA and TICK are of the type universal_real; the others are 
  650. of the type universal_integer.
  651.  
  652. MIN_INT      The smallest (most negative) value of all predefined integer 
  653.              types.
  654.  
  655. MAX_INT      The largest (most positive) value of all predefined integer 
  656.              types.
  657.  
  658. MAX_DIGITS   The largest value allowed for the number of significant 
  659.              decimal digits in a floating point constraint.
  660.  
  661. MAX_MANTISSA The largest possible number of binary digits in the mantissa 
  662.              of model numbers of a fixed point subtype.
  663.  
  664. FINE_DELTA   The smallest delta allowed in a fixed point constraint that 
  665.              has the range constraint -1.0 .. 1.0.
  666.  
  667. TICK         The basic clock period, in seconds.
  668.  
  669. References: allow 1.6, delta of a fixed point constraint 3.5.9, fixed point 
  670. constraint 3.5.9, floating point constraint 3.5.7, integer type 3.5.4, 
  671. model number 3.5.6, named number 3.2, package 7, range constraint 3.5, 
  672. system package 13.7, type 3.3, universal_integer type 3.5.4, universal_real 
  673. type 3.5.6   
  674.  
  675. 13.7.2 Representation Attributes
  676.  
  677. The values of certain implementation-dependent characteristics can be 
  678. obtatined by interrogating appropriate representation attributes.  These 
  679. attributes are described below.
  680.  
  681. For any object, program unit, label, or entry X:
  682.  
  683. X'ADDRESS      Yields the address of the first of the storage units 
  684.                allocated to X.  For a subprogram, package, task unit or 
  685.                label, this value refers to the machine code associated with 
  686.                the corresponding body or statement.  For an entry for which 
  687.                an address clause has been given, the value refers to the 
  688.                corresponding hardware interrupt. The value of this 
  689.                attribute is of the type ADDRESS defined in the package 
  690.                SYSTEM.
  691.  
  692. For any type or subtype X or for any object X:
  693.  
  694. X'SIZE         Applied to an object, yields the number of bits allocated to 
  695.                hold the object.  Applied to a type or subtype, yields the 
  696.                minimum number of bits that is needed by the implementation 
  697.                to hold any possible object of this type or subtype. The 
  698.                value of this attribute is of the type universal_integer. 
  699.  
  700. For the above two representation attributes, if the prefix is the name of a 
  701. function, the attribute is understood to be an attribute of the function 
  702. (not of the result of calling the function).  Similarly, if the type of the 
  703. prefix is an access type, the attribute is understood to be an attribute of 
  704. the prefix (not of the designated object: attributes of the latter can be 
  705. written with a prefix ending with the reserved word all).
  706.  
  707. For any component C of a record object R:
  708.  
  709. R.C'POSITION   Yields the offset, from the start of the first storage unit 
  710.                occupied by the record, of the first of the storage units 
  711.                occupied by C.  This offset is measured in storage units.  
  712.                The value of this attribute is of the type 
  713.                universal_integer.
  714.  
  715. R.C'FIRST_BIT  Yields the offset, from the start of the first of the 
  716.                storage units occupied by C, of the last bit occupied by C.  
  717.                This offset is measured in bits.  The value of this 
  718.                attribute is of the type universal_integer.
  719.  
  720. R.C'LAST_BIT   Yields the offset, from the start of the first of the 
  721.                storage units occupied by C, of the last bit occupied by C.  
  722.                This offset is measured in bits. The value of this attribute 
  723.                is of the type universal_integer.
  724.  
  725. For any access type or subtype T: 
  726.  
  727. T'STORAGE_SIZE Yields the total number of storage units reserved for the 
  728.                collection associated with the base type of T.  The value of 
  729.                this attribute is of the type universal_integer.
  730.  
  731. For any task type or task object T:
  732.  
  733. T'STORAGE_SIZE Yields the number of storage units reserved for each 
  734.                activation of a task of the type T or for the activation of 
  735.                the task object T.  The value of this attribute is of the 
  736.                type universal_integer. 
  737.  
  738. Notes: 
  739.  
  740. For a task object X, the attribute X'SIZE gives the number of bits used to 
  741. hold the object X, whereas X'STORAGE_SIZE gives the number of storage units 
  742. allocated for the activation of the task designated by X.  For a formal 
  743. parameter X, if parameter passing is achieved by copy, then the attribute 
  744. X'ADDRESS yields the address of the local copy; if parameter passing is by 
  745. reference, then the address is that of the actual parameter.
  746.  
  747. References: access subtype 3.8, access type 3.8, activation 9.3, actual 
  748. parameter 6.2, address clause 13.5, address predefined type 13.7, attribute 
  749. 4.1.4, base type 3.3, collection 3.8, component 3.3, entry 9.5, formal 
  750. parameter 6.1 6.2, label 5.1, object 3.2, package 7, package body 7.1, 
  751. parameter passing 6.2, program unit 6, record object 3.7, statement 5, 
  752. storage unit 13.7, subprogram 6, subprogram body 6.3, subtype 3.3, system 
  753. predefined package 13.7, task 9, task body 9.1, task object 9.2, task type 
  754. 9.2, task unit 9, type 3.3, universal_integer type 3.5.4
  755.  
  756. 13.7.3 Representation Attributes of Real Types
  757.  
  758. For every real type or subtype T, the following machine-dependent 
  759. attributes are defined, which are not related to the model numbers.  
  760. Programs using these attributes may thereby exploit properties that go 
  761. beyond the minimal properties associated with the numeric type (see section 
  762. 4.5.7 for the rules defining the accuracy of operations with real 
  763. operands). Precautions must therefore be taken when using these machine-
  764. dependent attributes if portability is to be ensured.
  765.  
  766. For both floating point and fixed point types:
  767.  
  768. T'MACHINE_ROUNDS    Yields the value TRUE if every predefined arithmetic 
  769.                     operation on values of the base type of T either returns 
  770.                     an exact result or performs rounding; yields the value 
  771.                     FALSE otherwise.  The value of this attribute is of the 
  772.                     predefined type BOOLEAN.
  773.  
  774. T'MACHINE_OVERFLOWS Yields the value TRUE if every predefined operation on 
  775.                     values of the base type of T either provides a correct 
  776.                     result, or raises the exception NUMERIC_ERROR in 
  777.                     overflow situations (see 4.5.7); yields the value FALSE 
  778.                     otherwise. The value of this attribute is of the 
  779.                     predefined type BOOLEAN.
  780.  
  781. For floating point types, the following attributes provide characteristics 
  782. of the underlying machine representation, in terms of the canonical form 
  783. defined in section 3.5.7:
  784.  
  785. T'MACHINE_RADIX     Yields the value of the radix used by the machine 
  786.                     representation of the base type of T (the digits are 
  787.                     extended digits in the range 0 to T'MACHINE_RADIX -1). 
  788.                     The value of this attribute is of the type 
  789.                     universal_integer.
  790.  
  791. T'MACHINE_EMAX      Yields the largest value of exponent for the machine 
  792.                     representation of the base type of T.  The value of 
  793.                     this attribute is of the type universal_integer.
  794.  
  795. T'MACHINE_EMIN      Yields the smallest (most negative) value of exponent 
  796.                     for the machine representation of the base type of T.  
  797.                     The value of this attribute is of the type 
  798.                     universal_integer.   
  799.  
  800. Note: For many machines the largest machine representable number of type F 
  801. is almost 
  802.       (F'MACHINE_RADIX)**(F'MACHINE_EMAX),
  803.  
  804. and the smallest positive representable number is 
  805.  
  806.       F'MACHINE_RADIX ** (F'MACHINE_EMIN -1)
  807.  
  808. References:arithmetic operator 4.5, attribute 4.1.4, base type 3.3, boolean 
  809. predefined type 3.5.3, false boolean value 3.5.3, fixed point type 3.5.9, 
  810. floating point type 3.5.7, model number 3.5.6, numeric type 3.5, 
  811. numeric_error exception 11.1, predefined operation 3.3.3, radix 3.5.7, real 
  812. type 3.5.6, subtype 3.3, true boolean value 3.5.3,  type 3.3, 
  813. universal_integer type 3.5.4
  814.  
  815. 13.8 Machine Code Insertions
  816.  
  817. A machine code insertion can be achieved by a call to a procedure whose 
  818. sequence of statements contains code statements.
  819.  
  820.       code_statement ::= type_mark'record_aggregate;
  821.  
  822. A code statement is only allowed in the sequence of statements of a 
  823. procedure body.  If a procedure body contains code statements, then within 
  824. this procedure body the only allowed form of statement is a code statement 
  825. (labeled or not), the only allowed declarative items are use clauses, and 
  826. no exception handler is allowed (comments and pragmas are allowed as 
  827. usual).  
  828.  
  829. Each machine instruction appears as a record aggregate of a record type 
  830. that defines the corresponding instruction.  The base type of the type mark 
  831. of a code statement must be declared within the predefined library package 
  832. called MACHINE_CODE; this package must be named by a with clause that 
  833. applies to the compilation unit in which the code statement occurs.  An
  834. implementation is not required to provide such a package.
  835.  
  836. An implementation is allowed to impose further restrictions on the record 
  837. aggregates allowed in code statements.  For example, it may require that 
  838. expressions contained in such aggregates be static expressions.  
  839.  
  840. An implementation may provide machine-dependent pragmas specifying register 
  841. conventions and calling conventions.  Such pragmas must be documented in 
  842. Appendix F
  843.  
  844. Example:
  845.  
  846.       M : MASK
  847.       procedure SET_MASK; pragma INLINE(SET_MASK);
  848.  
  849.       procedure SET_MASK is 
  850.         use MACHINE_CODE;
  851.       begin
  852.         SI_FORMAT'(CODE => SSM, B => M'BASE_REG, D => M'DISP);
  853.         --  M'BASE_REG and M'DISP are implementation-specific predefined 
  854.             attributes
  855.       end;  
  856.  
  857. References: allow 1.6, apply 10.1.1, comment 2.7, compilation unit 10.1, 
  858. declarative item 3.9, exception handler 11.2, inline pragma 6.3.2, labeled 
  859. statement 5.1, library unit 10.1, package 7, pragma 2.8, procedure 6 6.1, 
  860. procedure body 6.3, record aggregate 4.3.1, record type 3.7, sequence of 
  861. statements 5.1, statement 5, static expression 4.9, use clause 5.4, with 
  862. clause 10.1.1
  863.  
  864. 13.9 Interface to Other Languages
  865.  
  866. A subprogram written in another language can be called from an Ada program 
  867. provided that all communication is achieved via parameters and function 
  868. results. A pragma of the form
  869.  
  870.       pragma INTERFACE (language_name, subprogram_name);
  871.  
  872. must be given for each such subprogram; a subprogram name is allowed to 
  873. stand for several overloaded subprograms.  This pragma is allowed at the 
  874. place of a declarative item, and must apply in this case to a subprogram 
  875. declared by an earlier declarative item of the same declarative part or 
  876. package specification.  The pragma is also allowed for a library unit; in 
  877. this case the pragma must appear after the subprogram declaration, and 
  878. before any subsequent compilation unit.  The pragma specifies the other 
  879. language (and therby the calling conventions ) and informs the compiler 
  880. that an object module will be supplied for the corresponding subprogram.  A 
  881. body is not allowed for such a subprogram (not even in the form of a body 
  882. stub) since the instructions of the subprogram are written in another 
  883. language.  
  884.  
  885. This capability need not be provided by all implementations.  An 
  886. implementation may place restrictions on the allowable forms and places of 
  887. parameters and calls.
  888.  
  889. Example:
  890.  
  891.       package FORT_LIB is 
  892.         function SQRT (X : FLOAT) return FLOAT;
  893.         function EXP  (X : FLOAT) return FLOAT;
  894.       private 
  895.         pragma INTERFACE(FORTRAN, SQRT);
  896.         pragma INTERFACE(FORTRAN, EXP);
  897.       end FORT_LIB;
  898.  
  899. Notes:
  900.  
  901. The conventions used by other language processors that call Ada programs 
  902. are not part of the Ada language definition.  Such conventions must be 
  903. defined by these other language processors. 
  904.  
  905. The pragma INTERFACE is not defined for generic subprograms.
  906.  
  907. References: allow 1.6, body stub 10.2, compilation unit 10.1, declaration 
  908. 3.1, declarative item 3.9, declarative part 3.9, function result 6.5, 
  909. library unit 10.1, must 1.6, name 4.1, overloaded subprogram 6.6, package 
  910. specification 7.1, parameter of a subprogram 6.2, pragma 2.8, subprogram 6, 
  911. subprogram body 6.3, subprogram call 6.4, subprogram declaration 6.1
  912.  
  913. 13.10 Unchecked Programming
  914.  
  915. The predefined generic library subprograms UNCHECKED_DEALLOCATION and 
  916. UNCHECKED_CONVERSION are used for unchecked storage deallocation and for 
  917. unchecked type conversions.
  918.  
  919.       generic
  920.          type OBJECT is limited private;
  921.          type NAME   is access  OBJECT;
  922.       procedure UNCHECKED_DEALLOCATION(X: in out NAME);
  923.  
  924.       generic
  925.          type SOURCE is limited private;
  926.          type TARGET is limited private;
  927.       function UNCHECKED_CONVERSION(S : SOURCE) return TARGET;
  928.  
  929. References: generic subprogram 12.1, library unit 10.1, type 3.3
  930.  
  931. 13.10.1 Unchecked Storage Deallocation
  932.  
  933. Unchecked storage deallocation of an object designated by a value of an 
  934. access type is achieved by a call of a procedure that is obtained by 
  935. instantiation of the generic procedure UNCHECKED_DEALLOCATION.  For 
  936. example:
  937.  
  938.       procedure FREE is new UNCHECKED_DEALLOCATION(object_type_name,
  939.              access_type_name);
  940.  
  941. Such a FREE procedure has the following effect:
  942.  
  943. (a)  after executing FREE(X), the value of X is null;
  944.  
  945. (b) FREE(X), when X is already equal to null, has no effect;
  946.  
  947. (c) FREE(X), when X is not equal to null, is an indication that the object 
  948.     designated by X is no longer required, and that the storage it occupies 
  949.     is to be reclaimed.
  950.  
  951. If X and Y designate the same object, then accessing this object through Y 
  952. is erroneous if this access is performed (or attempted) after the call 
  953. FREE(X); the efeect of each such access is not defined by the language.
  954.  
  955. Notes:
  956.  
  957. It is a consequence of the visibility rules that the generic procedure 
  958. UNCHECKED_DEALLOCATION is not visible in a compilation unit unless this 
  959. generic procedure is mentioned by a with clause that applies to the 
  960. compilation unit.
  961.  
  962. If X designates a task object, the call FREE(X); has no effect on the task 
  963. designated by the value of this task object.  The same holds for any 
  964. subcomponent of the object designated by X, if this subcomponent is a task 
  965. object.
  966.  
  967. References: access type 3.8, apply 10.1.1, compilation unit 10.1, designate 
  968. 3.8 9.1, erroneous 1.6, generic instantiation 12.3, generic procedure 12.1, 
  969. generic unit 12, library unit 10.1, null access value 3.8, object 3.2, 
  970. procedure 6, procedure call 6.4, subcomponent 3.3, task 9, task object 9.2,
  971. visibility 8.3, with clause 10.1.1
  972.  
  973. 13.10.2 Unchecked Type Conversions
  974.  
  975. An unchecked type conversion can be achieved by a call of a function that 
  976. is obtained by instantiation of the generic function UNCHECKED_CONVERSION.
  977.  
  978. The effect of an unchecked conversion is to return the (uninterpreted) 
  979. parameter value as a value of the target type, that is, the bit pattern 
  980. defining the source value is returned unchanged as the bit pattern defining 
  981. a value of the target type.  An implementation may place restrictions on 
  982. unchecked conversions, for example, restrictions dependeing on the 
  983. respective sizes of objects of the source and target type. Such 
  984. restrictions must be documented in appendix F.
  985.  
  986. Whenever unchecked conversions are used, it is the programmer's 
  987. responsibility to ensure that these conversions maintain the properties 
  988. that are guaranteed by the language for objects of the target type.  
  989. Programs that violate these properties by means of unchecked conversions 
  990. are erroneous.
  991.  
  992. Note:
  993.  
  994. It is a consequence of the visibility rules that the generic function 
  995. UNCHECKED_CONVERSION is not visible in a compilation unit unless this 
  996. generic function is mentioned by a with clause that applies to the 
  997. compilation unit. 
  998.  
  999. References: apply 10.1.1, compilation unit 10.1, erroneous 1.6, generic 
  1000. function 12.1, instantiation 12.3, parameter of a subprogram 6.2, type 3.3, 
  1001. with clause 10.1.1
  1002.  
  1003.  
  1004.  
  1005.