+bool type_info::is_subclass() const
+{
+ if( typeid(*this) == typeid(::__cxxabiv1::__si_class_type_info) )
+ return true;
+ if( typeid(*this) == typeid(::__cxxabiv1::__vmi_class_type_info) )
+ return true;
+ return false;
+}
+
+// Acess-defined
+bool type_info::__is_child(const type_info &poss_child, size_t &offset) const
+{
+ _SysDebug("typeids = this:%s , poss_child:%s", typeid(*this).name(), typeid(poss_child).name());
+
+ // Check #1: Child is same type
+ if( poss_child == *this ) {
+ offset = 0;
+ return true;
+ }
+
+ // Check #2: This type must be a class
+ if( !this->is_class() ) {
+ return false;
+ }
+ // Check #3: Child class must be a subclass
+ if( !poss_child.is_subclass() ) {
+ return false;
+ }
+
+ if( typeid(poss_child) == typeid(::__cxxabiv1::__si_class_type_info) ) {
+ auto &si_poss_child = reinterpret_cast<const ::__cxxabiv1::__si_class_type_info&>(poss_child);
+ // Single inheritance
+ _SysDebug("type_info::__is_child - Single inheritance");
+ return __is_child( *si_poss_child.__base_type, offset );
+ }
+ else if( typeid(poss_child) == typeid(::__cxxabiv1::__vmi_class_type_info) ) {
+ // Multiple inheritance
+ _SysDebug("TODO: type_info::__is_child - Multiple inheritance");
+ abort();
+ for(;;);
+ }
+ else {
+ // Oops!
+ _SysDebug("ERROR: type_info::__is_child - Reported subclass type, but not a subclass %s",
+ typeid(poss_child).name()
+ );
+ abort();
+ for(;;);
+ }
+}