OSDN Git Service

* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Factor out
[pf3gnuchains/gcc-fork.git] / gcc / ada / exp_atag.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             E X P _ A T A G                              --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 2006-2009, 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 package contains routines involved in the frontend expansion of
27 --  subprograms of package Ada.Tags
28
29 with Types; use Types;
30 with Uintp; use Uintp;
31
32 package Exp_Atag is
33
34    --  Note: In all the subprograms of this package formal 'Loc' is the source
35    --  location used in constructing the corresponding nodes.
36
37    procedure Build_Common_Dispatching_Select_Statements
38      (Loc    : Source_Ptr;
39       DT_Ptr : Entity_Id;
40       Stmts  : List_Id);
41    --  Ada 2005 (AI-345): Generate statements that are common between timed,
42    --  asynchronous, and conditional select expansion.
43
44    function Build_CW_Membership
45      (Loc          : Source_Ptr;
46       Obj_Tag_Node : Node_Id;
47       Typ_Tag_Node : Node_Id) return Node_Id;
48    --  Build code that returns true if Obj_Tag is in Typ_Tag'Class. Each DT
49    --  has a table of ancestors and its inheritance level (Idepth). Obj is in
50    --  Typ'Class if Typ'Tag is found in the table of ancestors referenced by
51    --  Obj'Tag. Knowing the level of inheritance of both types, this can be
52    --  computed in constant time by the formula:
53    --
54    --   TSD (Obj'tag).Tags_Table (TSD (Obj'tag).Idepth - TSD (Typ'tag).Idepth)
55    --     = Typ'tag
56
57    function Build_Get_Access_Level
58      (Loc      : Source_Ptr;
59       Tag_Node : Node_Id) return Node_Id;
60    --  Build code that retrieves the accessibility level of the tagged type.
61    --
62    --  Generates: TSD (Tag).Access_Level
63
64    procedure Build_Get_Predefined_Prim_Op_Address
65      (Loc      : Source_Ptr;
66       Position : Uint;
67       Tag_Node : in out Node_Id;
68       New_Node : out Node_Id);
69    --  Given a pointer to a dispatch table (T) and a position in the DT, build
70    --  code that gets the address of the predefined virtual function stored in
71    --  it (used for dispatching calls). Tag_Node is relocated.
72    --
73    --  Generates: Predefined_DT (Tag).D (Position);
74
75    procedure Build_Get_Prim_Op_Address
76      (Loc      : Source_Ptr;
77       Typ      : Entity_Id;
78       Position : Uint;
79       Tag_Node : in out Node_Id;
80       New_Node : out Node_Id);
81    --  Build code that retrieves the address of the virtual function stored in
82    --  a given position of the dispatch table (used for dispatching calls).
83    --  Tag_Node is relocated.
84    --
85    --  Generates: To_Tag (Tag).D (Position);
86
87    function Build_Get_Transportable
88      (Loc      : Source_Ptr;
89       Tag_Node : Node_Id) return Node_Id;
90    --  Build code that retrieves the value of the Transportable flag for
91    --  the given Tag.
92    --
93    --  Generates: TSD (Tag).Transportable;
94
95    function Build_Inherit_Predefined_Prims
96      (Loc          : Source_Ptr;
97       Old_Tag_Node : Node_Id;
98       New_Tag_Node : Node_Id) return Node_Id;
99    --  Build code that inherits the predefined primitives of the parent.
100    --
101    --  Generates: Predefined_DT (New_T).D (All_Predefined_Prims) :=
102    --               Predefined_DT (Old_T).D (All_Predefined_Prims);
103    --
104    --  Required to build non-library level dispatch tables. Also required
105    --  when compiling without static dispatch tables support.
106
107    function Build_Inherit_Prims
108      (Loc          : Source_Ptr;
109       Typ          : Entity_Id;
110       Old_Tag_Node : Node_Id;
111       New_Tag_Node : Node_Id;
112       Num_Prims    : Nat) return Node_Id;
113    --  Build code that inherits Num_Prims user-defined primitives from the
114    --  dispatch table of the parent type of tagged type Typ. It is used to
115    --  copy the dispatch table of the parent in the following cases:
116    --    a) case of derivations of CPP_Class types
117    --    b) tagged types whose dispatch table is not statically allocated
118    --
119    --  Generates:
120    --    New_Tag.Prims_Ptr (1 .. Num_Prims) :=
121    --      Old_Tag.Prims_Ptr (1 .. Num_Prims);
122
123    function Build_Offset_To_Top
124      (Loc       : Source_Ptr;
125       This_Node : Node_Id) return Node_Id;
126    --  Build code that references the Offset_To_Top component of the primary
127    --  or secondary dispatch table associated with This_Node. This subprogram
128    --  provides a subset of the functionality provided by the function
129    --  Offset_To_Top of package Ada.Tags, and is only called by the frontend
130    --  when such routine is not available in a configurable runtime.
131    --
132    --  Generates:
133    --    Offset_To_Top_Ptr
134    --      (Address!(Tag_Ptr!(This).all) - Offset_To_Top_Offset)
135
136    function Build_Set_Predefined_Prim_Op_Address
137      (Loc          : Source_Ptr;
138       Tag_Node     : Node_Id;
139       Position     : Uint;
140       Address_Node : Node_Id) return Node_Id;
141    --  Build code that saves the address of a virtual function in a given
142    --  Position of the portion of the dispatch table associated with the
143    --  predefined primitives of Tag. Called from Exp_Disp.Fill_DT_Entry
144    --  and Exp_Disp.Fill_Secondary_DT_Entry. It is used for:
145    --   1) Filling the dispatch table of CPP_Class types.
146    --   2) Late overriding (see Check_Dispatching_Operation).
147    --
148    --  Generates: Predefined_DT (Tag).D (Position) := Value
149
150    function Build_Set_Prim_Op_Address
151      (Loc          : Source_Ptr;
152       Typ          : Entity_Id;
153       Tag_Node     : Node_Id;
154       Position     : Uint;
155       Address_Node : Node_Id) return Node_Id;
156    --  Build code that saves the address of a virtual function in a given
157    --  Position of the dispatch table associated with the Tag. Called from
158    --  Exp_Disp.Fill_DT_Entry and Exp_Disp.Fill_Secondary_DT_Entry. Used for:
159    --   1) Filling the dispatch table of CPP_Class types.
160    --   2) Late overriding (see Check_Dispatching_Operation).
161    --
162    --  Generates: Tag.D (Position) := Value
163
164    function Build_Set_Size_Function
165      (Loc       : Source_Ptr;
166       Tag_Node  : Node_Id;
167       Size_Func : Entity_Id) return Node_Id;
168    --  Build code that saves in the TSD the address of the function
169    --  calculating _size of the object.
170
171    function Build_Set_Static_Offset_To_Top
172      (Loc          : Source_Ptr;
173       Iface_Tag    : Node_Id;
174       Offset_Value : Node_Id) return Node_Id;
175    --  Build code that initialize the Offset_To_Top component of the
176    --  secondary dispatch table referenced by Iface_Tag.
177    --
178    --  Generates:
179    --    Offset_To_Top_Ptr
180    --      (Address!(Tag_Ptr!(This).all) - Offset_To_Top_Offset).all
181    --     := Offset_Value
182
183 end Exp_Atag;