| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#include "typeinfo" |
| 26 |
#include <cstddef> |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#include <cxxabi.h> |
| 31 |
|
| 32 |
namespace __cxxabiv1 { |
| 33 |
|
| 34 |
namespace { |
| 35 |
|
| 36 |
using namespace std; |
| 37 |
using namespace abi; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
struct vtable_prefix |
| 42 |
{ |
| 43 |
|
| 44 |
ptrdiff_t whole_object; |
| 45 |
|
| 46 |
|
| 47 |
#ifdef _GLIBCXX_VTABLE_PADDING |
| 48 |
ptrdiff_t padding1; |
| 49 |
#endif |
| 50 |
|
| 51 |
|
| 52 |
const __class_type_info *whole_type; |
| 53 |
|
| 54 |
|
| 55 |
#ifdef _GLIBCXX_VTABLE_PADDING |
| 56 |
ptrdiff_t padding2; |
| 57 |
#endif |
| 58 |
|
| 59 |
|
| 60 |
const void *origin; |
| 61 |
}; |
| 62 |
|
| 63 |
template <typename T> |
| 64 |
inline const T * |
| 65 |
adjust_pointer (const void *base, ptrdiff_t offset) |
| 66 |
{ |
| 67 |
return reinterpret_cast <const T *> |
| 68 |
(reinterpret_cast <const char *> (base) + offset); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
inline void const * |
| 74 |
convert_to_base (void const *addr, bool is_virtual, ptrdiff_t offset) |
| 75 |
{ |
| 76 |
if (is_virtual) |
| 77 |
{ |
| 78 |
const void *vtable = *static_cast <const void *const *> (addr); |
| 79 |
|
| 80 |
offset = *adjust_pointer<ptrdiff_t> (vtable, offset); |
| 81 |
} |
| 82 |
|
| 83 |
return adjust_pointer<void> (addr, offset); |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
inline bool contained_p (__class_type_info::__sub_kind access_path) |
| 88 |
{ |
| 89 |
return access_path >= __class_type_info::__contained_mask; |
| 90 |
} |
| 91 |
inline bool public_p (__class_type_info::__sub_kind access_path) |
| 92 |
{ |
| 93 |
return access_path & __class_type_info::__contained_public_mask; |
| 94 |
} |
| 95 |
inline bool virtual_p (__class_type_info::__sub_kind access_path) |
| 96 |
{ |
| 97 |
return (access_path & __class_type_info::__contained_virtual_mask); |
| 98 |
} |
| 99 |
inline bool contained_public_p (__class_type_info::__sub_kind access_path) |
| 100 |
{ |
| 101 |
return ((access_path & __class_type_info::__contained_public) |
| 102 |
== __class_type_info::__contained_public); |
| 103 |
} |
| 104 |
inline bool contained_nonpublic_p (__class_type_info::__sub_kind access_path) |
| 105 |
{ |
| 106 |
return ((access_path & __class_type_info::__contained_public) |
| 107 |
== __class_type_info::__contained_mask); |
| 108 |
} |
| 109 |
inline bool contained_nonvirtual_p (__class_type_info::__sub_kind access_path) |
| 110 |
{ |
| 111 |
return ((access_path & (__class_type_info::__contained_mask |
| 112 |
| __class_type_info::__contained_virtual_mask)) |
| 113 |
== __class_type_info::__contained_mask); |
| 114 |
} |
| 115 |
|
| 116 |
static const __class_type_info *const nonvirtual_base_type = |
| 117 |
static_cast <const __class_type_info *> (0) + 1; |
| 118 |
|
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
struct __class_type_info::__upcast_result |
| 124 |
{ |
| 125 |
const void *dst_ptr; |
| 126 |
__sub_kind part2dst; |
| 127 |
int src_details; |
| 128 |
const __class_type_info *base_type; |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
__upcast_result (int d) |
| 133 |
:dst_ptr (NULL), part2dst (__unknown), src_details (d), base_type (NULL) |
| 134 |
{} |
| 135 |
}; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
struct __class_type_info::__dyncast_result |
| 140 |
{ |
| 141 |
const void *dst_ptr; |
| 142 |
__sub_kind whole2dst; |
| 143 |
__sub_kind whole2src; |
| 144 |
__sub_kind dst2src; |
| 145 |
int whole_details; |
| 146 |
|
| 147 |
__dyncast_result (int details_ = __vmi_class_type_info::__flags_unknown_mask) |
| 148 |
:dst_ptr (NULL), whole2dst (__unknown), |
| 149 |
whole2src (__unknown), dst2src (__unknown), |
| 150 |
whole_details (details_) |
| 151 |
{} |
| 152 |
|
| 153 |
protected: |
| 154 |
__dyncast_result(const __dyncast_result&); |
| 155 |
|
| 156 |
__dyncast_result& |
| 157 |
operator=(const __dyncast_result&); |
| 158 |
}; |
| 159 |
|
| 160 |
inline __class_type_info::__sub_kind __class_type_info:: |
| 161 |
__find_public_src (ptrdiff_t src2dst, |
| 162 |
const void *obj_ptr, |
| 163 |
const __class_type_info *src_type, |
| 164 |
const void *src_ptr) const |
| 165 |
{ |
| 166 |
if (src2dst >= 0) |
| 167 |
return adjust_pointer <void> (obj_ptr, src2dst) == src_ptr |
| 168 |
? __contained_public : __not_contained; |
| 169 |
if (src2dst == -2) |
| 170 |
return __not_contained; |
| 171 |
return __do_find_public_src (src2dst, obj_ptr, src_type, src_ptr); |
| 172 |
} |
| 173 |
|
| 174 |
} |