PR ada/18819
[official-gcc.git] / gcc / ada / exp_sel.adb
blobdbb7fb290865f13bd7ac51820eaab3ec19544139
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E X P _ S E L --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2005, 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 ------------------------------------------------------------------------------
27 with Einfo; use Einfo;
28 with Nlists; use Nlists;
29 with Nmake; use Nmake;
30 with Rtsfind; use Rtsfind;
31 with Stand; use Stand;
32 with Tbuild; use Tbuild;
34 package body Exp_Sel is
36 -----------------------
37 -- Build_Abort_Block --
38 -----------------------
40 function Build_Abort_Block
41 (Loc : Source_Ptr;
42 Abr_Blk_Ent : Entity_Id;
43 Cln_Blk_Ent : Entity_Id;
44 Blk : Node_Id) return Node_Id
46 begin
47 return
48 Make_Block_Statement (Loc,
49 Identifier => New_Reference_To (Abr_Blk_Ent, Loc),
51 Declarations => No_List,
53 Handled_Statement_Sequence =>
54 Make_Handled_Sequence_Of_Statements (Loc,
55 Statements =>
56 New_List (
57 Make_Implicit_Label_Declaration (Loc,
58 Defining_Identifier =>
59 Cln_Blk_Ent,
60 Label_Construct =>
61 Blk),
62 Blk),
64 Exception_Handlers =>
65 New_List (
66 Make_Exception_Handler (Loc,
67 Exception_Choices =>
68 New_List (
69 New_Reference_To (Stand.Abort_Signal, Loc)),
70 Statements =>
71 New_List (
72 Make_Procedure_Call_Statement (Loc,
73 Name =>
74 New_Reference_To (RTE (
75 RE_Abort_Undefer), Loc),
76 Parameter_Associations => No_List))))));
77 end Build_Abort_Block;
79 -------------
80 -- Build_B --
81 -------------
83 function Build_B
84 (Loc : Source_Ptr;
85 Decls : List_Id) return Entity_Id
87 B : constant Entity_Id := Make_Defining_Identifier (Loc,
88 Chars => New_Internal_Name ('B'));
90 begin
91 Append_To (Decls,
92 Make_Object_Declaration (Loc,
93 Defining_Identifier =>
95 Object_Definition =>
96 New_Reference_To (Standard_Boolean, Loc),
97 Expression =>
98 New_Reference_To (Standard_False, Loc)));
100 return B;
101 end Build_B;
103 -------------
104 -- Build_C --
105 -------------
107 function Build_C
108 (Loc : Source_Ptr;
109 Decls : List_Id) return Entity_Id
111 C : constant Entity_Id := Make_Defining_Identifier (Loc,
112 Chars => New_Internal_Name ('C'));
114 begin
115 Append_To (Decls,
116 Make_Object_Declaration (Loc,
117 Defining_Identifier =>
119 Object_Definition =>
120 New_Reference_To (RTE (RE_Prim_Op_Kind), Loc)));
122 return C;
123 end Build_C;
125 -------------------------
126 -- Build_Cleanup_Block --
127 -------------------------
129 function Build_Cleanup_Block
130 (Loc : Source_Ptr;
131 Blk_Ent : Entity_Id;
132 Stmts : List_Id;
133 Clean_Ent : Entity_Id) return Node_Id
135 Cleanup_Block : constant Node_Id :=
136 Make_Block_Statement (Loc,
137 Identifier => New_Reference_To (Blk_Ent, Loc),
138 Declarations => No_List,
139 Handled_Statement_Sequence =>
140 Make_Handled_Sequence_Of_Statements (Loc,
141 Statements => Stmts),
142 Is_Asynchronous_Call_Block => True);
144 begin
145 Set_Entry_Cancel_Parameter (Blk_Ent, Clean_Ent);
147 return Cleanup_Block;
148 end Build_Cleanup_Block;
150 -------------
151 -- Build_K --
152 -------------
154 function Build_K
155 (Loc : Source_Ptr;
156 Decls : List_Id;
157 Obj : Entity_Id) return Entity_Id
159 K : constant Entity_Id := Make_Defining_Identifier (Loc,
160 Chars => New_Internal_Name ('K'));
162 begin
163 Append_To (Decls,
164 Make_Object_Declaration (Loc,
165 Defining_Identifier => K,
166 Object_Definition =>
167 New_Reference_To (RTE (RE_Tagged_Kind), Loc),
168 Expression =>
169 Make_Function_Call (Loc,
170 Name => New_Reference_To (RTE (RE_Get_Tagged_Kind), Loc),
171 Parameter_Associations => New_List (
172 Unchecked_Convert_To (RTE (RE_Tag), Obj)))));
174 return K;
175 end Build_K;
177 -------------
178 -- Build_S --
179 -------------
181 function Build_S
182 (Loc : Source_Ptr;
183 Decls : List_Id) return Entity_Id
185 S : constant Entity_Id := Make_Defining_Identifier (Loc,
186 Chars => New_Internal_Name ('S'));
188 begin
189 Append_To (Decls,
190 Make_Object_Declaration (Loc,
191 Defining_Identifier => S,
192 Object_Definition =>
193 New_Reference_To (Standard_Integer, Loc)));
195 return S;
196 end Build_S;
198 ------------------------
199 -- Build_S_Assignment --
200 ------------------------
202 function Build_S_Assignment
203 (Loc : Source_Ptr;
204 S : Entity_Id;
205 Obj : Entity_Id;
206 Call_Ent : Entity_Id) return Node_Id
208 begin
209 return
210 Make_Assignment_Statement (Loc,
211 Name => New_Reference_To (S, Loc),
212 Expression =>
213 Make_Function_Call (Loc,
214 Name => New_Reference_To (RTE (RE_Get_Offset_Index), Loc),
215 Parameter_Associations => New_List (
216 Unchecked_Convert_To (RTE (RE_Tag), Obj),
217 Make_Integer_Literal (Loc, DT_Position (Call_Ent)))));
218 end Build_S_Assignment;
220 end Exp_Sel;