]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/libsupc++/class_type_info.cc
Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[thirdparty/gcc.git] / libstdc++-v3 / libsupc++ / class_type_info.cc
CommitLineData
748086b7
JJ
1// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2007,
2// 2009 Free Software Foundation
bd994a48
MM
3//
4// This file is part of GCC.
5//
6// GCC is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
748086b7 8// the Free Software Foundation; either version 3, or (at your option)
bd994a48
MM
9// any later version.
10
11// GCC is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
748086b7
JJ
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
bd994a48 19
748086b7
JJ
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
bd994a48
MM
24
25#include "tinfo.h"
26
27namespace __cxxabiv1 {
28
29__class_type_info::
30~__class_type_info ()
31{}
32
33bool __class_type_info::
34__do_catch (const type_info *thr_type,
35 void **thr_obj,
36 unsigned outer) const
37{
38 if (*this == *thr_type)
39 return true;
40 if (outer >= 4)
41 // Neither `A' nor `A *'.
42 return false;
43 return thr_type->__do_upcast (this, thr_obj);
44}
45
46bool __class_type_info::
47__do_upcast (const __class_type_info *dst_type,
48 void **obj_ptr) const
49{
50 __upcast_result result (__vmi_class_type_info::__flags_unknown_mask);
51
52 __do_upcast (dst_type, *obj_ptr, result);
53 if (!contained_public_p (result.part2dst))
54 return false;
55 *obj_ptr = const_cast <void *> (result.dst_ptr);
56 return true;
57}
58
59__class_type_info::__sub_kind __class_type_info::
60__do_find_public_src (ptrdiff_t,
61 const void *obj_ptr,
62 const __class_type_info *,
63 const void *src_ptr) const
64{
65 if (src_ptr == obj_ptr)
66 // Must be our type, as the pointers match.
67 return __contained_public;
68 return __not_contained;
69}
70
71bool __class_type_info::
72__do_dyncast (ptrdiff_t,
73 __sub_kind access_path,
74 const __class_type_info *dst_type,
75 const void *obj_ptr,
76 const __class_type_info *src_type,
77 const void *src_ptr,
78 __dyncast_result &__restrict result) const
79{
80 if (obj_ptr == src_ptr && *this == *src_type)
81 {
82 // The src object we started from. Indicate how we are accessible from
83 // the most derived object.
84 result.whole2src = access_path;
85 return false;
86 }
87 if (*this == *dst_type)
88 {
89 result.dst_ptr = obj_ptr;
90 result.whole2dst = access_path;
91 result.dst2src = __not_contained;
92 return false;
93 }
94 return false;
95}
96
97bool __class_type_info::
98__do_upcast (const __class_type_info *dst, const void *obj,
99 __upcast_result &__restrict result) const
100{
101 if (*this == *dst)
102 {
103 result.dst_ptr = obj;
104 result.base_type = nonvirtual_base_type;
105 result.part2dst = __contained_public;
106 return true;
107 }
108 return false;
109}
110
111}