OSDN Git Service

* config/pa/fptr.c: Update license header.
[pf3gnuchains/gcc-fork.git] / gcc / ada / sem_ch12.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             S E M _ C H 1 2                              --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2006, 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,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, 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 Inline; use Inline;
28 with Types;  use Types;
29
30 package Sem_Ch12 is
31    procedure Analyze_Generic_Package_Declaration        (N : Node_Id);
32    procedure Analyze_Generic_Subprogram_Declaration     (N : Node_Id);
33    procedure Analyze_Package_Instantiation              (N : Node_Id);
34    procedure Analyze_Procedure_Instantiation            (N : Node_Id);
35    procedure Analyze_Function_Instantiation             (N : Node_Id);
36    procedure Analyze_Formal_Object_Declaration          (N : Node_Id);
37    procedure Analyze_Formal_Type_Declaration            (N : Node_Id);
38    procedure Analyze_Formal_Subprogram                  (N : Node_Id);
39    procedure Analyze_Formal_Package                     (N : Node_Id);
40
41    procedure Start_Generic;
42    --  Must be invoked before starting to process a generic spec or body
43
44    procedure End_Generic;
45    --  Must be invoked just at the end of the end of the processing of a
46    --  generic spec or body.
47
48    procedure Check_Generic_Child_Unit
49      (Gen_Id           : Node_Id;
50       Parent_Installed : in out Boolean);
51    --  If the name of the generic unit in an instantiation or a renaming
52    --  is a selected component, then the prefix may be an instance and the
53    --  selector may  designate a child unit. Retrieve the parent generic
54    --  and search for the child unit that must be declared within. Similarly,
55    --  if this is the name of a generic child unit within an instantiation of
56    --  its own parent, retrieve the parent generic.
57
58    function Copy_Generic_Node
59      (N             : Node_Id;
60       Parent_Id     : Node_Id;
61       Instantiating : Boolean)
62       return          Node_Id;
63    --  Copy the tree for a generic unit or its body. The unit is copied
64    --  repeatedly: once to produce a copy on which semantic analysis of
65    --  the generic is performed, and once for each instantiation. The tree
66    --  being copied is not semantically analyzed, except that references to
67    --  global entities are marked on terminal nodes.
68
69    function Get_Instance_Of (A : Entity_Id) return Entity_Id;
70    --  Retrieve actual associated with given generic parameter.
71    --  If A is uninstantiated or not a generic parameter, return A.
72
73    function Get_Package_Instantiation_Node (A : Entity_Id) return Node_Id;
74    --  Given the entity of a unit that is an instantiation, retrieve the
75    --  original instance node. This is used when loading the instantiations
76    --  of the ancestors of a child generic that is being instantiated.
77
78    procedure Instantiate_Package_Body
79      (Body_Info    : Pending_Body_Info;
80       Inlined_Body : Boolean := False);
81    --  Called after semantic analysis, to complete the instantiation of
82    --  package instances. The flag Inlined_Body is set if the body is
83    --  being instantiated on the fly for inlined purposes.
84
85    procedure Instantiate_Subprogram_Body
86      (Body_Info : Pending_Body_Info);
87    --  Called after semantic analysis, to complete the instantiation of
88    --  function and procedure instances.
89
90    procedure Save_Global_References (N : Node_Id);
91    --  Traverse the original generic unit, and capture all references to
92    --  entities that are defined outside of the generic in the analyzed
93    --  tree for the template. These references are copied into the original
94    --  tree, so that they appear automatically in every instantiation.
95    --  A critical invariant in this approach is that if an id in the generic
96    --  resolves to a local entity, the corresponding id in the instance
97    --  will resolve to the homologous entity in the instance, even though
98    --  the enclosing context for resolution is different, as long as the
99    --  global references have been captured as described here.
100
101    --  Because instantiations can be nested, the environment of the instance,
102    --  involving the actuals and other data-structures, must be saved and
103    --  restored in stack-like fashion. Front-end inlining also uses these
104    --  structures for the management of private/full views.
105
106    procedure Set_Copied_Sloc_For_Inlined_Body (N : Node_Id; E : Entity_Id);
107    --  This procedure is used when a subprogram body is inlined. This process
108    --  shares the same circuitry as the creation of an instantiated copy of
109    --  a generic template. The call to this procedure establishes a new source
110    --  file entry representing the inlined body as an instantiation, marked as
111    --  an inlined body (so that errout can distinguish cases for generating
112    --  error messages, otherwise the treatment is identical). In this call
113    --  N is the subprogram body and E is the defining identifier of the
114    --  subprogram in quiestion. The resulting Sloc adjustment factor is
115    --  saved as part of the internal state of the Sem_Ch12 package for use
116    --  in subsequent calls to copy nodes.
117
118    procedure Save_Env
119      (Gen_Unit : Entity_Id;
120       Act_Unit : Entity_Id);
121    --   ??? comment needed
122
123    procedure Restore_Env;
124    --   ??? comment needed
125
126    procedure Initialize;
127    --  Initializes internal data structures
128
129    procedure Check_Private_View (N : Node_Id);
130    --  Check whether the type of a generic entity has a different view between
131    --  the point of generic analysis and the point of instantiation. If the
132    --  view has changed, then at the point of instantiation we restore the
133    --  correct view to perform semantic analysis of the instance, and reset
134    --  the current view after instantiation. The processing is driven by the
135    --  current private status of the type of the node, and Has_Private_View,
136    --  a flag that is set at the point of generic compilation. If view and
137    --  flag are inconsistent then the type is updated appropriately.
138    --
139    --  This subprogram is used in Check_Generic_Actuals and Copy_Generic_Node,
140    --  and is exported here for the purpose of front-end inlining (see Exp_Ch6.
141    --  Expand_Inlined_Call.Process_Formals).
142
143 end Sem_Ch12;