OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [lib-load.ads] - Blame information for rev 756

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.