Пример #1
0
bool InheritsFrom(clang::CXXRecordDecl *declaration, clang::ASTContext* context, const char* parent) {
	for (const auto& base : declaration->bases()) {
        // See all the written parents (bases) of the class
		clang::QualType base_type = context->getCanonicalType(base.getType());
		if (base_type.getBaseTypeIdentifier() != nullptr && base_type.getBaseTypeIdentifier()->getName() == parent) // Ok if directly inherits
			return true;
		if (InheritsFrom(base_type, context, parent)) // Ok if inherits of a descendent
			return true;
	}
	return false;
}
Пример #2
0
STDMETHODIMP_(BOOL) CDolphinSmalltalk::IsKindOf(Oop objectPointer, const POTE classPointer)
{
	POTE behaviorPointer = FetchClassOf(objectPointer);
	return InheritsFrom(behaviorPointer, classPointer);
}