Mark ChangeLog
[official-gcc.git] / gcc / ada / i-cpp-vms.adb
bloba0a8a49962ebab376e5134662273d3a873d08f9d
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- I N T E R F A C E S . C P P --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2000-2004, 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 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This is the OpenVMS/Alpha DEC C++ (cxx) version of this package
36 with Ada.Tags; use Ada.Tags;
37 with System; use System;
38 with System.Storage_Elements; use System.Storage_Elements;
39 with Unchecked_Conversion;
41 package body Interfaces.CPP is
43 subtype Cstring is String (Positive);
44 type Cstring_Ptr is access all Cstring;
45 type Tag_Table is array (Natural range <>) of Vtable_Ptr;
46 pragma Suppress_Initialization (Tag_Table);
48 type Type_Specific_Data is record
49 Idepth : Natural;
50 Expanded_Name : Cstring_Ptr;
51 External_Tag : Cstring_Ptr;
52 HT_Link : Tag;
53 Ancestor_Tags : Tag_Table (Natural);
54 end record;
56 type Vtable_Entry is record
57 Pfn : System.Address;
58 end record;
60 type Type_Specific_Data_Ptr is access all Type_Specific_Data;
61 type Vtable_Entry_Array is array (Positive range <>) of Vtable_Entry;
63 type VTable is record
64 Prims_Ptr : Vtable_Entry_Array (Positive);
65 TSD : Type_Specific_Data_Ptr;
66 -- Location of TSD is unknown so it got moved here to be out of the
67 -- way of Prims_Ptr. Find it later. ???
68 end record;
70 --------------------------------------------------------
71 -- Unchecked Conversions for Tag, Vtable_Ptr, and TSD --
72 --------------------------------------------------------
74 function To_Type_Specific_Data_Ptr is
75 new Unchecked_Conversion (Address, Type_Specific_Data_Ptr);
77 function To_Address is
78 new Unchecked_Conversion (Type_Specific_Data_Ptr, Address);
80 ---------------------------------------------
81 -- Unchecked Conversions for String Fields --
82 ---------------------------------------------
84 function To_Cstring_Ptr is
85 new Unchecked_Conversion (Address, Cstring_Ptr);
87 function To_Address is
88 new Unchecked_Conversion (Cstring_Ptr, Address);
90 -----------------------
91 -- Local Subprograms --
92 -----------------------
94 function Length (Str : Cstring_Ptr) return Natural;
95 -- Length of string represented by the given pointer (treating the
96 -- string as a C-style string, which is Nul terminated).
98 --------------------
99 -- Displaced_This --
100 --------------------
102 function Displaced_This
103 (Current_This : System.Address;
104 Vptr : Vtable_Ptr;
105 Position : Positive) return System.Address
107 pragma Warnings (Off, Vptr);
108 pragma Warnings (Off, Position);
109 begin
110 return Current_This;
111 -- + Storage_Offset (Vptr.Prims_Ptr (Position).Delta1);
112 -- why is above line commented out ???
113 end Displaced_This;
115 -----------------------
116 -- CPP_CW_Membership --
117 -----------------------
119 function CPP_CW_Membership
120 (Obj_Tag : Vtable_Ptr;
121 Typ_Tag : Vtable_Ptr) return Boolean
123 Pos : constant Integer := Obj_Tag.TSD.Idepth - Typ_Tag.TSD.Idepth;
124 begin
125 return Pos >= 0 and then Obj_Tag.TSD.Ancestor_Tags (Pos) = Typ_Tag;
126 end CPP_CW_Membership;
128 ---------------------------
129 -- CPP_Get_Expanded_Name --
130 ---------------------------
132 function CPP_Get_Expanded_Name (T : Vtable_Ptr) return Address is
133 begin
134 return To_Address (T.TSD.Expanded_Name);
135 end CPP_Get_Expanded_Name;
137 --------------------------
138 -- CPP_Get_External_Tag --
139 --------------------------
141 function CPP_Get_External_Tag (T : Vtable_Ptr) return Address is
142 begin
143 return To_Address (T.TSD.External_Tag);
144 end CPP_Get_External_Tag;
146 -------------------------------
147 -- CPP_Get_Inheritance_Depth --
148 -------------------------------
150 function CPP_Get_Inheritance_Depth (T : Vtable_Ptr) return Natural is
151 begin
152 return T.TSD.Idepth;
153 end CPP_Get_Inheritance_Depth;
155 -----------------------
156 -- CPP_Get_RC_Offset --
157 -----------------------
159 function CPP_Get_RC_Offset (T : Vtable_Ptr) return SSE.Storage_Offset is
160 pragma Warnings (Off, T);
161 begin
162 return 0;
163 end CPP_Get_RC_Offset;
165 -----------------------------
166 -- CPP_Get_Prim_Op_Address --
167 -----------------------------
169 function CPP_Get_Prim_Op_Address
170 (T : Vtable_Ptr;
171 Position : Positive) return Address
173 begin
174 return T.Prims_Ptr (Position).Pfn;
175 end CPP_Get_Prim_Op_Address;
177 -------------------------------
178 -- CPP_Get_Remotely_Callable --
179 -------------------------------
181 function CPP_Get_Remotely_Callable (T : Vtable_Ptr) return Boolean is
182 pragma Warnings (Off, T);
183 begin
184 return True;
185 end CPP_Get_Remotely_Callable;
187 -----------------
188 -- CPP_Get_TSD --
189 -----------------
191 function CPP_Get_TSD (T : Vtable_Ptr) return Address is
192 begin
193 return To_Address (T.TSD);
194 end CPP_Get_TSD;
196 --------------------
197 -- CPP_Inherit_DT --
198 --------------------
200 procedure CPP_Inherit_DT
201 (Old_T : Vtable_Ptr;
202 New_T : Vtable_Ptr;
203 Entry_Count : Natural)
205 begin
206 if Old_T /= null then
207 New_T.Prims_Ptr (1 .. Entry_Count) :=
208 Old_T.Prims_Ptr (1 .. Entry_Count);
209 end if;
210 end CPP_Inherit_DT;
212 ---------------------
213 -- CPP_Inherit_TSD --
214 ---------------------
216 procedure CPP_Inherit_TSD
217 (Old_TSD : Address;
218 New_Tag : Vtable_Ptr)
220 TSD : constant Type_Specific_Data_Ptr :=
221 To_Type_Specific_Data_Ptr (Old_TSD);
223 New_TSD : Type_Specific_Data renames New_Tag.TSD.all;
225 begin
226 if TSD /= null then
227 New_TSD.Idepth := TSD.Idepth + 1;
228 New_TSD.Ancestor_Tags (1 .. New_TSD.Idepth)
229 := TSD.Ancestor_Tags (0 .. TSD.Idepth);
230 else
231 New_TSD.Idepth := 0;
232 end if;
234 New_TSD.Ancestor_Tags (0) := New_Tag;
235 end CPP_Inherit_TSD;
237 ---------------------------
238 -- CPP_Set_Expanded_Name --
239 ---------------------------
241 procedure CPP_Set_Expanded_Name (T : Vtable_Ptr; Value : Address) is
242 begin
243 T.TSD.Expanded_Name := To_Cstring_Ptr (Value);
244 end CPP_Set_Expanded_Name;
246 --------------------------
247 -- CPP_Set_External_Tag --
248 --------------------------
250 procedure CPP_Set_External_Tag (T : Vtable_Ptr; Value : Address) is
251 begin
252 T.TSD.External_Tag := To_Cstring_Ptr (Value);
253 end CPP_Set_External_Tag;
255 -------------------------------
256 -- CPP_Set_Inheritance_Depth --
257 -------------------------------
259 procedure CPP_Set_Inheritance_Depth
260 (T : Vtable_Ptr;
261 Value : Natural)
263 begin
264 T.TSD.Idepth := Value;
265 end CPP_Set_Inheritance_Depth;
267 -----------------------------
268 -- CPP_Set_Prim_Op_Address --
269 -----------------------------
271 procedure CPP_Set_Prim_Op_Address
272 (T : Vtable_Ptr;
273 Position : Positive;
274 Value : Address)
276 begin
277 T.Prims_Ptr (Position).Pfn := Value;
278 end CPP_Set_Prim_Op_Address;
280 -----------------------
281 -- CPP_Set_RC_Offset --
282 -----------------------
284 procedure CPP_Set_RC_Offset (T : Vtable_Ptr; Value : SSE.Storage_Offset) is
285 pragma Warnings (Off, T);
286 pragma Warnings (Off, Value);
287 begin
288 null;
289 end CPP_Set_RC_Offset;
291 -------------------------------
292 -- CPP_Set_Remotely_Callable --
293 -------------------------------
295 procedure CPP_Set_Remotely_Callable (T : Vtable_Ptr; Value : Boolean) is
296 pragma Warnings (Off, T);
297 pragma Warnings (Off, Value);
298 begin
299 null;
300 end CPP_Set_Remotely_Callable;
302 -----------------
303 -- CPP_Set_TSD --
304 -----------------
306 procedure CPP_Set_TSD (T : Vtable_Ptr; Value : Address) is
307 begin
308 T.TSD := To_Type_Specific_Data_Ptr (Value);
309 end CPP_Set_TSD;
311 -------------------
312 -- Expanded_Name --
313 -------------------
315 function Expanded_Name (T : Vtable_Ptr) return String is
316 Result : constant Cstring_Ptr := T.TSD.Expanded_Name;
317 begin
318 return Result (1 .. Length (Result));
319 end Expanded_Name;
321 ------------------
322 -- External_Tag --
323 ------------------
325 function External_Tag (T : Vtable_Ptr) return String is
326 Result : constant Cstring_Ptr := T.TSD.External_Tag;
327 begin
328 return Result (1 .. Length (Result));
329 end External_Tag;
331 ------------
332 -- Length --
333 ------------
335 function Length (Str : Cstring_Ptr) return Natural is
336 Len : Integer := 1;
338 begin
339 while Str (Len) /= ASCII.Nul loop
340 Len := Len + 1;
341 end loop;
343 return Len - 1;
344 end Length;
346 end Interfaces.CPP;