1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 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 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 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 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Record Representation Clauses</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-13-5.html">Previous</A> <A HREF="AA-13-5-2.html">Next</A></P>
<HR>
<H1> 13.5.1 Record Representation Clauses</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [A <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
specifies the storage representation of records and record extensions,
that is, the order, position, and size of components (including discriminants,
if any). <A NAME="I4477"></A>]</DIV>
<H4 ALIGN=CENTER>Language Design Principles</H4>
<DIV Class="Paranum"><FONT SIZE=-2>1.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>It should be feasible for an implementation
to use negative offsets in the representation of composite types. However,
no implementation should be forced to support negative offsets. Therefore,
negative offsets should be disallowed in <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>s.
</FONT></DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">record_representation_clause<A NAME="I4478"></A>
::= </FONT><BR>
<B>for</B> <I>first_subtype_</I><A NAME="I4479"></A><FONT FACE="Arial, Helvetica">local_name</FONT> <B>use</B><BR>
<B>record</B> [<A NAME="I4480"></A><FONT FACE="Arial, Helvetica">mod_clause</FONT>]<BR>
{<A NAME="I4481"></A><FONT FACE="Arial, Helvetica">component_clause</FONT>}<BR>
<B>end</B> <B>record</B>;</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">component_clause<A NAME="I4482"></A>
::= </FONT><BR>
<I>component_</I><A NAME="I4483"></A><FONT FACE="Arial, Helvetica">local_name</FONT> <B>at</B> <A NAME="I4484"></A><FONT FACE="Arial, Helvetica">position</FONT> <B>range</B> <A NAME="I4485"></A><FONT FACE="Arial, Helvetica">first_bit</FONT> .. <A NAME="I4486"></A><FONT FACE="Arial, Helvetica">last_bit</FONT>;</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">position<A NAME="I4487"></A>
::= </FONT><I>static_</I><A NAME="I4488"></A><FONT FACE="Arial, Helvetica">expression</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">first_bit<A NAME="I4489"></A>
::= </FONT><I>static_</I><A NAME="I4490"></A><FONT FACE="Arial, Helvetica">simple_expression</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">last_bit<A NAME="I4491"></A>
::= </FONT><I>static_</I><A NAME="I4492"></A><FONT FACE="Arial, Helvetica">simple_expression</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B><FONT FACE="Arial, Helvetica">First_bit</FONT>
and <FONT FACE="Arial, Helvetica">last_bit</FONT> need to be <FONT FACE="Arial, Helvetica">simple_expression</FONT>
instead of <FONT FACE="Arial, Helvetica">expression</FONT> for the same
reason as in <FONT FACE="Arial, Helvetica">range</FONT> (see <A HREF="AA-3-5.html">3.5</A>,
``<A HREF="AA-3-5.html">Scalar Types</A>''). </FONT></DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> <A NAME="I4493"></A><A NAME="I4494"></A><A NAME="I4495"></A><A NAME="I4496"></A>Each
<FONT FACE="Arial, Helvetica">position</FONT>, <FONT FACE="Arial, Helvetica">first_bit</FONT>,
and <FONT FACE="Arial, Helvetica">last_bit</FONT> is expected to be of
any integer type. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>These need
not have the same integer type. </FONT></DIV>
<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> The <I>first_subtype_</I><FONT FACE="Arial, Helvetica">local_name</FONT>
of a <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
shall denote a specific nonlimited record or record extension subtype.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>As for all
type-related representation items, the <FONT FACE="Arial, Helvetica">local_name</FONT>
is required to denote a first subtype. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal"> If the <I>component_</I><FONT FACE="Arial, Helvetica">local_name</FONT>
is a <FONT FACE="Arial, Helvetica">direct_name</FONT>, the <FONT FACE="Arial, Helvetica">local_name</FONT>
shall denote a component of the type. For a record extension, the component
shall not be inherited, and shall not be a discriminant that corresponds
to a discriminant of the parent type. If the <I>component_</I><FONT FACE="Arial, Helvetica">local_name</FONT>
has an <FONT FACE="Arial, Helvetica">attribute_designator</FONT>, the
<FONT FACE="Arial, Helvetica">direct_name</FONT> of the <FONT FACE="Arial, Helvetica">local_name</FONT>
shall denote either the declaration of the type or a component of the
type, and the <FONT FACE="Arial, Helvetica">attribute_designator</FONT>
shall denote an implementation-defined implicit component of the type.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal"> The <FONT FACE="Arial, Helvetica">position</FONT>,
<FONT FACE="Arial, Helvetica">first_bit</FONT>, and <FONT FACE="Arial, Helvetica">last_bit</FONT>
shall be static expressions. The value of <FONT FACE="Arial, Helvetica">position</FONT>
and <FONT FACE="Arial, Helvetica">first_bit</FONT> shall be nonnegative.
The value of <FONT FACE="Arial, Helvetica">last_bit</FONT> shall be no
less than <FONT FACE="Arial, Helvetica">first_bit</FONT> - 1. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>A <FONT FACE="Arial, Helvetica">component_clause</FONT>
such as ``X <B>at</B> 4 <B>range</B> 0..-1;'' is allowed if X can fit
in zero bits. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Normal"> At most one <FONT FACE="Arial, Helvetica">component_clause</FONT>
is allowed for each component of the type, including for each discriminant
(<FONT FACE="Arial, Helvetica">component_clauses</FONT> may be given
for some, all, or none of the components). Storage places within a <FONT FACE="Arial, Helvetica">component_list</FONT>
shall not overlap, unless they are for components in distinct <FONT FACE="Arial, Helvetica">variant</FONT>s
of the same <FONT FACE="Arial, Helvetica">variant_part</FONT>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Normal"> A name that denotes a component of a type is
not allowed within a <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
for the type, except as the <I>component_</I><FONT FACE="Arial, Helvetica">local_name</FONT>
of a <FONT FACE="Arial, Helvetica">component_clause</FONT>. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.a</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1><B>Reason:
</B>It might seem strange to make the <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
part of the declarative region, and then disallow mentions of the components
within almost all of the <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>.
The alternative would be to treat the <I>component_</I><FONT FACE="Arial, Helvetica">local_name</FONT>
like a formal parameter name in a subprogram call (in terms of visibility).
However, this rule would imply slightly different semantics, because
(given the actual rule) the components can hide other declarations. This
was the rule in Ada 83, and we see no reason to change it. The following,
for example, was and is illegal: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.b</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>type</B> T <B>is</B><BR>
<B>record</B><BR>
X : Integer;<BR>
<B>end</B> <B>record</B>;<BR>
X : <B>constant</B> := 31; --<I> Same defining name as the component.</I><BR>
<B>for</B> T <B>use</B><BR>
<B>record</B><BR>
X <B>at</B> 0 <B>range</B> 0..X; --<I> Illegal!</I><BR>
<B>end</B> <B>record</B>;<BR>
</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The component X hides the named
number X throughout the <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>.
</FONT></DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
(without the <FONT FACE="Arial, Helvetica">mod_clause</FONT>) specifies
the layout. The storage place attributes (see <A HREF="AA-13-5-2.html">13.5.2</A>)
are taken from the values of the <FONT FACE="Arial, Helvetica">position</FONT>,
<FONT FACE="Arial, Helvetica">first_bit</FONT>, and <FONT FACE="Arial, Helvetica">last_bit</FONT>
expressions after normalizing those values so that <FONT FACE="Arial, Helvetica">first_bit</FONT>
is less than Storage_Unit. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>For example,
if Storage_Unit is 8, then ``C <B>at</B> 0 <B>range</B> 24..31;'' defines
C'Position = 3, C'First_Bit = 0, and C'Last_Bit = 7. This is true of
machines with either bit ordering.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>A <FONT FACE="Arial, Helvetica">component_clause</FONT>
also determines the value of the Size attribute of the component, since
this attribute is related to First_Bit and Last_Bit. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal"> [A <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
for a record extension does not override the layout of the parent part;]
if the layout was specified for the parent type, it is inherited by the
record extension. </DIV>
<H4 ALIGN=CENTER>Implementation Permissions</H4>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Normal"> An implementation may generate implementation-defined
components (for example, one containing the offset of another component).
An implementation may generate names that denote such implementation-defined
components; such names shall be implementation-defined <FONT FACE="Arial, Helvetica">attribute_reference</FONT>s.
An implementation may allow such implementation-defined names to be used
in <FONT FACE="Arial, Helvetica">record_representation_clauses</FONT>.
An implementation can restrict such <FONT FACE="Arial, Helvetica">component_clause</FONT>s
in any manner it sees fit. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>Implementation-defined
components.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Of course,
since the semantics of implementation-defined attributes is implementation
defined, the implementation need not support these names in all situations.
They might be purely for the purpose of <FONT FACE="Arial, Helvetica">component_clause</FONT>s,
for example. The visibility rules for such names are up to the implementation.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We do not allow such component
names to be normal identifiers -- that would constitute blanket permission
to do all kinds of evil things. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B><A NAME="I4497"></A>Such
implementation-defined components are known in the vernacular as ``dope.''
Their main purpose is for storing offsets of components that depend on
discriminants. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Normal"> If a <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
is given for an untagged derived type, the storage place attributes for
all of the components of the derived type may differ from those of the
corresponding components of the parent type, even for components whose
storage place is not specified explicitly in the <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This is clearly
necessary, since the whole record may need to be laid out differently.
</FONT></DIV>
<H4 ALIGN=CENTER>Implementation Advice</H4>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <A NAME="I4498"></A>The
recommended level of support for <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>s
is: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An implementation should support storage places that can
be extracted with a load, mask, shift sequence of machine code, and set
with a load, shift, mask, store sequence, given the available machine
instructions and run-time model.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A storage place should be supported if its size is equal
to the Size of the component subtype, and it starts and ends on a boundary
that obeys the Alignment of the component subtype.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>If the default bit ordering applies to the declaration
of a given type, then for a component whose subtype's Size is less than
the word size, any storage place that does not cross an aligned word
boundary should be supported. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>20.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The above recommendations
are sufficient to define interfaces to most interesting hardware. This
causes less implementation burden than the definition in ACID, which
requires arbitrary bit alignments of arbitrarily large components. Since
the ACID definition is neither enforced by the ACVC, nor supported by
all implementations, it seems OK for us to weaken it. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An implementation may reserve a storage place for the tag
field of a tagged type, and disallow other components from overlapping
that place. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>21.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Similar permission
for other dope is not granted. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An implementation need not support a <FONT FACE="Arial, Helvetica">component_clause</FONT>
for a component of an extension part if the storage place is not after
the storage places of all components of the parent type, whether or not
those storage places had been specified. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>22.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>These restrictions
are probably necessary if block equality operations are to be feasible
for class-wide types. For block comparison to work, the implementation
typically has to fill in any gaps with zero (or one) bits. If a ``gap''
in the parent type is filled in with a component in a type extension,
then this won't work when a class-wide object is passed by reference,
as is required. </FONT></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>12 If no <FONT FACE="Arial, Helvetica">component_clause</FONT>
is given for a component, then the choice of the storage place for the
component is left to the implementation. If <FONT FACE="Arial, Helvetica">component_clause</FONT>s
are given for all components, the <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
completely specifies the representation of the type and will be obeyed
exactly by the implementation. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The visibility
rules prevent the name of a component of the type from appearing in a
<FONT FACE="Arial, Helvetica">record_representation_clause</FONT> at
any place <I>except</I> for the <I>component_</I><FONT FACE="Arial, Helvetica">local_name</FONT>
of a <FONT FACE="Arial, Helvetica">component_clause</FONT>. However,
since the <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
is part of the declarative region of the type declaration, the component
names hide outer homographs throughout.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23.b/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>{<I><A HREF="defect1.html#8652/0009">8652/0009</A></I>}
A <FONT FACE="Arial, Helvetica">record_representation_clause</FONT> cannot
be given for a protected type, even though protected types, like record
types, have components. The primary reason for this rule is that there
is likely to be too much dope in a protected type -- entry queues, bit
maps for barrier values, etc. In order to control the representation
of the user-defined components, simply declare a record type, give it
a <FONT FACE="Arial, Helvetica"><U>record_</U>representation_clause</FONT>,
and give the protected type one component whose type is the record type.
Alternatively, if the protected object is protecting something like a
device register, it makes more sense to keep the thing being protected
outside the protected object (possibly with a pointer to it in the protected
object), in order to keep implementation-defined components out of the
way. </FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Example of specifying
the layout of a record type:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Examples"><TT>Word : <B>constant</B> := 4; --<I> storage element is byte, 4 bytes per word</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> State <B>is</B> (A,M,W,P);<BR>
<B>type</B> Mode <B>is</B> (Fix, Dec, Exp, Signif);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> Byte_Mask <B>is</B> <B>array</B> (0..7) <B>of</B> Boolean;<BR>
<B>type</B> State_Mask <B>is</B> <B>array</B> (State) <B>of</B> Boolean;<BR>
<B>type</B> Mode_Mask <B>is</B> <B>array</B> (Mode) <B>of</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> Program_Status_Word <B>is</B><BR>
<B>record</B><BR>
System_Mask : Byte_Mask;<BR>
Protection_Key : Integer <B>range</B> 0 .. 3;<BR>
Machine_State : State_Mask;<BR>
Interrupt_Cause : Interruption_Code;<BR>
Ilc : Integer <B>range</B> 0 .. 3;<BR>
Cc : Integer <B>range</B> 0 .. 3;<BR>
Program_Mask : Mode_Mask;<BR>
Inst_Address : Address;<BR>
<B>end</B> <B>record</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Examples"><TT><B>for</B> Program_Status_Word <B>use</B><BR>
<B>record</B><BR>
System_Mask <B>at</B> 0*Word <B>range</B> 0 .. 7;<BR>
Protection_Key <B>at</B> 0*Word <B>range</B> 10 .. 11; --<I> bits 8,9 unused</I><BR>
Machine_State <B>at</B> 0*Word <B>range</B> 12 .. 15;<BR>
Interrupt_Cause <B>at</B> 0*Word <B>range</B> 16 .. 31;<BR>
Ilc <B>at</B> 1*Word <B>range</B> 0 .. 1; --<I> second word</I><BR>
Cc <B>at</B> 1*Word <B>range</B> 2 .. 3;<BR>
Program_Mask <B>at</B> 1*Word <B>range</B> 4 .. 7;<BR>
Inst_Address <B>at</B> 1*Word <B>range</B> 8 .. 31;<BR>
<B>end</B> <B>record</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="Examples"><TT><B>for</B> Program_Status_Word'Size <B>use</B> 8*System.Storage_Unit;<BR>
<B>for</B> Program_Status_Word'Alignment <B>use</B> 8;</TT></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>13 <I>Note on the example:</I>
The <FONT FACE="Arial, Helvetica">record_representation_clause</FONT>
defines the record layout. The Size clause guarantees that (at least)
eight storage elements are used for objects of the type. The Alignment
clause guarantees that aliased, imported, or exported objects of the
type will have addresses divisible by eight. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>31.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The <FONT FACE="Arial, Helvetica">alignment_clause</FONT>
has been renamed to <FONT FACE="Arial, Helvetica">mod_clause</FONT> and
moved to <A HREF="AA-J.html">Annex J</A>, ``<A HREF="AA-J.html">Obsolescent
Features</A>''.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We have clarified that implementation-defined
component names have to be in the form of an <FONT FACE="Arial, Helvetica">attribute_reference</FONT>
of a component or of the first subtype itself; surely Ada 83 did not
intend to allow arbitrary identifiers.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The RM83-13.4(7) wording incorrectly
allows components in non-variant records to overlap. We have corrected
that oversight. </FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-13-5.html">Previous</A> <A HREF="AA-13-5-2.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|