File: AA-10-1-4.html

package info (click to toggle)
ada-reference-manual 20021112web-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 18,652 kB
  • ctags: 8,921
  • sloc: makefile: 52; sh: 20
file content (272 lines) | stat: -rw-r--r-- 20,197 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>AARM95 - The Compilation Process</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>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-10-1-3.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-10-1-5.html">Next</A></P>
<HR>
<H1> 10.1.4 The Compilation Process</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;<A NAME="I3928"></A><A NAME="I3929"></A>Each compilation
unit submitted to the compiler is compiled in the context of an <I>environment</I>
<FONT FACE="Arial, Helvetica">declarative_part</FONT> (or simply, an
<I>environment</I>), which is a conceptual <FONT FACE="Arial, Helvetica">declarative_part</FONT>
that forms the outermost declarative region of the context of any <FONT FACE="Arial, Helvetica">compilation</FONT>.
At run time, an environment forms the <FONT FACE="Arial, Helvetica">declarative_part</FONT>
of the body of the environment task of a partition (see <A HREF="AA-10-2.html">10.2</A>,
``<A HREF="AA-10-2.html">Program Execution</A>''). </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>1.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>At compile
time, there is no particular construct that the declarative region is
considered to be nested within -- the environment is the universe. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>1.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>The environment
is really just a portion of a <FONT FACE="Arial, Helvetica">declarative_part</FONT>,
since there might, for example, be bodies that do not yet exist. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;The <FONT FACE="Arial, Helvetica">declarative_item</FONT>s
of the environment are <FONT FACE="Arial, Helvetica">library_item</FONT>s
appearing in an order such that there are no forward semantic dependences.
Each included subunit occurs in place of the corresponding stub. The
visibility rules apply as if the environment were the outermost declarative
region, except that <FONT FACE="Arial, Helvetica">with_clause</FONT>s
are needed to make declarations of library units visible (see <A HREF="AA-10-1-2.html">10.1.2</A>).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;The mechanisms for creating an environment and
for adding and replacing compilation units within an environment are
implementation defined. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>The
mechanisms for creating an environment and for adding and replacing compilation
units.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The traditional
model, used by most Ada 83 implementations, is that one places a compilation
unit in the environment by compiling it. Other models are possible. For
example, an implementation might define the environment to be a directory;
that is, the compilation units in the environment are all the compilation
units in the source files contained in the directory. In this model,
the mechanism for replacing a compilation unit with a new one is simply
to edit the source file containing that compilation unit. </FONT></DIV>

<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>4/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0032">8652/0032</A></I>}
If a <FONT FACE="Arial, Helvetica">library_unit_body</FONT> that is a
<FONT FACE="Arial, Helvetica">subprogram_body</FONT> is submitted to
the compiler, it is interpreted only as a completion if a <FONT FACE="Arial, Helvetica">library_unit_declaration</FONT>
<S>for a subprogram or a generic subprogram </S>with the same <FONT FACE="Arial, Helvetica">defining_program_unit_name</FONT>
already exists in the environment <U>for a subprogram other than an instance
of a generic subprogram or for a generic subprogram </U>(even if the
profile of the body is not type conformant with that of the declaration);
otherwise the <FONT FACE="Arial, Helvetica">subprogram_body</FONT> is
interpreted as both the declaration and body of a library subprogram.
<A NAME="I3930"></A></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The principle
here is that a <FONT FACE="Arial, Helvetica">subprogram_body</FONT> should
be interpreted as only a completion if and only if it ``might'' be legal
as the completion of some preexisting declaration, where ``might'' is
defined in a way that does not require overload resolution to determine.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Hence, if the preexisting declaration
is a <FONT FACE="Arial, Helvetica">subprogram_declaration</FONT> or <FONT FACE="Arial, Helvetica">generic_subprogram_declaration</FONT>,
we treat the new <FONT FACE="Arial, Helvetica">subprogram_body</FONT>
as its completion, because it ``might'' be legal. If it turns out that
the profiles don't fully conform, it's an error. In all other cases (the
preexisting declaration is a package or a generic package, or an instance
of a generic subprogram, or a renaming, or a ``spec-less'' subprogram,
or in the case where there is no preexisting thing), the <FONT FACE="Arial, Helvetica">subprogram_body</FONT>
declares a new subprogram.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>See also AI83-00266/09. </FONT></DIV>

<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;When a compilation unit is compiled, all compilation
units upon which it depends semantically shall already exist in the environment;
<A NAME="I3931"></A>the set of these compilation units shall be <I>consistent</I>
in the sense that the new compilation unit shall not semantically depend
(directly or indirectly) on two different versions of the same compilation
unit, nor on an earlier version of itself. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>For example,
if package declarations A and B both say ``<B>with</B> X;'', and the
user compiles a compilation unit that says ``<B>with</B> A, B;'', then
the A and B have to be talking about the same version of X. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>What it means
to be a ``different version'' is not specified by the language. In some
implementations, it means that the compilation unit has been recompiled.
In others, it means that the source of the compilation unit has been
edited in some significant way.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that an implementation cannot
require the existence of compilation units upon which the given one does
not semantically depend. For example, an implementation is required to
be able to compile a compilation unit that says &quot;<B>with</B> A;&quot;
when A's body does not exist. It has to be able to detect errors without
looking at A's body.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Similarly, the implementation
has to be able to compile a call to a subprogram for which a <FONT FACE="Arial, Helvetica">pragma</FONT>
Inline has been specified without seeing the body of that subprogram
-- inlining would not be achieved in this case, but the call is still
legal. </FONT></DIV>

<H4 ALIGN=CENTER>Implementation Permissions</H4>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;The implementation may require that a compilation
unit be legal before inserting it into the environment.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;When a compilation unit that declares or renames
a library unit is added to the environment, the implementation may remove
from the environment any preexisting <FONT FACE="Arial, Helvetica">library_item</FONT>
with the same <FONT FACE="Arial, Helvetica">defining_program_unit_name</FONT>.
When a compilation unit that is a subunit or the body of a library unit
is added to the environment, the implementation may remove from the environment
any preexisting version of the same compilation unit. When a given compilation
unit is removed from the environment, the implementation may also remove
any compilation unit that depends semantically upon the given one. If
the given compilation unit contains the body of a subprogram to which
a <FONT FACE="Arial, Helvetica">pragma</FONT> Inline applies, the implementation
may also remove any compilation unit containing a call to that subprogram.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The permissions
given in this paragraph correspond to the traditional model, where compilation
units enter the environment by being compiled into it, and the compiler
checks their legality at that time. A implementation model in which the
environment consists of all source files in a given directory might not
want to take advantage of these permissions. Compilation units would
not be checked for legality as soon as they enter the environment; legality
checking would happen later, when compilation units are compiled. In
this model, compilation units might never be automatically removed from
the environment; they would be removed when the user explicitly deletes
a source file.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that the rule is recursive:
if the above permission is used to remove a compilation unit containing
an inlined subprogram call, then compilation units that depend semantically
upon the removed one may also be removed, and so on.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that here we are talking
about dependences among existing compilation units in the environment;
it doesn't matter what <FONT FACE="Arial, Helvetica">with_clause</FONT>s
are attached to the new compilation unit that triggered all this.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>An implementation may have other
modes in which compilation units in addition to the ones mentioned above
are removed. For example, an implementation might inline subprogram calls
without an explicit <FONT FACE="Arial, Helvetica">pragma</FONT> Inline.
If so, it either has to have a mode in which that optimization is turned
off, or it has to automatically regenerate code for the inlined calls
without requiring the user to resubmit them to the compiler. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7.d.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>{<I><A HREF="defect2.html#8652/0108">8652/0108</A></I>}
<U>In the standard mode, implementations may only remove units from the
environment for one of the reasons listed here, or in response to an
explicit user command to modify the environment. It is not intended that
the act of compiling a unit is one of the ``mechansisms'' for removing
units other than those specified by this International Standard.</U>
</FONT></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>5&nbsp;&nbsp;The rules of the language
are enforced across <FONT FACE="Arial, Helvetica">compilation</FONT>
and compilation unit boundaries, just as they are enforced within a single
compilation unit. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Note that
Section 1 requires an implementation to detect illegal compilation units
at compile time. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>6&nbsp;&nbsp;<A NAME="I3932"></A>An
implementation may support a concept of a <I>library</I>, which contains
<FONT FACE="Arial, Helvetica">library_item</FONT>s. If multiple libraries
are supported, the implementation has to define how a single environment
is constructed when a compilation unit is submitted to the compiler.
Naming conflicts between different libraries might be resolved by treating
each library as the root of a hierarchy of child library units. <A NAME="I3933"></A></FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>Alternatively,
naming conflicts could be resolved via some sort of hiding rule. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>For example,
the implementation might support a command to import library Y into library
X. If a root library unit called LU (that is, Standard.LU) exists in
Y, then from the point of view of library X, it could be called Y.LU.
X might contain library units that say, ``<B>with</B> Y.LU;''. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>7&nbsp;&nbsp;A compilation unit containing
an instantiation of a separately compiled generic unit does not semantically
depend on the body of the generic unit. Therefore, replacing the generic
body in the environment does not result in the removal of the compilation
unit containing the instantiation. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>Therefore,
implementations have to be prepared to automatically instantiate generic
bodies at link-time, as needed. This might imply a complete automatic
recompilation, but it is the intent of the language that generic bodies
can be (re)instantiated without forcing all of the compilation units
that semantically depend on the compilation unit containing the instantiation
to be recompiled. </FONT></DIV>

<HR>
<P><A HREF="AA-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-10-1-3.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-10-1-5.html">Next</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>