File indexing completed on 2024-06-16 04:23:16

0001 /*
0002     SPDX-FileCopyrightText: 2002-2005 Roberto Raggi <roberto@kdevelop.org>
0003     SPDX-FileCopyrightText: 2006 Adam Treat <treat@kde.org>
0004     SPDX-FileCopyrightText: 2006-2008 Hamish Rodda <rodda@kde.org>
0005     SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-only
0008 */
0009 
0010 #include "enumeratortype.h"
0011 
0012 #include "typesystemdata.h"
0013 #include "typeregister.h"
0014 
0015 namespace KDevelop {
0016 REGISTER_TYPE(EnumeratorType);
0017 
0018 EnumeratorType::EnumeratorType(const EnumeratorType& rhs)
0019     : EnumeratorTypeBase(copyData<EnumeratorType>(*rhs.d_func()))
0020 {
0021 }
0022 
0023 EnumeratorType::EnumeratorType(EnumeratorTypeData& data)
0024     : EnumeratorTypeBase(data)
0025 {
0026 }
0027 
0028 EnumeratorType::EnumeratorType()
0029     : EnumeratorTypeBase(createData<EnumeratorType>())
0030 {
0031     IntegralType::setDataType(TypeInt);
0032     setModifiers(ConstModifier);
0033 }
0034 
0035 AbstractType* EnumeratorType::clone() const
0036 {
0037     return new EnumeratorType(*this);
0038 }
0039 
0040 bool EnumeratorType::equals(const AbstractType* _rhs) const
0041 {
0042     if (this == _rhs)
0043         return true;
0044 
0045     if (!EnumeratorTypeBase::equals(_rhs))
0046         return false;
0047 
0048     Q_ASSERT(dynamic_cast<const EnumeratorType*>(_rhs));
0049 
0050     // Nothing Enumerator-type specific to compare
0051     return true;
0052 }
0053 
0054 uint EnumeratorType::hash() const
0055 {
0056     return KDevHash(ConstantIntegralType::hash()) << IdentifiedType::hash();
0057 }
0058 
0059 AbstractType::WhichType EnumeratorType::whichType() const
0060 {
0061     return TypeEnumerator;
0062 }
0063 
0064 QString EnumeratorType::toString() const
0065 {
0066     return IdentifiedType::qualifiedIdentifier().toString();
0067 }
0068 }