1 // Copyright (C) 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
3 // This file is part of GCC.
5 // GCC is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2, or (at your option)
9 // GCC is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with GCC; see the file COPYING. If not, write to
15 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
16 // Boston, MA 02110-1301, USA.
18 // As a special exception, you may use this file as part of a free software
19 // library without restriction. Specifically, if other files instantiate
20 // templates or use macros or inline functions from this file, or you compile
21 // this file and link it with other files to produce an executable, this
22 // file does not by itself cause the resulting executable to be covered by
23 // the GNU General Public License. This exception does not however
24 // invalidate any other reasons why the executable file might be covered by
25 // the GNU General Public License.
27 // Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com>
35 // Type information for int, float etc.
36 class __fundamental_type_info
: public std::type_info
40 __fundamental_type_info(const char* __n
) : std::type_info(__n
) { }
43 ~__fundamental_type_info();
46 // Type information for array objects.
47 class __array_type_info
: public std::type_info
51 __array_type_info(const char* __n
) : std::type_info(__n
) { }
57 // Type information for functions (both member and non-member).
58 class __function_type_info
: public std::type_info
62 __function_type_info(const char* __n
) : std::type_info(__n
) { }
65 ~__function_type_info();
68 // Implementation defined member function.
70 __is_function_p() const;
73 // Type information for enumerations.
74 class __enum_type_info
: public std::type_info
78 __enum_type_info(const char* __n
) : std::type_info(__n
) { }
84 // Common type information for simple pointers and pointers to member.
85 class __pbase_type_info
: public std::type_info
88 unsigned int __flags
; // Qualification of the target object.
89 const std::type_info
* __pointee
; // Type of pointed to object.
92 __pbase_type_info(const char* __n
, int __quals
,
93 const std::type_info
* __type
)
94 : std::type_info(__n
), __flags(__quals
), __pointee(__type
)
100 // Implementation defined type.
104 __volatile_mask
= 0x2,
105 __restrict_mask
= 0x4,
106 __incomplete_mask
= 0x8,
107 __incomplete_class_mask
= 0x10
111 __pbase_type_info(const __pbase_type_info
&);
114 operator=(const __pbase_type_info
&);
116 // Implementation defined member functions.
118 __do_catch(const std::type_info
* __thr_type
, void** __thr_obj
,
119 unsigned int __outer
) const;
122 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
123 unsigned __outer
) const;
126 // Type information for simple pointers.
127 class __pointer_type_info
: public __pbase_type_info
131 __pointer_type_info(const char* __n
, int __quals
,
132 const std::type_info
* __type
)
133 : __pbase_type_info (__n
, __quals
, __type
) { }
137 ~__pointer_type_info();
140 // Implementation defined member functions.
142 __is_pointer_p() const;
145 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
146 unsigned __outer
) const;
149 class __class_type_info
;
151 // Type information for a pointer to member variable.
152 class __pointer_to_member_type_info
: public __pbase_type_info
155 __class_type_info
* __context
; // Class of the member.
158 __pointer_to_member_type_info(const char* __n
, int __quals
,
159 const std::type_info
* __type
,
160 __class_type_info
* __klass
)
161 : __pbase_type_info(__n
, __quals
, __type
), __context(__klass
) { }
164 ~__pointer_to_member_type_info();
167 __pointer_to_member_type_info(const __pointer_to_member_type_info
&);
169 __pointer_to_member_type_info
&
170 operator=(const __pointer_to_member_type_info
&);
172 // Implementation defined member function.
174 __pointer_catch(const __pbase_type_info
* __thr_type
, void** __thr_obj
,
175 unsigned __outer
) const;
178 // Helper class for __vmi_class_type.
179 class __base_class_type_info
182 const __class_type_info
* __base_type
; // Base class type.
183 long __offset_flags
; // Offset and info.
185 enum __offset_flags_masks
187 __virtual_mask
= 0x1,
190 __offset_shift
= 8 // Bits to shift offset.
193 // Implementation defined member functions.
195 __is_virtual_p() const
196 { return __offset_flags
& __virtual_mask
; }
199 __is_public_p() const
200 { return __offset_flags
& __public_mask
; }
205 // This shift, being of a signed type, is implementation
206 // defined. GCC implements such shifts as arithmetic, which is
208 return static_cast<ptrdiff_t>(__offset_flags
) >> __offset_shift
;
212 // Type information for a class.
213 class __class_type_info
: public std::type_info
217 __class_type_info (const char *__n
) : type_info(__n
) { }
220 ~__class_type_info ();
222 // Implementation defined types.
223 // The type sub_kind tells us about how a base object is contained
224 // within a derived object. We often do this lazily, hence the
225 // UNKNOWN value. At other times we may use NOT_CONTAINED to mean
226 // not publicly contained.
232 // Not contained within us (in some circumstances this might
233 // mean not contained publicly)
236 // Contained ambiguously.
239 // Via a virtual path.
240 __contained_virtual_mask
= __base_class_type_info::__virtual_mask
,
242 // Via a public path.
243 __contained_public_mask
= __base_class_type_info::__public_mask
,
245 // Contained within us.
246 __contained_mask
= 1 << __base_class_type_info::__hwm_bit
,
248 __contained_private
= __contained_mask
,
249 __contained_public
= __contained_mask
| __contained_public_mask
252 struct __upcast_result
;
253 struct __dyncast_result
;
256 // Implementation defined member functions.
258 __do_upcast(const __class_type_info
* __dst_type
, void**__obj_ptr
) const;
261 __do_catch(const type_info
* __thr_type
, void** __thr_obj
,
262 unsigned __outer
) const;
265 // Helper for upcast. See if DST is us, or one of our bases.
266 // Return false if not found, true if found.
268 __do_upcast(const __class_type_info
* __dst
, const void* __obj
,
269 __upcast_result
& __restrict __result
) const;
271 // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly
272 // within OBJ_PTR. OBJ_PTR points to a base object of our type,
273 // which is the destination type. SRC2DST indicates how SRC
274 // objects might be contained within this type. If SRC_PTR is one
275 // of our SRC_TYPE bases, indicate the virtuality. Returns
276 // not_contained for non containment or private containment.
278 __find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
279 const __class_type_info
* __src_type
,
280 const void* __src_ptr
) const;
282 // Helper for dynamic cast. ACCESS_PATH gives the access from the
283 // most derived object to this base. DST_TYPE indicates the
284 // desired type we want. OBJ_PTR points to a base of our type
285 // within the complete object. SRC_TYPE indicates the static type
286 // started from and SRC_PTR points to that base within the most
287 // derived object. Fill in RESULT with what we find. Return true
288 // if we have located an ambiguous match.
290 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
291 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
292 const __class_type_info
* __src_type
, const void* __src_ptr
,
293 __dyncast_result
& __result
) const;
295 // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE
296 // bases are inherited by the type started from -- which is not
297 // necessarily the current type. The current type will be a base
298 // of the destination type. OBJ_PTR points to the current base.
300 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
301 const __class_type_info
* __src_type
,
302 const void* __src_ptr
) const;
305 // Type information for a class with a single non-virtual base.
306 class __si_class_type_info
: public __class_type_info
309 const __class_type_info
* __base_type
;
312 __si_class_type_info(const char *__n
, const __class_type_info
*__base
)
313 : __class_type_info(__n
), __base_type(__base
) { }
316 ~__si_class_type_info();
319 __si_class_type_info(const __si_class_type_info
&);
321 __si_class_type_info
&
322 operator=(const __si_class_type_info
&);
324 // Implementation defined member functions.
326 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
327 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
328 const __class_type_info
* __src_type
, const void* __src_ptr
,
329 __dyncast_result
& __result
) const;
332 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
333 const __class_type_info
* __src_type
,
334 const void* __sub_ptr
) const;
337 __do_upcast(const __class_type_info
*__dst
, const void*__obj
,
338 __upcast_result
& __restrict __result
) const;
341 // Type information for a class with multiple and/or virtual bases.
342 class __vmi_class_type_info
: public __class_type_info
345 unsigned int __flags
; // Details about the class hierarchy.
346 unsigned int __base_count
; // Number of direct bases.
348 // The array of bases uses the trailing array struct hack so this
349 // class is not constructable with a normal constructor. It is
350 // internally generated by the compiler.
351 __base_class_type_info __base_info
[1]; // Array of bases.
354 __vmi_class_type_info(const char* __n
, int ___flags
)
355 : __class_type_info(__n
), __flags(___flags
), __base_count(0) { }
358 ~__vmi_class_type_info();
360 // Implementation defined types.
363 __non_diamond_repeat_mask
= 0x1, // Distinct instance of repeated base.
364 __diamond_shaped_mask
= 0x2, // Diamond shaped multiple inheritance.
365 __flags_unknown_mask
= 0x10
369 // Implementation defined member functions.
371 __do_dyncast(ptrdiff_t __src2dst
, __sub_kind __access_path
,
372 const __class_type_info
* __dst_type
, const void* __obj_ptr
,
373 const __class_type_info
* __src_type
, const void* __src_ptr
,
374 __dyncast_result
& __result
) const;
377 __do_find_public_src(ptrdiff_t __src2dst
, const void* __obj_ptr
,
378 const __class_type_info
* __src_type
,
379 const void* __src_ptr
) const;
382 __do_upcast(const __class_type_info
* __dst
, const void* __obj
,
383 __upcast_result
& __restrict __result
) const;
386 // Dynamic cast runtime.
387 // src2dst has the following possible values
388 // >-1: src_type is a unique public non-virtual base of dst_type
389 // dst_ptr + src2dst == src_ptr
390 // -1: unspecified relationship
391 // -2: src_type is not a public base of dst_type
392 // -3: src_type is a multiple public non-virtual base of dst_type
394 __dynamic_cast(const void* __src_ptr
, // Starting object.
395 const __class_type_info
* __src_type
, // Static type of object.
396 const __class_type_info
* __dst_type
, // Desired target type.
397 ptrdiff_t __src2dst
); // How src and dst are related.
400 // Returns the type_info for the currently handled exception [15.3/8], or
401 // null if there is none.
402 extern "C" std::type_info
*
403 __cxa_current_exception_type();
404 } // namespace __cxxabiv1
406 // User programs should use the alias `abi'.
407 namespace abi
= __cxxabiv1
;