Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

tinfo2.cc

Go to the documentation of this file.
00001 // Methods for type_info for -*- C++ -*- Run Time Type Identification.
00002 
00003 // Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001 
00004 // Free Software Foundation
00005 //
00006 // This file is part of GNU CC.
00007 //
00008 // GNU CC is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2, or (at your option)
00011 // any later version.
00012 
00013 // GNU CC is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 
00018 // You should have received a copy of the GNU General Public License
00019 // along with GNU CC; see the file COPYING.  If not, write to
00020 // the Free Software Foundation, 59 Temple Place - Suite 330,
00021 // Boston, MA 02111-1307, USA. 
00022 
00023 // As a special exception, you may use this file as part of a free software
00024 // library without restriction.  Specifically, if other files instantiate
00025 // templates or use macros or inline functions from this file, or you compile
00026 // this file and link it with other files to produce an executable, this
00027 // file does not by itself cause the resulting executable to be covered by
00028 // the GNU General Public License.  This exception does not however
00029 // invalidate any other reasons why the executable file might be covered by
00030 // the GNU General Public License.
00031 
00032 #include <cstddef>
00033 #include "tinfo.h"
00034 #include "new"          // for placement new
00035 
00036 // We can't rely on having stdlib.h if we're freestanding.
00037 extern "C" void abort ();
00038 
00039 using std::type_info;
00040 
00041 #if !__GXX_MERGED_TYPEINFO_NAMES
00042 
00043 bool
00044 type_info::before (const type_info &arg) const
00045 {
00046   return __builtin_strcmp (name (), arg.name ()) < 0;
00047 }
00048 
00049 #endif
00050 
00051 #include <cxxabi.h>
00052 
00053 namespace __cxxabiv1 {
00054 
00055 using namespace std;
00056 
00057 // This has special meaning to the compiler, and will cause it
00058 // to emit the type_info structures for the fundamental types which are
00059 // mandated to exist in the runtime.
00060 __fundamental_type_info::
00061 ~__fundamental_type_info ()
00062 {}
00063 
00064 __array_type_info::
00065 ~__array_type_info ()
00066 {}
00067 
00068 __function_type_info::
00069 ~__function_type_info ()
00070 {}
00071 
00072 __enum_type_info::
00073 ~__enum_type_info ()
00074 {}
00075 
00076 __pbase_type_info::
00077 ~__pbase_type_info ()
00078 {}
00079 
00080 __pointer_type_info::
00081 ~__pointer_type_info ()
00082 {}
00083 
00084 __pointer_to_member_type_info::
00085 ~__pointer_to_member_type_info ()
00086 {}
00087 
00088 bool __pointer_type_info::
00089 __is_pointer_p () const
00090 {
00091   return true;
00092 }
00093 
00094 bool __function_type_info::
00095 __is_function_p () const
00096 {
00097   return true;
00098 }
00099 
00100 bool __pbase_type_info::
00101 __do_catch (const type_info *thr_type,
00102             void **thr_obj,
00103             unsigned outer) const
00104 {
00105   if (*this == *thr_type)
00106     return true;      // same type
00107   if (typeid (*this) != typeid (*thr_type))
00108     return false;     // not both same kind of pointers
00109   
00110   if (!(outer & 1))
00111     // We're not the same and our outer pointers are not all const qualified
00112     // Therefore there must at least be a qualification conversion involved
00113     // But for that to be valid, our outer pointers must be const qualified.
00114     return false;
00115   
00116   const __pbase_type_info *thrown_type =
00117     static_cast <const __pbase_type_info *> (thr_type);
00118   
00119   if (thrown_type->__qualifier_flags & ~__qualifier_flags)
00120     // We're less qualified.
00121     return false;
00122   
00123   if (!(__qualifier_flags & __const_mask))
00124     outer &= ~1;
00125   
00126   return __pointer_catch (thrown_type, thr_obj, outer);
00127 }
00128 
00129 inline bool __pbase_type_info::
00130 __pointer_catch (const __pbase_type_info *thrown_type,
00131                  void **thr_obj,
00132                  unsigned outer) const
00133 {
00134   return __pointee->__do_catch (thrown_type->__pointee, thr_obj, outer + 2);
00135 }
00136 
00137 bool __pointer_type_info::
00138 __pointer_catch (const __pbase_type_info *thrown_type,
00139                  void **thr_obj,
00140                  unsigned outer) const
00141 {
00142   if (outer < 2 && *__pointee == typeid (void))
00143     {
00144       // conversion to void
00145       return !thrown_type->__pointee->__is_function_p ();
00146     }
00147   
00148   return __pbase_type_info::__pointer_catch (thrown_type, thr_obj, outer);
00149 }
00150 
00151 bool __pointer_to_member_type_info::
00152 __pointer_catch (const __pbase_type_info *thr_type,
00153                  void **thr_obj,
00154                  unsigned outer) const
00155 {
00156   // This static cast is always valid, as our caller will have determined that
00157   // thr_type is really a __pointer_to_member_type_info.
00158   const __pointer_to_member_type_info *thrown_type =
00159     static_cast <const __pointer_to_member_type_info *> (thr_type);
00160   
00161   if (*__context_class != *thrown_type->__context_class)
00162     return false;     // not pointers to member of same class
00163   
00164   return __pbase_type_info::__pointer_catch (thrown_type, thr_obj, outer);
00165 }
00166 
00167 } // namespace std

Generated at Tue May 1 16:28:40 2001 for libstdc++-v3 by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001