home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / lrm / chap13.doc < prev    next >
Encoding:
Text File  |  1988-05-03  |  50.9 KB  |  2,180 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. The following document is a draft  of  the  corresponding  chapter  of  the
  7. version  of  the  Ada  Reference  Manual  produced  in response to the Ansi
  8. Canvass.  It is given a limited circulation  to  Ada  implementers  and  to
  9. other groups contributing comments (according to the conventions defined in
  10. RRM.comments).  This draft should not be referred to in any publication.
  11.  
  12.  
  13.  
  14.                       ANSI-RM-13-v23 - Draft Chapter
  15.  
  16.      13  Representation Clauses and Implementation-Dependent Features
  17.                                 version 23
  18.  
  19.                                  83-02-11
  20.  
  21. This revision has addressed all comments up to #5795
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.      13. Representation Clauses and Implementation-Dependent Features
  78.  
  79.  
  80.  
  81. This      chapter     describes     representation     clauses,     certain
  82. implementation-dependent features, and other  features  that  are  used  in
  83. system programming.
  84.  
  85.  
  86.  
  87. 13.1  Representation Clauses
  88.  
  89.  
  90. Representation  clauses  specify  how  the  types of the language are to be
  91. mapped onto the underlying machine.  They can  be  provided  to  give  more
  92. efficient representation or to interface with features that are outside the
  93. domain of the language (for example, peripheral hardware).
  94.  
  95.     representation_clause ::=
  96.          type_representation_clause | address_clause
  97.  
  98.     type_representation_clause ::= length_clause
  99.        | enumeration_representation_clause | record_representation_clause
  100.  
  101. A  type  representation clause applies either to a type or to a first named
  102. subtype (that is, to a subtype declared by a  type  declaration,  the  base
  103. type  being  therefore anonymous).  Such a representation clause applies to
  104. all objects that have this type or this first named subtype.  At  most  one
  105. enumeration  or  record  representation clause is allowed for a given type:
  106. an enumeration representation clause is only  allowed  for  an  enumeration
  107. type;   a  record  representation  clause, only for a record type.  (On the
  108. other hand, more than one length clause can be provided for a  given  type;
  109. moreover,  both a length clause and an enumeration or record representation
  110. clause  can  be  provided.)   A  length  clause  is  the   only   form   of
  111. representation  clause  allowed  for a type derived from a parent type that
  112. has (user-defined) derivable subprograms.
  113.  
  114. An address clause applies either to an object;  to a  subprogram,  package,
  115. or  task  unit;  or to an entry.  At most one address clause is allowed for
  116. any of these entities.
  117.  
  118. A representation clause and the declaration of  the  entity  to  which  the
  119. clause  applies  must  both  occur  immediately within the same declarative
  120. part, package specification, or task specification;  the  declaration  must
  121. occur  before  the clause.  In the absence of a representation clause for a
  122. given  declaration,  a  default  representation  of  this  declaration   is
  123. determined  by  the implementation.  Such a default determination occurs no
  124. later than the end of the immediately enclosing declarative  part,  package
  125. specification,  or  task  specification.   For  a  declaration  given  in a
  126. declarative part, this default determination  occurs  before  any  enclosed
  127.  
  128.  
  129.                                   13 - 1
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138. body.
  139.  
  140. In  the  case  of  a  type,  certain occurrences of its name imply that the
  141. representation of the type must already have been determined.  Consequently
  142. these occurrences force the default determination  of  any  aspect  of  the
  143. representation  not  already  determined  by  a  prior  type representation
  144. clause.  This default determination is also forced by  similar  occurrences
  145. of the name of a subtype of the type, or of the name of any type or subtype
  146. that has subcomponents of the type.  A forcing occurrence is any occurrence
  147. other than in a type or subtype declaration, a subprogram specification, an
  148. entry  declaration,  a  deferred  constant  declaration,  a  pragma,  or  a
  149. representation clause for the type itself.   In  any  case,  an  occurrence
  150. within an expression is always forcing.
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                   13 - 2
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204. A  representation  clause  for  a  given  entity  must  not appear after an
  205. occurrence of the name of the entity if this occurrence  forces  a  default
  206. determination of representation for the entity.
  207.  
  208. Similar  restrictions  exist  for  address  clauses.   For  an  object, any
  209. occurrence of  its  name  (after  the  object  declaration)  is  a  forcing
  210. occurrence.  For a subprogram, package, task unit, or entry, any occurrence
  211. of a representation attribute of such an entity is a forcing occurrence.
  212.  
  213. The  effect  of the elaboration of a representation clause is to define the
  214. corresponding aspects of the representation.
  215.  
  216. The interpretation of some of the expressions that appear in representation
  217. clauses is implementation-dependent, for  example,  expressions  specifying
  218. addresses.   An  implementation  may limit its acceptance of representation
  219. clauses to those that can be handled simply by the underlying hardware.  If
  220. a representation clause is accepted by an implementation, the compiler must
  221. guarantee that the net effect of the program is not changed by the presence
  222. of the clause, except for address clauses and for parts of the program that
  223. interrogate  representation  attributes.    If   a   program   contains   a
  224. representation  clause  that  is not accepted, the program is illegal.  For
  225. each  implementation,  the  allowed   representation   clauses,   and   the
  226. conventions   used   for   implementation-dependent  expressions,  must  be
  227. documented in Appendix F of the reference manual.
  228.  
  229. Whereas a representation clause is used to impose  certain  characteristics
  230. of  the  mapping   of an entity onto the underlying machine, pragmas can be
  231. used to provide an implementation with criteria for its selection of such a
  232. mapping.  The pragma PACK specifies that storage minimization should be the
  233. main criterion when selecting the representation of a record or array type.
  234. Its form is as follows:
  235.  
  236.     pragma PACK(type_simple_name);
  237.  
  238. Packing means that gaps between the storage areas allocated to  consecutive
  239. components  should  be minimized.  It need not, however, affect the mapping
  240. of each component onto storage.  This mapping can itself be influenced by a
  241. pragma (or controlled by a representation  clause)  for  the  component  or
  242. component type.  The position of a PACK pragma, and the restrictions on the
  243. named  type, are governed by the same rules as for a representation clause;
  244. in particular, the pragma must appear before any use  of  a  representation
  245. attribute of the packed entity.
  246.  
  247. The  pragma  PACK  is  the  only  language-defined  representation  pragma.
  248. Additional representation pragmas may be  provided  by  an  implementation;
  249. these  must  be  documented  in Appendix F.  (In contrast to representation
  250. clauses, a pragma that is not accepted by the implementation  is  ignored.)
  251.  
  252. Note:
  253.  
  254. No representation clause is allowed for a generic formal type.
  255.  
  256. References:   address  clause  13.5,  allow  1.6,  body 3.9, component 3.3,
  257. declaration 3.1, declarative part 3.9, default expression  3.2.1,  deferred
  258. constant  declaration  7.4,  derivable  subprogram  3.4,  derived type 3.4,
  259.  
  260.  
  261.                                   13 - 3
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270. entity 3.1, entry 9.5, enumeration representation clause  13.3,  expression
  271. 4.4, generic formal type 12.1.2, illegal 1.6, length clause 13.2, must 1.6,
  272. name  4.1,  object  3.2,  occur  immediately within 8.1, package 7, package
  273. specification 7.1, parent  type  3.4,  pragma  2.8,  record  representation
  274. clause  13.4,  representation  attribute  13.7.2  13.7.3, subcomponent 3.3,
  275. subprogram 6, subtype 3.3, subtype declaration  3.3.2,  task  specification
  276. 9.1, task unit 9, type 3.3, type declaration 3.3.1
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                   13 - 4
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. 13.2  Length Clauses
  337.  
  338.  
  339. A length clause specifies an amount of storage associated with a type.
  340.  
  341.     length_clause ::= for attribute use simple_expression;
  342.  
  343. The  expression  must  be  of some numeric type and is evaluated during the
  344. elaboration of the length clause (unless it is a static  expression).   The
  345. prefix of the attribute must denote either a type or a first named subtype.
  346. The  prefix  is  called  T  in  what  follows.   The only allowed attribute
  347. designators in a length clause are  SIZE,  STORAGE_SIZE,  and  SMALL.   The
  348. effect of the length clause depends on the attribute designator:
  349.  
  350.  
  351. (a)  Size specification:  T'SIZE
  352.  
  353.      The  expression must be a static expression of some integer type.  The
  354.      value of the expression specifies an upper bound  for  the  number  of
  355.      bits  to be allocated to objects of the type or first named subtype T.
  356.      The  size  specification  must  allow  for  enough  storage  space  to
  357.      accommodate   every   allowable   value  of  these  objects.   A  size
  358.      specification for a composite type may affect the  size  of  the  gaps
  359.      between the storage areas allocated to consecutive components.  On the
  360.      other  hand, it need not affect the size of the storage area allocated
  361.      to each component.
  362.  
  363.      The size specification is only allowed if the constraints on T and  on
  364.      its   subcomponents   (if   any)  are  static.   In  the  case  of  an
  365.      unconstrained array type, the index subtypes must also be static.
  366.  
  367.  
  368. (b)  Specification of collection size:  T'STORAGE_SIZE
  369.  
  370.      The prefix T must denote an access type.  The expression  must  be  of
  371.      some  integer  type (but need not be static);  its value specifies the
  372.      number of storage units to be reserved for the  collection,  that  is,
  373.      the  storage  space needed to contain all objects designated by values
  374.      of the access type and by values  of  other  types  derived  from  the
  375.      access  type,  directly  or indirectly.  This form of length clause is
  376.      not allowed for a type derived from an access type.
  377.  
  378.  
  379. (c)  Specification of storage for a task activation:  T'STORAGE_SIZE
  380.  
  381.      The prefix T must denote a task type.  The expression must be of  some
  382.      integer type (but need not be static);  its value specifies the number
  383.      of  storage units to be reserved for an activation (not the code) of a
  384.      task of the type.
  385.  
  386.  
  387. (d)  Specification of small for a fixed point type:  T'SMALL
  388.  
  389.      The prefix T must denote the first named  subtype  of  a  fixed  point
  390.      type.   The  expression must be a static expression of some real type;
  391.  
  392.  
  393.                                   13 - 5
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.      its value must not be greater  than  the  delta  of  the  first  named
  403.      subtype.   The  effect  of  the  length clause is to use this value of
  404.      small for the representation of values of the fixed point  base  type.
  405.      (The  length  clause  thereby  also  affects the amount of storage for
  406.      objects that have this type.)
  407.  
  408. Notes:
  409.  
  410. A size specification is allowed for an access, task, or fixed  point  type,
  411. whether or not another form of length clause is also given for the type.
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                   13 - 6
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468. What  is  considered to be part of the storage reserved for a collection or
  469. for an activation of  a  task  is  implementation-dependent.   The  control
  470. afforded  by  length  clauses  is  therefore relative to the implementation
  471. conventions.  For example, the language does not define whether the storage
  472. reserved for an activation of a task includes any storage  needed  for  the
  473. collection  associated  with  an access type declared within the task body.
  474. Neither does it define the method of  allocation  for  objects  denoted  by
  475. values  of  an access type.  For example, the space allocated could be on a
  476. stack;  alternatively,   a  general  dynamic  allocation  scheme  or  fixed
  477. storage could be used.
  478.  
  479. The  objects  allocated  in a collection need not have the same size if the
  480. designated type is an unconstrained array type  or  an  unconstrained  type
  481. with  discriminants.   Note also that the allocator itself may require some
  482. space for internal tables  and  links.   Hence  a  length  clause  for  the
  483. collection  of an access type does not always give precise control over the
  484. maximum number of allocated objects.
  485.  
  486. Examples:
  487.  
  488.     --  assumed declarations:
  489.  
  490.     type MEDIUM is range 0 .. 65000;
  491.     type SHORT  is delta 0.01 range -100.0 .. 100.0;
  492.     type DEGREE is delta 0.1  range -360.0 .. 360.0;
  493.  
  494.     BYTE : constant := 8;
  495.     PAGE : constant := 2000;
  496.  
  497.     --  length clauses:
  498.  
  499.     for COLOR'SIZE  use 1*BYTE;  --  see 3.5.1
  500.     for MEDIUM'SIZE use 2*BYTE;
  501.     for SHORT'SIZE  use 15;
  502.  
  503.     for CAR_NAME'STORAGE_SIZE use  --  approximately 2000 cars
  504.                 2000*((CAR'SIZE/SYSTEM.STORAGE_UNIT) + 1);
  505.  
  506.     for KEYBOARD_DRIVER'STORAGE_SIZE use 1*PAGE;
  507.  
  508.     for DEGREE'SMALL use 360.0/2**(SYSTEM.STORAGE_UNIT - 1);
  509.  
  510. Notes on the examples:
  511.  
  512. In the length clause for SHORT, fifteen  bits  is  the  minimum  necessary,
  513. since   the   type   definition   requires   SHORT'SMALL  =  2.0**(-7)  and
  514. SHORT'MANTISSA = 14.  The length clause for DEGREE forces the model numbers
  515. to exactly span the range of the type.
  516.  
  517. References:  access type 3.8, allocator 4.8, allow  1.6,  array  type  3.6,
  518. attribute  4.1.4, collection 3.8, composite type 3.3, constraint 3.3, delta
  519. of a fixed point type 3.5.9, derived type 3.4, designate  3.8,  elaboration
  520. 3.9,  entity 3.1, evaluation 4.5, expression 4.4, first named subtype 13.1,
  521. fixed point type 3.5.9, index subtype 3.6, integer type  3.5.4,  must  1.6,
  522. numeric  type 3.5, object 3.2, real type 3.5.6, record type 3.7, small of a
  523.  
  524.  
  525.                                   13 - 7
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534. fixed point type 3.5.10, static  constraint  4.9,  static  expression  4.9,
  535. static  subtype  4.9,  storage  unit 13.7, subcomponent 3.3, system package
  536. 13.7, task 9, task activation 9.3, task specification 9.1, task  type  9.2,
  537. type 3.3, unconstrained array type 3.6
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.                                   13 - 8
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600. 13.3  Enumeration Representation Clauses
  601.  
  602.  
  603. An  enumeration  representation clause specifies the internal codes for the
  604. literals of the enumeration type that is named in the clause.
  605.  
  606.     enumeration_representation_clause ::= for type_simple_name use aggregate;
  607.  
  608. The aggregate used to specify this mapping is written as a  one-dimensional
  609. aggregate,  for  which  the  index  subtype is the enumeration type and the
  610. component type is universal_integer.
  611.  
  612. All literals of the enumeration type must be provided with distinct integer
  613. codes, and all choices and component values given in the aggregate must  be
  614. static.   The integer codes specified for the enumeration type must satisfy
  615. the predefined ordering relation of the type.
  616.  
  617. Example:
  618.  
  619.     type MIX_CODE is (ADD, SUB, MUL, LDA, STA, STZ);
  620.  
  621.     for MIX_CODE use
  622.        (ADD => 1, SUB => 2, MUL => 3, LDA => 8, STA => 24, STZ => 33);
  623.  
  624.  
  625. Notes:
  626.  
  627. The attributes SUCC, PRED, and POS are defined even for  enumeration  types
  628. with  a  noncontiguous representation;  their definition corresponds to the
  629. (logical)  type  declaration  and  is  not  affected  by  the   enumeration
  630. representation  clause.   In  the example, because of the need to avoid the
  631. omitted  values,  these  functions  are  likely  to  be  less   efficiently
  632. implemented  than  they could be in the absence of a representation clause.
  633. Similar considerations apply when such types are used for indexing.
  634.  
  635.  
  636. References:   aggregate  4.3,  array  aggregate  4.3.2,  array  type   3.6,
  637. attribute  of  an  enumeration  type  3.5.5,  choice  3.7.3, component 3.3,
  638. enumeration literal 3.5.1, enumeration type 3.5.1, function 6.5, index 3.6,
  639. index subtype 3.6, literal 4.2, ordering relation of  an  enumeration  type
  640. 3.5.1,  representation clause 13.1, simple name 4.1, static expression 4.9,
  641. type 3.3, type declaration 3.3.1, universal_integer type 3.5.4
  642.  
  643.  
  644.  
  645. 13.4  Record Representation Clauses
  646.  
  647.  
  648. A record representation clause  specifies  the  storage  representation  of
  649. records,  that  is,  the  order,  position,  and  size of record components
  650. (including discriminants, if any).
  651.  
  652.     record_representation_clause ::=
  653.        for type_simple_name use
  654.           record [alignment_clause]
  655.  
  656.  
  657.                                   13 - 9
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.              {component_clause}
  667.           end record;
  668.  
  669.     alignment_clause ::= at mod static_simple_expression;
  670.  
  671.     component_clause ::=
  672.        component_name at static_simple_expression range static_range;
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.                                   13 - 10
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732. The simple expression given after the reserved words at mod in an alignment
  733. clause, or after the reserved word at in a  component  clause,  must  be  a
  734. static  expression  of  some integer type.  If the bounds of the range of a
  735. component clause are defined by simple expressions, then each bound of  the
  736. range  must be defined by a static expression of some integer type, but the
  737. two bounds need not have the same integer type.
  738.  
  739. An alignment clause forces each record of the given type to be allocated at
  740. a starting address that is a multiple of the value of the given  expression
  741. (that   is,   the   address  modulo  the  expression  must  be  zero).   An
  742. implementation may place restrictions on the allowable alignments.
  743.  
  744. A component clause specifies the storage place of a component, relative  to
  745. the start of the record.  The integer defined by the static expression of a
  746. component  clause  is  a  relative address expressed in storage units.  The
  747. range defines the bit positions of  the  storage  place,  relative  to  the
  748. storage  unit.   The  first storage unit of a record is numbered zero.  The
  749. first bit of a storage unit is numbered zero.  The ordering of  bits  in  a
  750. storage unit is machine-dependent and may extend to adjacent storage units.
  751. (For a specific machine, the size in bits of a storage unit is given by the
  752. configuration-dependent   named  number  SYSTEM.STORAGE_UNIT.)   Whether  a
  753. component is allowed to overlap a storage boundary,  and  if  so,  how,  is
  754. implementation-defined.
  755.  
  756. At  most  one  component clause is allowed for each component of the record
  757. type, including for each discriminant (component clauses may be  given  for
  758. some, all, or none of the components).  If no component clause is given for
  759. a component, then the choice of the storage place for the component is left
  760. to  the  compiler.   If component clauses are given for all components, the
  761. record representation clause completely specifies the representation of the
  762. record type and must be obeyed exactly by the compiler.
  763.  
  764. Storage places within a record variant must not overlap, but overlap of the
  765. storage for distinct variants is allowed.  Each component clause must allow
  766. for enough storage space  to  accommodate  every  allowable  value  of  the
  767. component.   A  component  clause  is  only  allowed for a component if any
  768. constraint on this component or on any of its subcomponents is static.
  769.  
  770. An implementation may generate names that  denote  implementation-dependent
  771. components  (for  example, one containing the offset of another component).
  772. Such implementation-dependent names can be used  in  record  representation
  773. clauses  (these names need not be simple names;  for example, they could be
  774. implementation-dependent attributes).
  775.  
  776.  
  777. Example:
  778.  
  779.     WORD : constant := 4;  --  storage unit is byte, 4 bytes per word
  780.  
  781.     type STATE      is (A, M, W, P);
  782.     type MODE       is (FIX, DEC, EXP, SIGNIF);
  783.  
  784.     type BYTE_MASK  is array (0 .. 7) of BOOLEAN;
  785.     type STATE_MASK is array (STATE)  of BOOLEAN;
  786.     type MODE_MASK  is array (MODE)   of BOOLEAN;
  787.  
  788.  
  789.                                   13 - 11
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.     type PROGRAM_STATUS_WORD is
  799.        record
  800.           SYSTEM_MASK     : BYTE_MASK;
  801.           PROTECTION_KEY  : INTEGER range 0 .. 3;
  802.           MACHINE_STATE   : STATE_MASK;
  803.           INTERRUPT_CAUSE : INTERRUPTION_CODE;
  804.           ILC             : INTEGER range 0 .. 3;
  805.           CC              : INTEGER range 0 .. 3;
  806.           PROGRAM_MASK    : MODE_MASK;
  807.           INST_ADDRESS    : ADDRESS;
  808.        end record;
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.                                   13 - 12
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.     for PROGRAM_STATUS_WORD use
  865.        record at mod 8;
  866.           SYSTEM_MASK     at 0*WORD range 0  .. 7;
  867.           PROTECTION_KEY  at 0*WORD range 10 .. 11;  --  bits 8, 9 unused
  868.           MACHINE_STATE   at 0*WORD range 12 .. 15;
  869.           INTERRUPT_CAUSE at 0*WORD range 16 .. 31;
  870.           ILC             at 1*WORD range 0  .. 1;   --  second word
  871.           CC              at 1*WORD range 2  .. 3;
  872.           PROGRAM_MASK    at 1*WORD range 4  .. 7;
  873.           INST_ADDRESS    at 1*WORD range 8  .. 31;
  874.        end record;
  875.  
  876.     for PROGRAM_STATUS_WORD'SIZE use 8*SYSTEM.STORAGE_UNIT;
  877.  
  878. Note on the example:
  879.  
  880. The record representation clause defines the  record  layout.   The  length
  881. clause guarantees that exactly eight storage units are used.
  882.  
  883. References:   allow  1.6,  attribute 4.1.4, constant 3.2.1, constraint 3.3,
  884. discriminant 3.7.1, integer type 3.5.4, must 1.6, named number  3.2,  range
  885. 3.5,  record  component 3.7, record type 3.7, simple expression 4.4, simple
  886. name 4.1, static constraint 4.9, static expression 4.9, storage unit  13.7,
  887. subcomponent 3.3, system package 13.7, variant 3.7.3
  888.  
  889.  
  890.  
  891.  
  892. 13.5  Address Clauses
  893.  
  894.  
  895. An address clause specifies a required address in storage for an entity.
  896.  
  897.     address_clause ::= for simple_name use at simple_expression;
  898.  
  899. The expression given after the reserved word at must be of the type ADDRESS
  900. defined  in the package SYSTEM (see 13.7);  this package must be named by a
  901. with clause that applies to the  compilation  unit  in  which  the  address
  902. clause  occurs.   The conventions that define the interpretation of a value
  903. of the type ADDRESS as an address, as an interrupt level,  or  whatever  it
  904. may  be,  are  implementation-dependent.   The allowed nature of the simple
  905. name and the meaning of the corresponding address are as follows:
  906.  
  907. (a)  Name of an object:  the  address  is  that  required  for  the  object
  908.      (variable or constant).
  909.  
  910. (b)  Name of a subprogram, package, or task  unit:   the  address  is  that
  911.      required  for the machine code associated with the body of the program
  912.      unit.
  913.  
  914. (c)  Name of a single entry:  the address specifies a hardware interrupt to
  915.      which the single entry is to be linked.
  916.  
  917. If the simple name is  that  of  a  single  task,  the  address  clause  is
  918. understood  to  refer  to the task unit and not to the task object.  In all
  919.  
  920.  
  921.                                   13 - 13
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930. cases, the address clause is only legal if  exactly  one  declaration  with
  931. this  identifier  occurs  earlier,  immediately within the same declarative
  932. part, package specification, or task specification.  A name declared  by  a
  933. renaming declaration is not allowed as the simple name.
  934.  
  935. Address  clauses  should  not  be  used  to  achieve overlays of objects or
  936. overlays of program units.  Nor should a given interrupt be linked to  more
  937. than  one entry.  Any program using address clauses to achieve such effects
  938. is erroneous.
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.                                   13 - 14
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996. Example:
  997.  
  998.  
  999.     for CONTROL use at 16#0020#;  --  assuming that SYSTEM.ADDRESS is an integer type
  1000.  
  1001. Notes:
  1002.  
  1003. The above rules imply that if two subprograms overload each other  and  are
  1004. visible at a given point, an address clause for any of them is not legal at
  1005. this  point.   Similarly  if  a  task  specification  declares entries that
  1006. overload each other, they cannot be interrupt entries.  The syntax does not
  1007. allow an address clause for a library unit.  An implementation may  provide
  1008. pragmas for the specification of program overlays.
  1009.  
  1010.  
  1011. References:   address  predefined type 13.7, apply 10.1.1, compilation unit
  1012. 10.1, constant 3.2.1, entity 3.1, entry 9.5, erroneous 1.6, expression 4.4,
  1013. library unit 10.1, name 4.1, object 3.2, package  7,  pragma  2.8,  program
  1014. unit  6,  reserved  word  2.9,  simple  expression  4.4,  simple  name 4.1,
  1015. subprogram 6, subprogram body 6.3, system package 13.7, task body 9.1, task
  1016. object 9.2, task unit 9, type 3.3, variable 3.2.1, with clause 10.1.1
  1017.  
  1018.  
  1019.  
  1020.  
  1021. 13.5.1  Interrupts
  1022.  
  1023.  
  1024. An address clause given for an entry associates the entry with some  device
  1025. that  may cause an interrupt;  such an entry is referred to in this section
  1026. as an  interrupt  entry.   If  control  information  is  supplied  upon  an
  1027. interrupt,  it  is  passed  to an associated interrupt entry as one or more
  1028. parameters of mode in;  only parameters of this mode are allowed.
  1029.  
  1030. An interrupt acts as an entry call issued by a hardware task whose priority
  1031. is higher than the priority of the main program, and also higher  than  the
  1032. priority of any user-defined task (that is, any task whose type is declared
  1033. by  a  task  unit in the program).  The entry call may be an ordinary entry
  1034. call, a timed entry call, or a conditional entry  call,  depending  on  the
  1035. kind of interrupt and on the implementation.
  1036.  
  1037. If  a  select statement contains both a terminate alternative and an accept
  1038. alternative for an interrupt  entry,  then  an  implementation  may  impose
  1039. further  requirements  for  the  selection  of the terminate alternative in
  1040. addition to those given in section 9.4.
  1041.  
  1042. Example:
  1043.  
  1044.     task INTERRUPT_HANDLER is
  1045.        entry DONE;
  1046.        for DONE use at 16#40#;  --  assuming that SYSTEM.ADDRESS is an integer type
  1047.     end INTERRUPT_HANDLER;
  1048.  
  1049. Notes:
  1050.  
  1051.  
  1052.  
  1053.                                   13 - 15
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062. Interrupt entry calls need only have the semantics described  above;   they
  1063. may  be implemented by having the hardware directly execute the appropriate
  1064. accept statements.
  1065.  
  1066. Queued interrupts correspond to ordinary entry calls.  Interrupts that  are
  1067. lost  if  not  immediately processed correspond to conditional entry calls.
  1068. It is a consequence of the priority rules that an accept statement executed
  1069. in response to an interrupt takes precedence  over  ordinary,  user-defined
  1070. tasks, and can be executed without first invoking a scheduling action.
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.                                   13 - 16
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128. One  of the possible effects of an address clause for an interrupt entry is
  1129. to specify the priority of the interrupt (directly or indirectly).   Direct
  1130. calls to an interrupt entry are allowed.
  1131.  
  1132. References:   accept  alternative  9.7.1,  accept  statement  9.5,  address
  1133. predefined type 13.7, allow 1.6, conditional entry call 9.7.2,  entry  9.5,
  1134. entry call 9.5, mode 6.1, parameter of a subprogram 6.2, priority of a task
  1135. 9.8,  select  alternative 9.7.1, select statement 9.7, system package 13.7,
  1136. task 9, terminate alternative 9.7.1, timed entry call 9.7.3
  1137.  
  1138.  
  1139.  
  1140.  
  1141. 13.6  Change of Representation
  1142.  
  1143.  
  1144. At most one representation clause is allowed for a given type and  a  given
  1145. aspect  of  its representation.  Hence, if an alternative representation is
  1146. needed, it is necessary to declare a second type, derived from  the  first,
  1147. and to specify a different representation for the second type.
  1148.  
  1149. Example:
  1150.  
  1151.     --  PACKED_DESCRIPTOR and DESCRIPTOR are two different types
  1152.     --  with identical characteristics, apart from their representation
  1153.  
  1154.     type DESCRIPTOR is
  1155.        record
  1156.           --  components of a descriptor
  1157.        end record;
  1158.  
  1159.     type PACKED_DESCRIPTOR is new DESCRIPTOR;
  1160.  
  1161.     for PACKED_DESCRIPTOR use
  1162.        record
  1163.           --  component clauses for some or for all components
  1164.        end record;
  1165.  
  1166. Change  of  representation  can  now  be  accomplished  by  assignment with
  1167. explicit type conversions:
  1168.  
  1169.     D : DESCRIPTOR;
  1170.     P : PACKED_DESCRIPTOR;
  1171.  
  1172.     P := PACKED_DESCRIPTOR(D);  --  pack D
  1173.     D := DESCRIPTOR(P);         --  unpack P
  1174.  
  1175.  
  1176. References:  assignment 5.2, derived type 3.4, type  3.3,  type  conversion
  1177. 4.6, type declaration 3.1, representation clause 13.1
  1178.  
  1179.  
  1180.  
  1181. 13.7  The Package System
  1182.  
  1183.  
  1184.  
  1185.                                   13 - 17
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194. For each implementation there is a predefined library package called SYSTEM
  1195. which   includes   the   definitions   of  certain  configuration-dependent
  1196. characteristics.    The   specification   of   the   package   SYSTEM    is
  1197. implementation-dependent and must be given in Appendix F.  The visible part
  1198. of this package must contain at least the following declarations.
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.                                   13 - 18
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.     package SYSTEM is
  1261.        type ADDRESS is implementation_defined;
  1262.        type NAME    is implementation_defined_enumeration_type;
  1263.  
  1264.        SYSTEM_NAME  : constant NAME := implementation_defined;
  1265.  
  1266.        STORAGE_UNIT : constant := implementation_defined;
  1267.        MEMORY_SIZE  : constant := implementation_defined;
  1268.  
  1269.        --  System-Dependent Named Numbers:
  1270.  
  1271.        MIN_INT      : constant := implementation_defined;
  1272.        MAX_INT      : constant := implementation_defined;
  1273.        MAX_DIGITS   : constant := implementation_defined;
  1274.        MAX_MANTISSA : constant := implementation_defined;
  1275.        FINE_DELTA   : constant := implementation_defined;
  1276.        TICK         : constant := implementation_defined;
  1277.  
  1278.        --  Other System-Dependent Declarations
  1279.  
  1280.        subtype PRIORITY is INTEGER range implementation_defined;
  1281.  
  1282.        ...
  1283.     end SYSTEM;
  1284.  
  1285. The  type ADDRESS is the type of the addresses provided in address clauses;
  1286. it is also the type of the  result  delivered  by  the  attribute  ADDRESS.
  1287. Values  of  the  enumeration type NAME are the names of alternative machine
  1288. configurations handled by the implementation;  one of these is the constant
  1289. SYSTEM_NAME.  The named number STORAGE_UNIT  is  the  number  of  bits  per
  1290. storage  unit;   the  named  number  MEMORY_SIZE is the number of available
  1291. storage units in the configuration;  these named numbers are  of  the  type
  1292. universal_integer.
  1293.  
  1294. An  alternative  form  of  the package SYSTEM, with given values for any of
  1295. SYSTEM_NAME, STORAGE_UNIT, and MEMORY_SIZE, can be obtained by means of the
  1296. corresponding pragmas.  These pragmas are only allowed at the  start  of  a
  1297. compilation, before the first compilation unit (if any) of the compilation.
  1298.  
  1299.     pragma SYSTEM_NAME(enumeration_literal);
  1300.  
  1301. The  effect  of the above pragma is to use the enumeration literal with the
  1302. specified identifier for the definition of the constant SYSTEM_NAME.   This
  1303. pragma  is  only  allowed if the specified identifier corresponds to one of
  1304. the literals of the type NAME.
  1305.  
  1306.     pragma STORAGE_UNIT(numeric_literal);
  1307.  
  1308. The effect of the above pragma is to use the value of the specified numeric
  1309. literal for the definition of the named number STORAGE_UNIT.
  1310.  
  1311.     pragma MEMORY_SIZE(numeric_literal);
  1312.  
  1313. The effect of the above pragma is to use the value of the specified numeric
  1314. literal for the definition of the named number MEMORY_SIZE.
  1315.  
  1316.  
  1317.                                   13 - 19
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326. The compilation of any of these pragmas causes an implicit recompilation of
  1327. the package SYSTEM.  Consequently any compilation unit that names SYSTEM in
  1328. its context clause becomes obsolete after this implicit recompilation.   An
  1329. implementation  may impose further limitations on the use of these pragmas.
  1330. For example, an implementation may allow them only  at  the  start  of  the
  1331. first compilation, when creating a new program library.
  1332.  
  1333. Note:
  1334.  
  1335. It is a consequence of the visibility rules that a declaration given in the
  1336. package  SYSTEM is not visible in a compilation unit unless this package is
  1337. mentioned by a with clause that applies (directly  or  indirectly)  to  the
  1338. compilation unit.
  1339.  
  1340.  
  1341.  
  1342. References:    address   clause   13.5,   apply  10.1.1,  attribute  4.1.4,
  1343. compilation  unit  10.1,  declaration  3.1,  enumeration   literal   3.5.1,
  1344. enumeration  type 3.5.1, identifier 2.3, library unit 10.1, must 1.6, named
  1345. number 3.2, number declaration  3.2.2,  numeric  literal  2.4,  package  7,
  1346. package  specification  7.1,  pragma  2.8,  program library 10.1, type 3.3,
  1347. visibility 8.3, visible part 7.2, with clause 10.1.1
  1348.  
  1349.  
  1350.  
  1351.  
  1352. 13.7.1  System-Dependent Named Numbers
  1353.  
  1354.  
  1355. Within the package SYSTEM, the following named numbers are  declared.   The
  1356. numbers FINE_DELTA and TICK are of the type universal_real;  the others are
  1357. of the type universal_integer.
  1358.  
  1359. MIN_INT       The smallest (most negative) value of all predefined  integer
  1360.               types.
  1361.  
  1362. MAX_INT       The largest (most positive) value of all  predefined  integer
  1363.               types.
  1364.  
  1365. MAX_DIGITS    The largest value  allowed  for  the  number  of  significant
  1366.               decimal digits in a floating point constraint.
  1367.  
  1368. MAX_MANTISSA  The largest possible number of binary digits in the  mantissa
  1369.               of model numbers of a fixed point subtype.
  1370.  
  1371. FINE_DELTA    The smallest delta allowed in a fixed point  constraint  that
  1372.               has the range constraint -1.0 .. 1.0.
  1373.  
  1374. TICK          The basic clock period, in seconds.
  1375.  
  1376.  
  1377.  
  1378. References:   allow  1.6,  delta  of  a fixed point constraint 3.5.9, fixed
  1379. point constraint 3.5.9,  floating  point  constraint  3.5.7,  integer  type
  1380. 3.5.4,  model  number  3.5.6, named number 3.2, package 7, range constraint
  1381.  
  1382.  
  1383.                                   13 - 20
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392. 3.5,  system  package  13.7,  type  3.3,  universal_integer   type   3.5.4,
  1393. universal_real type 3.5.6
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.                                   13 - 21
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458. 13.7.2  Representation Attributes
  1459.  
  1460.  
  1461. The  values  of  certain  implementation-dependent  characteristics  can be
  1462. obtained by interrogating  appropriate  representation  attributes.   These
  1463. attributes are described below.
  1464.  
  1465. For any object, program unit, label, or entry X:
  1466.  
  1467. X'ADDRESS       Yields the address  of  the  first  of  the  storage  units
  1468.                 allocated  to  X.   For a subprogram, package, task unit or
  1469.                 label, this value refers to  the  machine  code  associated
  1470.                 with the corresponding body or statement.  For an entry for
  1471.                 which an address clause has been given, the value refers to
  1472.                 the  corresponding  hardware  interrupt.  The value of this
  1473.                 attribute is of the type ADDRESS  defined  in  the  package
  1474.                 SYSTEM.
  1475.  
  1476. For any type or subtype X, or for any object X:
  1477.  
  1478. X'SIZE          Applied to an object, yields the number of  bits  allocated
  1479.                 to  hold  the object.  Applied to a type or subtype, yields
  1480.                 the  minimum  number  of  bits  that  is  needed   by   the
  1481.                 implementation  to hold any possible object of this type or
  1482.                 subtype.  The value  of  this  attribute  is  of  the  type
  1483.                 universal_integer.
  1484.  
  1485. For the above two representation attributes, if the prefix is the name of a
  1486. function,  the  attribute  is understood to be an attribute of the function
  1487. (not of the result of calling the function).  Similarly, if the type of the
  1488. prefix is an access type, the attribute is understood to be an attribute of
  1489. the prefix (not of the designated object:  attributes of the latter can  be
  1490. written with a prefix ending with the reserved word all).
  1491.  
  1492. For any component C of a record object R:
  1493.  
  1494. R.C'POSITION    Yields the offset, from the start of the first storage unit
  1495.                 occupied  by  the record, of the first of the storage units
  1496.                 occupied by C.  This offset is measured in  storage  units.
  1497.                 The    value   of   this   attribute   is   of   the   type
  1498.                 universal_integer.
  1499.  
  1500. R.C'FIRST_BIT   Yields the offset, from the  start  of  the  first  of  the
  1501.                 storage  units  occupied by C, of the first bit occupied by
  1502.                 C.  This offset is measured in bits.   The  value  of  this
  1503.                 attribute is of the type universal_integer.
  1504.  
  1505. R.C'LAST_BIT    Yields the offset, from the  start  of  the  first  of  the
  1506.                 storage units occupied by C, of the last bit occupied by C.
  1507.                 This  offset  is  measured  in  bits.   The  value  of this
  1508.                 attribute is of the type universal_integer.
  1509.  
  1510. For any access type or subtype T:
  1511.  
  1512.  
  1513.  
  1514.  
  1515.                                   13 - 22
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524. T'STORAGE_SIZE  Yields the total number of storage units reserved  for  the
  1525.                 collection  associated  with the base type of T.  The value
  1526.                 of this attribute is of the type universal_integer.
  1527.  
  1528. For any task type or task object T:
  1529.  
  1530. T'STORAGE_SIZE  Yields the  number  of  storage  units  reserved  for  each
  1531.                 activation of a task of the type T or for the activation of
  1532.                 the  task  object T.  The value of this attribute is of the
  1533.                 type universal_integer.
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.                                   13 - 23
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590. Notes:
  1591.  
  1592. For a task object X, the attribute X'SIZE gives the number of bits used  to
  1593. hold the object X, whereas X'STORAGE_SIZE gives the number of storage units
  1594. allocated  for  the  activation  of the task designated by X.  For a formal
  1595. parameter X, if parameter passing is achieved by copy, then  the  attribute
  1596. X'ADDRESS yields the address of the local copy;  if parameter passing is by
  1597. reference, then the address is that of the actual parameter.
  1598.  
  1599. References:   access  subtype  3.8, access type 3.8, activation 9.3, actual
  1600. parameter 6.2, address clause 13.5, address predefined type 13.7, attribute
  1601. 4.1.4, base type 3.3, collection 3.8,  component  3.3,  entry  9.5,  formal
  1602. parameter  6.1  6.2,  label  5.1,  object 3.2, package 7, package body 7.1,
  1603. parameter passing 6.2, program unit 6,  record  object  3.7,  statement  5,
  1604. storage  unit  13.7, subprogram 6, subprogram body 6.3, subtype 3.3, system
  1605. predefined package 13.7, task 9, task body 9.1, task object 9.2, task  type
  1606. 9.2, task unit 9, type 3.3, universal_integer type 3.5.4
  1607.  
  1608.  
  1609.  
  1610.  
  1611. 13.7.3  Representation Attributes of Real Types
  1612.  
  1613.  
  1614. For   every  real  type  or  subtype  T,  the  following  machine-dependent
  1615. attributes are defined,  which  are  not  related  to  the  model  numbers.
  1616. Programs  using  these  attributes  may  thereby exploit properties that go
  1617. beyond the minimal properties associated with the numeric type (see section
  1618. 4.5.7  for  the  rules  defining  the  accuracy  of  operations  with  real
  1619. operands).    Precautions   must   therefore  be  taken  when  using  these
  1620. machine-dependent attributes if portability is to be ensured.
  1621.  
  1622. For both floating point and fixed point types:
  1623.  
  1624. T'MACHINE_ROUNDS       Yields the value TRUE if every predefined arithmetic
  1625.                        operation on values of the base  type  of  T  either
  1626.                        returns   an  exact  result  or  performs  rounding;
  1627.                        yields the value FALSE otherwise.  The value of this
  1628.                        attribute is of the predefined type BOOLEAN.
  1629.  
  1630. T'MACHINE_OVERFLOWS    Yields the value TRUE if every predefined  operation
  1631.                        on  values  of  the base type of T either provides a
  1632.                        correct   result,   or    raises    the    exception
  1633.                        NUMERIC_ERROR  in  overflow  situations (see 4.5.7);
  1634.                        yields the value FALSE otherwise.  The value of this
  1635.                        attribute is of the predefined type BOOLEAN.
  1636.  
  1637. For floating point types, the following attributes provide  characteristics
  1638. of  the  underlying  machine representation, in terms of the canonical form
  1639. defined in section 3.5.7:
  1640.  
  1641. T'MACHINE_RADIX        Yields the value of the radix used  by  the  machine
  1642.                        representation  of the base type of T.  The value of
  1643.                        this attribute is of the type universal_integer.
  1644.  
  1645.  
  1646.  
  1647.                                   13 - 24
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656. T'MACHINE_MANTISSA     Yields the number of digits in the mantissa for  the
  1657.                        machine  representation  of  the base type of T (the
  1658.                        digits  are  extended  digits  in  the  range  0  to
  1659.                        T'MACHINE_RADIX -1).  The value of this attribute is
  1660.                        of the type universal_integer.
  1661.  
  1662. T'MACHINE_EMAX         Yields the largest value of exponent for the machine
  1663.                        representation  of the base type of T.  The value of
  1664.                        this attribute is of the type universal_integer.
  1665.  
  1666. T'MACHINE_EMIN         Yields  the  smallest  (most  negative)   value   of
  1667.                        exponent  for the machine representation of the base
  1668.                        type of T.  The value of this attribute  is  of  the
  1669.                        type universal_integer.
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.                                   13 - 25
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722. Note:
  1723.  
  1724. For  many  machines  the  largest machine representable number of type F is
  1725. almost
  1726.  
  1727.     (F'MACHINE_RADIX)**(F'MACHINE_EMAX),
  1728.  
  1729. and the smallest positive representable number is
  1730.  
  1731.     F'MACHINE_RADIX ** (F'MACHINE_EMIN - 1)
  1732.  
  1733.  
  1734. References:  arithmetic operator  4.5,  attribute  4.1.4,  base  type  3.3,
  1735. boolean  predefined type 3.5.3, false boolean value 3.5.3, fixed point type
  1736. 3.5.9, floating point type 3.5.7, model number  3.5.6,  numeric  type  3.5,
  1737. numeric_error exception 11.1, predefined operation 3.3.3, radix 3.5.7, real
  1738. type   3.5.6,   subtype   3.3,   true   boolean   value  3.5.3,  type  3.3,
  1739. universal_integer type 3.5.4
  1740.  
  1741.  
  1742.  
  1743.  
  1744. 13.8  Machine Code Insertions
  1745.  
  1746.  
  1747. A machine code insertion can be achieved by a call  to  a  procedure  whose
  1748. sequence of statements contains code statements.
  1749.  
  1750.     code_statement ::= type_mark'record_aggregate;
  1751.  
  1752. A  code  statement  is  only  allowed  in  the  sequence of statements of a
  1753. procedure body.  If a procedure body contains code statements, then  within
  1754. this  procedure body the only allowed form of statement is a code statement
  1755. (labeled or not), the only allowed declarative items are use  clauses,  and
  1756. no  exception  handler  is  allowed  (comments  and  pragmas are allowed as
  1757. usual).
  1758.  
  1759. Each machine instruction appears as a record aggregate  of  a  record  type
  1760. that defines the corresponding instruction.  The base type of the type mark
  1761. of  a code statement must be declared within the predefined library package
  1762. called MACHINE_CODE;  this package must be named  by  a  with  clause  that
  1763. applies  to  the  compilation  unit in which the code statement occurs.  An
  1764. implementation is not required to provide such a package.
  1765.  
  1766. An implementation is allowed to impose further restrictions on  the  record
  1767. aggregates  allowed  in  code statements.  For example, it may require that
  1768. expressions contained in such aggregates be static expressions.
  1769.  
  1770. An implementation may provide machine-dependent pragmas specifying register
  1771. conventions and calling conventions.  Such pragmas must  be  documented  in
  1772. Appendix F.
  1773.  
  1774. Example:
  1775.  
  1776.  
  1777.  
  1778.  
  1779.                                   13 - 26
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.     M : MASK;
  1789.     procedure SET_MASK; pragma INLINE(SET_MASK);
  1790.  
  1791.     procedure SET_MASK is
  1792.        use MACHINE_CODE;
  1793.     begin
  1794.        SI_FORMAT'(CODE => SSM, B => M'BASE_REG, D => M'DISP);
  1795.        --  M'BASE_REG and M'DISP are implementation-specific predefined attributes
  1796.     end;
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.                                   13 - 27
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854. References:   allow  1.6, apply 10.1.1, comment 2.7, compilation unit 10.1,
  1855. declarative item 3.9, exception handler 11.2, inline pragma 6.3.2,  labeled
  1856. statement  5.1,  library unit 10.1, package 7, pragma 2.8, procedure 6 6.1,
  1857. procedure body 6.3, record aggregate 4.3.1, record type  3.7,  sequence  of
  1858. statements  5.1,  statement  5, static expression 4.9, use clause 8.4, with
  1859. clause 10.1.1
  1860.  
  1861.  
  1862.  
  1863.  
  1864. 13.9  Interface to Other Languages
  1865.  
  1866.  
  1867. A subprogram written in another language can be called from an Ada  program
  1868. provided  that  all  communication  is achieved via parameters and function
  1869. results.  A pragma of the form
  1870.  
  1871.     pragma INTERFACE (language_name, subprogram_name);
  1872.  
  1873. must be given for each such subprogram; a subprogram  name  is  allowed  to
  1874. stand  for  several  overloaded subprograms.  This pragma is allowed at the
  1875. place of a declarative item, and must apply in this case  to  a  subprogram
  1876. declared  by  an  earlier  declarative item of the same declarative part or
  1877. package specification.  The pragma is also allowed for a library unit;   in
  1878. this  case  the  pragma  must appear  after the subprogram declaration, and
  1879. before any subsequent compilation unit.  The  pragma  specifies  the  other
  1880. language  (and  thereby  the  calling conventions) and informs the compiler
  1881. that an object module will be supplied for the corresponding subprogram.  A
  1882. body is not allowed for such a subprogram (not even in the form of  a  body
  1883. stub)  since  the  instructions  of  the  subprogram are written in another
  1884. language.
  1885.  
  1886. This  capability  need  not  be  provided  by  all  implementations.     An
  1887. implementation  may place restrictions on the allowable forms and places of
  1888. parameters and calls.
  1889.  
  1890.  
  1891. Example:
  1892.  
  1893.     package FORT_LIB is
  1894.        function SQRT(X : FLOAT) return FLOAT;
  1895.        function EXP (X : FLOAT) return FLOAT;
  1896.     private
  1897.        pragma INTERFACE(FORTRAN, SQRT);
  1898.        pragma INTERFACE(FORTRAN, EXP);
  1899.     end FORT_LIB;
  1900.  
  1901. Notes:
  1902.  
  1903. The conventions used by other language processors that  call  Ada  programs
  1904. are  not  part  of  the  Ada language definition.  Such conventions must be
  1905. defined by these other language processors.
  1906.  
  1907. The pragma INTERFACE is not defined for generic subprograms.
  1908.  
  1909.  
  1910.  
  1911.                                   13 - 28
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921. References:  allow 1.6, body stub 10.2, compilation unit 10.1,  declaration
  1922. 3.1,  declarative  item  3.9,  declarative  part  3.9, function result 6.5,
  1923. library unit 10.1, must 1.6, name 4.1, overloaded subprogram  6.6,  package
  1924. specification 7.1, parameter of a subprogram 6.2, pragma 2.8, subprogram 6,
  1925. subprogram body 6.3, subprogram call 6.4, subprogram declaration 6.1
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.                                   13 - 29
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986. 13.10  Unchecked Programming
  1987.  
  1988.  
  1989. The  predefined  generic  library  subprograms  UNCHECKED_DEALLOCATION  and
  1990. UNCHECKED_CONVERSION are used for unchecked storage  deallocation  and  for
  1991. unchecked type conversions.
  1992.  
  1993.     generic
  1994.        type OBJECT is limited private;
  1995.        type NAME   is access OBJECT;
  1996.     procedure UNCHECKED_DEALLOCATION(X : in out NAME);
  1997.  
  1998.     generic
  1999.        type SOURCE is limited private;
  2000.        type TARGET is limited private;
  2001.     function UNCHECKED_CONVERSION(S : SOURCE) return TARGET;
  2002.  
  2003.  
  2004. References:  generic subprogram 12.1, library unit 10.1, type 3.3
  2005.  
  2006.  
  2007.  
  2008. 13.10.1  Unchecked Storage Deallocation
  2009.  
  2010.  
  2011. Unchecked  storage  deallocation  of  an object designated by a value of an
  2012. access type is achieved by a call  of  a  procedure  that  is  obtained  by
  2013. instantiation   of   the  generic  procedure  UNCHECKED_DEALLOCATION.   For
  2014. example:
  2015.  
  2016.     procedure FREE is new UNCHECKED_DEALLOCATION(object_type_name, access_type_name);
  2017.  
  2018.  
  2019. Such a FREE procedure has the following effect:
  2020.  
  2021. (a)  after executing FREE(X), the value of X is null;
  2022.  
  2023. (b)  FREE(X), when X is already equal to null, has no effect;
  2024.  
  2025. (c)  FREE(X), when X is not equal to null, is an indication that the object
  2026.      designated by X is  no  longer  required,  and  that  the  storage  it
  2027.      occupies is to be reclaimed.
  2028.  
  2029. If  X and Y designate the same object, then accessing this object through Y
  2030. is erroneous if this access is performed  (or  attempted)  after  the  call
  2031. FREE(X);  the effect of each such access is not defined by the language.
  2032.  
  2033. Notes:
  2034.  
  2035. It  is  a  consequence  of  the visibility rules that the generic procedure
  2036. UNCHECKED_DEALLOCATION is not visible in a  compilation  unit  unless  this
  2037. generic  procedure  is  mentioned  by  a  with  clause  that applies to the
  2038. compilation unit.
  2039.  
  2040.  
  2041.  
  2042.  
  2043.                                   13 - 30
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052. If X designates a task object, the call FREE(X) has no effect on  the  task
  2053. designated  by  the  value  of  this  task  object.  The same holds for any
  2054. subcomponent of the object designated by X, if this subcomponent is a  task
  2055. object.
  2056.  
  2057. References:    access  type  3.8,  apply  10.1.1,  compilation  unit  10.1,
  2058. designate 3.8 9.1,  erroneous  1.6,  generic  instantiation  12.3,  generic
  2059. procedure  12.1, generic unit 12, library unit 10.1, null access value 3.8,
  2060. object 3.2, procedure 6, procedure call 6.4, subcomponent 3.3, task 9, task
  2061. object 9.2, visibility 8.3, with clause 10.1.1
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.                                   13 - 31
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118. 13.10.2  Unchecked Type Conversions
  2119.  
  2120.  
  2121. An unchecked type conversion can be achieved by a call of a  function  that
  2122. is  obtained by instantiation of the generic function UNCHECKED_CONVERSION.
  2123.  
  2124. The effect of an unchecked conversion  is  to  return  the  (uninterpreted)
  2125. parameter  value  as  a  value of the target type, that is, the bit pattern
  2126. defining the source value is returned unchanged as the bit pattern defining
  2127. a value of the target type.  An implementation may  place  restrictions  on
  2128. unchecked   conversions,   for   example,  restrictions  depending  on  the
  2129. respective  sizes  of  objects  of  the  source  and  target  type.    Such
  2130. restrictions must be documented in appendix F.
  2131.  
  2132. Whenever   unchecked   conversions   are   used,  it  is  the  programmer's
  2133. responsibility to ensure that these  conversions  maintain  the  properties
  2134. that  are  guaranteed  by  the  language  for  objects  of the target type.
  2135. Programs that violate these properties by means  of  unchecked  conversions
  2136. are erroneous.
  2137.  
  2138.  
  2139. Note:
  2140.  
  2141. It  is  a  consequence  of  the  visibility rules that the generic function
  2142. UNCHECKED_CONVERSION is not visible  in  a  compilation  unit  unless  this
  2143. generic  function  is  mentioned  by  a  with  clause  that  applies to the
  2144. compilation unit.
  2145.  
  2146.  
  2147. References:  apply 10.1.1, compilation unit 10.1,  erroneous  1.6,  generic
  2148. function 12.1, instantiation 12.3, parameter of a subprogram 6.2, type 3.3,
  2149. with clause 10.1.1
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.                                   13 - 32
  2176.  
  2177.  
  2178.  
  2179.  
  2180.