OSDN Git Service

* 1aexcept.adb, 1aexcept.ads, 1ic.ads, 1ssecsta.adb,
[pf3gnuchains/gcc-fork.git] / gcc / ada / sem_ch8.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              S E M _ C H 8                               --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2001 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 2,  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 COPYING.  If not, write --
19 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, USA.                                                      --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 with Types; use Types;
28 package Sem_Ch8 is
29
30    -----------------------------------
31    -- Handling extensions of System --
32    -----------------------------------
33
34    --  For targets that define a much larger System package than given in
35    --  the RM, we use a child package containing additional declarations,
36    --  which is loaded when needed, and whose entities are conceptually
37    --  within System itself. The presence of this auxiliary package is
38    --  controlled with the pragma Extend_System. The following variable
39    --  holds the entity of the auxiliary package, to simplify the special
40    --  visibility rules that apply to it.
41
42    System_Aux_Id : Entity_Id := Empty;
43
44    -----------------
45    -- Subprograms --
46    -----------------
47
48    procedure Analyze_Exception_Renaming                 (N : Node_Id);
49    procedure Analyze_Expanded_Name                      (N : Node_Id);
50    procedure Analyze_Generic_Function_Renaming          (N : Node_Id);
51    procedure Analyze_Generic_Package_Renaming           (N : Node_Id);
52    procedure Analyze_Generic_Procedure_Renaming         (N : Node_Id);
53    procedure Analyze_Object_Renaming                    (N : Node_Id);
54    procedure Analyze_Package_Renaming                   (N : Node_Id);
55    procedure Analyze_Subprogram_Renaming                (N : Node_Id);
56    procedure Analyze_Use_Package                        (N : Node_Id);
57    procedure Analyze_Use_Type                           (N : Node_Id);
58
59    function Applicable_Use (Pack_Name : Node_Id) return Boolean;
60    --  Common code to Use_One_Package and Set_Use, to determine whether
61    --  use clause must be processed. Pack_Name is an entity name that
62    --  references the package in question.
63
64    procedure End_Scope;
65    --  Called at end of scope. On exit from blocks and bodies (subprogram,
66    --  package, task, and protected bodies), the name of the current scope
67    --  must be removed from the scope stack, and the local entities must be
68    --  removed from their homonym chains. On exit from record declarations,
69    --  from package specifications, and from tasks and protected type
70    --  specifications, more specialized procedures are invoked.
71
72    procedure End_Use_Clauses (Clause : Node_Id);
73    --  Invoked on scope exit, to undo the effect of local use clauses. U is
74    --  the first Use clause of a scope being exited. This can be the current
75    --  scope, or some enclosing scopes when building a clean environment to
76    --  compile an instance body for inlining.
77
78    procedure End_Use_Package (N : Node_Id);
79    procedure End_Use_Type    (N : Node_Id);
80    --  Subsidiaries of End_Use_Clauses.  Also called directly for use clauses
81    --  appearing in context clauses.
82
83    procedure Find_Direct_Name (N : Node_Id);
84    --  Given a direct name (Identifier or Operator_Symbol), this routine
85    --  scans the homonym chain for the name searching for corresponding
86    --  visible entities to find the referenced entity (or in the case of
87    --  overloading), entities. On return, the Entity, and Etype fields
88    --  are set. In the non-overloaded case, these are the correct final
89    --  entries. In the overloaded case, Is_Overloaded is set, Etype and
90    --  Entity refer to an arbitrary element of the overloads set, and
91    --  an appropriate list of entries has been made in the overload
92    --  interpretation table (to be disambiguated in the resolve phase).
93
94    procedure Find_Expanded_Name (N : Node_Id);
95    --  Selected component is known to be expanded name. Verify legality
96    --  of selector given the scope denoted by prefix.
97
98    procedure Find_Selected_Component (N : Node_Id);
99    --  Resolve various cases of selected components, recognize expanded names
100
101    procedure Find_Type (N : Node_Id);
102    --  Perform name resolution, and verify that the name found is that of a
103    --  type. On return the Entity and Etype fields of the node N are set
104    --  appropriately. If it is an incomplete type whose full declaration has
105    --  been seen, return the entity in the full declaration. Similarly, if
106    --  the type is private, it has receivd a full declaration, and we are
107    --  in the private part or body of the package, return the full
108    --  declaration as well. Special processing for Class types as well.
109
110    function Get_Full_View (T_Name : Entity_Id) return Entity_Id;
111    --  If T_Name is an incomplete type and the full declaration has been
112    --  seen, or is the name of a class_wide type whose root is incomplete.
113    --  return the corresponding full declaration.
114
115    function Has_Implicit_Operator (N : Node_Id) return Boolean;
116    --  N is an expanded name whose selector is an operator name (eg P."+").
117    --  A declarative part contains an implicit declaration of an operator
118    --  if it has a declaration of a type to which one of the predefined
119    --  operators apply. The existence of this routine is an artifact of
120    --  our implementation: a more straightforward but more space-consuming
121    --  choice would be to make all inherited operators explicit in the
122    --  symbol table.
123
124    procedure Initialize;
125    --  Initializes data structures used for visibility analysis. Must be
126    --  called before analyzing each new main source program.
127
128    procedure Install_Use_Clauses (Clause : Node_Id);
129    --  applies the use clauses appearing in a given declarative part,
130    --  when the corresponding scope has been placed back on the scope
131    --  stack after unstacking to compile a different context (subunit or
132    --  parent of generic body).
133
134    function In_Open_Scopes (S : Entity_Id) return Boolean;
135    --  S is the entity of a scope. This function determines if this scope
136    --  is currently open (i.e. it appears somewhere in the scope stack).
137
138    function Is_Appropriate_For_Record (T : Entity_Id) return Boolean;
139    --  Prefix is appropriate for record if it is of a record type, or
140    --  an access to such.
141
142    function Is_Appropriate_For_Entry_Prefix (T : Entity_Id) return Boolean;
143    --  True if it is of a task type, a protected type, or else an access
144    --  to one of these types.
145
146    procedure New_Scope (S : Entity_Id);
147    --  Make new scope stack entry, pushing S, the entity for a scope
148    --  onto the top of the scope table. The current setting of the scope
149    --  suppress flags is saved for restoration on exit.
150
151    procedure Pop_Scope;
152    --  Remove top entry from scope stack, restoring the saved setting
153    --  of the scope suppress flags.
154
155    function Present_System_Aux (N : Node_Id := Empty) return Boolean;
156    --  Return True if the auxiliary system file has been successfully loaded.
157    --  Otherwise attempt to load it, using the name supplied by a previous
158    --  Extend_System pragma, and report on the success of the load.
159    --  If N is present, it is a selected component whose prefix is System,
160    --  or else a with-clause on system. N is absent when the function is
161    --  called to find the visibility of implicit operators.
162
163    procedure Restore_Scope_Stack;
164    procedure Save_Scope_Stack;
165    --  These two procedures are called from Semantics, when a unit U1 is
166    --  to be compiled in the course of the compilation of another unit U2.
167    --  This happens whenever Rtsfind is called. U1, the unit retrieved by
168    --  Rtsfind, must be compiled in its own context, and the current scope
169    --  stack containing U2 and local scopes must be made unreachable. On
170    --  return, the contents of the scope stack must be made accessible again.
171
172    procedure Use_One_Package (P : Entity_Id; N : Node_Id);
173    --  Make visible entities declarated in package P potentially use-visible
174    --  in the current context. Also used in the analysis of subunits, when
175    --  re-installing use clauses of parent units. N is the use_clause that
176    --  names P (and possibly other packages).
177
178    procedure Use_One_Type (Id : Node_Id);
179    --  Id is the subtype mark from a use type clause. This procedure makes
180    --  the primitive operators of the type potentially use-visible.
181
182    procedure Set_Use (L : List_Id);
183    --  Find use clauses that are declarative items in a package declaration
184    --  and  set the potentially use-visible flags of imported entities before
185    --  analyzing the corresponding package body.
186
187 end Sem_Ch8;