annotate gcc/ada/lib-load.ads @ 118:fd00160c1b76

ifdef TARGET_64BIT
author mir3636
date Tue, 27 Feb 2018 15:01:35 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- L I B . L O A D --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This child package contains the function used to load a separately
kono
parents:
diff changeset
27 -- compiled unit, as well as the routine used to initialize the unit
kono
parents:
diff changeset
28 -- table and load the main source file.
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 package Lib.Load is
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -------------------------------
kono
parents:
diff changeset
33 -- Handling of Renamed Units --
kono
parents:
diff changeset
34 -------------------------------
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 -- A compilation unit can be a renaming of another compilation unit.
kono
parents:
diff changeset
37 -- Such renamed units are not allowed as parent units, that is you
kono
parents:
diff changeset
38 -- cannot declare a unit:
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 -- with x;
kono
parents:
diff changeset
41 -- package x.y is end;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 -- where x is a renaming of some other package. However you can refer
kono
parents:
diff changeset
44 -- to a renamed unit in a with clause:
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 -- package p is end;
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 -- package p.q is end;
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 -- with p;
kono
parents:
diff changeset
51 -- package pr renames p;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 -- with pr.q ....
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 -- This means that in the context of a with clause, the normal fixed
kono
parents:
diff changeset
56 -- correspondence between unit and file names is broken. In the above
kono
parents:
diff changeset
57 -- example, there is no file named pr-q.ads, since the actual child
kono
parents:
diff changeset
58 -- unit is p.q, and it will be found in file p-q.ads.
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 -- In order to deal with this case, we have to first load pr.ads, and
kono
parents:
diff changeset
61 -- then discover that it is a renaming of p, so that we know that pr.q
kono
parents:
diff changeset
62 -- really refers to p.q. Furthermore this can happen at any level:
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 -- with p.q;
kono
parents:
diff changeset
65 -- package p.r renames p.q;
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 -- with p.q;
kono
parents:
diff changeset
68 -- package p.q.s is end;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 -- with p.r.s ...
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 -- Now we have a case where the parent p.r is a child unit and is
kono
parents:
diff changeset
73 -- a renaming. This shows that renaming can occur at any level.
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 -- Finally, consider:
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 -- with pr.q.s ...
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 -- Here the parent pr.q is not itself a renaming, but it really refers
kono
parents:
diff changeset
80 -- to the unit p.q, and again we cannot know this without loading the
kono
parents:
diff changeset
81 -- parent. The bottom line here is that while the file name of a unit
kono
parents:
diff changeset
82 -- always corresponds to the unit name, the unit name as given to the
kono
parents:
diff changeset
83 -- Load_Unit function may not be the real unit.
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 -----------------
kono
parents:
diff changeset
86 -- Subprograms --
kono
parents:
diff changeset
87 -----------------
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 procedure Initialize;
kono
parents:
diff changeset
90 -- Initialize internal tables
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 procedure Initialize_Version (U : Unit_Number_Type);
kono
parents:
diff changeset
93 -- This is called once the source file corresponding to unit U has been
kono
parents:
diff changeset
94 -- fully scanned. At that point the checksum is computed, and can be used
kono
parents:
diff changeset
95 -- to initialize the version number.
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 procedure Load_Main_Source;
kono
parents:
diff changeset
98 -- Called at the start of compiling a new main source unit to initialize
kono
parents:
diff changeset
99 -- the library processing for the new main source. Establishes and
kono
parents:
diff changeset
100 -- initializes the units table entry for the new main unit (leaving
kono
parents:
diff changeset
101 -- the Unit_File_Name entry of Main_Unit set to No_File if there are no
kono
parents:
diff changeset
102 -- more files. Otherwise the main source file has been opened and read
kono
parents:
diff changeset
103 -- and then closed on return.
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 function Load_Unit
kono
parents:
diff changeset
106 (Load_Name : Unit_Name_Type;
kono
parents:
diff changeset
107 Required : Boolean;
kono
parents:
diff changeset
108 Error_Node : Node_Id;
kono
parents:
diff changeset
109 Subunit : Boolean;
kono
parents:
diff changeset
110 Corr_Body : Unit_Number_Type := No_Unit;
kono
parents:
diff changeset
111 Renamings : Boolean := False;
kono
parents:
diff changeset
112 With_Node : Node_Id := Empty;
kono
parents:
diff changeset
113 PMES : Boolean := False) return Unit_Number_Type;
kono
parents:
diff changeset
114 -- This function loads and parses the unit specified by Load_Name (or
kono
parents:
diff changeset
115 -- returns the unit number for the previously constructed units table
kono
parents:
diff changeset
116 -- entry if this is not the first call for this unit). Required indicates
kono
parents:
diff changeset
117 -- the behavior on a file not found condition, as further described below,
kono
parents:
diff changeset
118 -- and Error_Node is the node in the calling program to which error
kono
parents:
diff changeset
119 -- messages are to be attached.
kono
parents:
diff changeset
120 --
kono
parents:
diff changeset
121 -- If the corresponding file is found, the value returned by Load is the
kono
parents:
diff changeset
122 -- unit number that indexes the corresponding entry in the units table. If
kono
parents:
diff changeset
123 -- a serious enough parser error occurs to prevent subsequent semantic
kono
parents:
diff changeset
124 -- analysis, then the Fatal_Error flag of the returned entry is set and
kono
parents:
diff changeset
125 -- in addition, the fatal error flag of the calling unit is also set.
kono
parents:
diff changeset
126 --
kono
parents:
diff changeset
127 -- If the corresponding file is not found, then the behavior depends on
kono
parents:
diff changeset
128 -- the setting of Required. If Required is False, then No_Unit is returned
kono
parents:
diff changeset
129 -- and no error messages are issued. If Required is True, then an error
kono
parents:
diff changeset
130 -- message is posted, and No_Unit is returned.
kono
parents:
diff changeset
131 --
kono
parents:
diff changeset
132 -- A special case arises in the call from Rtsfind, where Error_Node is set
kono
parents:
diff changeset
133 -- to Empty. In this case Required is False, and the caller in any case
kono
parents:
diff changeset
134 -- treats any error as fatal.
kono
parents:
diff changeset
135 --
kono
parents:
diff changeset
136 -- The Subunit parameter is True to load a subunit, and False to load
kono
parents:
diff changeset
137 -- any other kind of unit (including all specs, package bodies, and
kono
parents:
diff changeset
138 -- subprogram bodies).
kono
parents:
diff changeset
139 --
kono
parents:
diff changeset
140 -- The Corr_Body argument is normally defaulted. It is set only in the
kono
parents:
diff changeset
141 -- case of loading the corresponding spec when the main unit is a body.
kono
parents:
diff changeset
142 -- In this case, Corr_Body is the unit number of this corresponding
kono
parents:
diff changeset
143 -- body. This is used to set the Serial_Ref_Unit field of the unit
kono
parents:
diff changeset
144 -- table entry. It is also used to deal with the special processing
kono
parents:
diff changeset
145 -- required by RM 10.1.4(4). See description in lib.ads.
kono
parents:
diff changeset
146 --
kono
parents:
diff changeset
147 -- Renamings activates the handling of renamed units as separately
kono
parents:
diff changeset
148 -- described in the documentation of this unit. If this parameter is
kono
parents:
diff changeset
149 -- set to True, then Load_Name may not be the real unit name and it
kono
parents:
diff changeset
150 -- is necessary to load parents to find the real name.
kono
parents:
diff changeset
151 --
kono
parents:
diff changeset
152 -- With_Node is set to the with_clause or limited_with_clause causing
kono
parents:
diff changeset
153 -- the unit to be loaded, and is used to bypass the circular dependency
kono
parents:
diff changeset
154 -- check in the case of a limited_with_clause (Ada 2005, AI-50217).
kono
parents:
diff changeset
155 --
kono
parents:
diff changeset
156 -- PMES indicates the required setting of Parsing_Main_Extended_Unit during
kono
parents:
diff changeset
157 -- loading of the unit. This flag is saved and restored over the call.
kono
parents:
diff changeset
158 -- Note: PMES is false for the subunit case, which seems wrong???
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 procedure Change_Main_Unit_To_Spec;
kono
parents:
diff changeset
161 -- This procedure is called if the main unit file contains a No_Body pragma
kono
parents:
diff changeset
162 -- and no other tokens. The effect is, if possible, to change the main unit
kono
parents:
diff changeset
163 -- from the body it references now, to the corresponding spec. This has the
kono
parents:
diff changeset
164 -- effect of ignoring the body, which is what we want. If it is impossible
kono
parents:
diff changeset
165 -- to successfully make the change, then the call has no effect, and the
kono
parents:
diff changeset
166 -- file is unchanged (this will lead to an error complaining about the
kono
parents:
diff changeset
167 -- inappropriate No_Body spec).
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 function Create_Dummy_Package_Unit
kono
parents:
diff changeset
170 (With_Node : Node_Id;
kono
parents:
diff changeset
171 Spec_Name : Unit_Name_Type) return Unit_Number_Type;
kono
parents:
diff changeset
172 -- With_Node is the Node_Id of a with statement for which the file could
kono
parents:
diff changeset
173 -- not be found, and Spec_Name is the corresponding unit name. This call
kono
parents:
diff changeset
174 -- creates a dummy package unit so that compilation can continue without
kono
parents:
diff changeset
175 -- blowing up when the missing unit is referenced.
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 procedure Make_Child_Decl_Unit (N : Node_Id);
kono
parents:
diff changeset
178 -- For a child subprogram body without a spec, we create a subprogram
kono
parents:
diff changeset
179 -- declaration in order to attach the required parent link. We create
kono
parents:
diff changeset
180 -- a Units_Table entry for this declaration, in order to maintain a
kono
parents:
diff changeset
181 -- one-to-one correspondence between compilation units and table entries.
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 procedure Make_Instance_Unit (N : Node_Id; In_Main : Boolean);
kono
parents:
diff changeset
184 -- When a compilation unit is an instantiation, it contains both the
kono
parents:
diff changeset
185 -- declaration and the body of the instance, each of which can have its
kono
parents:
diff changeset
186 -- own elaboration routine. The file itself corresponds to the declaration.
kono
parents:
diff changeset
187 -- We create an additional entry for the body, so that the binder can
kono
parents:
diff changeset
188 -- generate the proper elaboration calls to both. The argument N is the
kono
parents:
diff changeset
189 -- compilation unit node created for the body.
kono
parents:
diff changeset
190 --
kono
parents:
diff changeset
191 -- If the instance is not the main program, we still generate the instance
kono
parents:
diff changeset
192 -- body even though we do not generate code for it. In that case we still
kono
parents:
diff changeset
193 -- generate a compilation unit node for it, and we need to make an entry
kono
parents:
diff changeset
194 -- for it in the units table, so as to maintain a one-to-one mapping
kono
parents:
diff changeset
195 -- between table and nodes. The table entry is used among other things to
kono
parents:
diff changeset
196 -- provide a canonical traversal order for context units for CodePeer.
kono
parents:
diff changeset
197 -- The flag In_Main indicates whether the instance is the main unit.
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 procedure Version_Update (U : Node_Id; From : Node_Id);
kono
parents:
diff changeset
200 -- This routine is called when unit U is found to be semantically
kono
parents:
diff changeset
201 -- dependent on unit From. It updates the version of U to register
kono
parents:
diff changeset
202 -- dependence on the version of From. The arguments are compilation
kono
parents:
diff changeset
203 -- unit nodes for the relevant library nodes.
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 end Lib.Load;