1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1992-2000 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 with Inline
; use Inline
;
30 with Types
; use Types
;
33 procedure Analyze_Generic_Package_Declaration
(N
: Node_Id
);
34 procedure Analyze_Generic_Subprogram_Declaration
(N
: Node_Id
);
35 procedure Analyze_Package_Instantiation
(N
: Node_Id
);
36 procedure Analyze_Procedure_Instantiation
(N
: Node_Id
);
37 procedure Analyze_Function_Instantiation
(N
: Node_Id
);
38 procedure Analyze_Formal_Object_Declaration
(N
: Node_Id
);
39 procedure Analyze_Formal_Type_Declaration
(N
: Node_Id
);
40 procedure Analyze_Formal_Subprogram
(N
: Node_Id
);
41 procedure Analyze_Formal_Package
(N
: Node_Id
);
43 procedure Start_Generic
;
44 -- Must be invoked before starting to process a generic spec or body.
46 procedure End_Generic
;
47 -- Must be invoked just at the end of the end of the processing of a
48 -- generic spec or body.
50 procedure Check_Generic_Child_Unit
52 Parent_Installed
: in out Boolean);
53 -- If the name of the generic unit in an instantiation or a renaming
54 -- is a selected component, then the prefix may be an instance and the
55 -- selector may designate a child unit. Retrieve the parent generic
56 -- and search for the child unit that must be declared within. Similarly,
57 -- if this is the name of a generic child unit within an instantiation of
58 -- its own parent, retrieve the parent generic.
60 function Copy_Generic_Node
63 Instantiating
: Boolean)
65 -- Copy the tree for a generic unit or its body. The unit is copied
66 -- repeatedly: once to produce a copy on which semantic analysis of
67 -- the generic is performed, and once for each instantiation. The tree
68 -- being copied is not semantically analyzed, except that references to
69 -- global entities are marked on terminal nodes.
71 function Get_Instance_Of
(A
: Entity_Id
) return Entity_Id
;
72 -- Retrieve actual associated with given generic parameter.
73 -- If A is uninstantiated or not a generic parameter, return A.
75 procedure Instantiate_Package_Body
76 (Body_Info
: Pending_Body_Info
);
77 -- Called after semantic analysis, to complete the instantiation of
80 procedure Instantiate_Subprogram_Body
81 (Body_Info
: Pending_Body_Info
);
82 -- Called after semantic analysis, to complete the instantiation of
83 -- function and procedure instances.
85 procedure Save_Global_References
(N
: Node_Id
);
86 -- Traverse the original generic unit, and capture all references to
87 -- entities that are defined outside of the generic in the analyzed
88 -- tree for the template. These references are copied into the original
89 -- tree, so that they appear automatically in every instantiation.
90 -- A critical invariant in this approach is that if an id in the generic
91 -- resolves to a local entity, the corresponding id in the instance
92 -- will resolve to the homologous entity in the instance, even though
93 -- the enclosing context for resolution is different, as long as the
94 -- global references have been captured as described here.
96 -- Because instantiations can be nested, the environment of the instance,
97 -- involving the actuals and other data-structures, must be saved and
98 -- restored in stack-like fashion. Front-end inlining also uses these
99 -- structures for the management of private/full views.
101 procedure Set_Copied_Sloc
(N
: Node_Id
; E
: Entity_Id
);
104 (Gen_Unit
: Entity_Id
;
105 Act_Unit
: Entity_Id
);
107 procedure Restore_Env
;