File indexing completed on 2024-06-16 04:23:17
0001 /* 0002 SPDX-FileCopyrightText: 2009 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #include "typealiastype.h" 0008 #include "typeregister.h" 0009 #include "typesystem.h" 0010 0011 namespace KDevelop { 0012 REGISTER_TYPE(TypeAliasType); 0013 0014 AbstractType* TypeAliasType::clone() const 0015 { 0016 return new TypeAliasType(*this); 0017 } 0018 0019 bool TypeAliasType::equals(const AbstractType* _rhs) const 0020 { 0021 if (this == _rhs) 0022 return true; 0023 0024 if (!AbstractType::equals(_rhs)) { 0025 return false; 0026 } 0027 0028 Q_ASSERT(dynamic_cast<const TypeAliasType*>(_rhs)); 0029 const auto* rhs = static_cast<const TypeAliasType*>(_rhs); 0030 0031 if (!IdentifiedType::equals(rhs)) { 0032 return false; 0033 } 0034 0035 return d_func()->m_type == rhs->d_func()->m_type; 0036 } 0037 AbstractType::Ptr TypeAliasType::type() const 0038 { 0039 return d_func()->m_type.abstractType(); 0040 } 0041 0042 void TypeAliasType::setType(const AbstractType::Ptr& type) 0043 { 0044 d_func_dynamic()->m_type = IndexedType(type); 0045 } 0046 0047 uint TypeAliasType::hash() const 0048 { 0049 return KDevHash(AbstractType::hash()) << IdentifiedType::hash() << d_func()->m_type.hash(); 0050 } 0051 0052 QString TypeAliasType::toString() const 0053 { 0054 QualifiedIdentifier id = qualifiedIdentifier(); 0055 if (!id.isEmpty()) 0056 return AbstractType::toString(false) + id.toString(); 0057 0058 if (type()) 0059 return AbstractType::toString(false) + type()->toString(); 0060 0061 return QStringLiteral("typedef <notype>"); 0062 } 0063 0064 void TypeAliasType::accept0(KDevelop::TypeVisitor* v) const 0065 { 0066 if (v->visit(this)) 0067 acceptType(d_func()->m_type.abstractType(), v); 0068 0069 // v->endVisit (this); 0070 } 0071 0072 KDevelop::AbstractType::WhichType TypeAliasType::whichType() const 0073 { 0074 return TypeAlias; 0075 } 0076 0077 void TypeAliasType::exchangeTypes(KDevelop::TypeExchanger* exchanger) 0078 { 0079 d_func_dynamic()->m_type = IndexedType(exchanger->exchange(d_func()->m_type.abstractType())); 0080 } 0081 }