1 /* 2 This file is part of KDevelop 3 SPDX-FileCopyrightText: 2009 Milian Wolff <mail@milianw.de> 4 5 SPDX-License-Identifier: LGPL-2.0-or-later 6 */ 7 8 #include "integraltypeextended.h" 9 10 #include <language/duchain/types/typeregister.h> 11 12 using namespace KDevelop; 13 14 namespace Php 15 { 16 17 REGISTER_TYPE(IntegralTypeExtended); 18 IntegralTypeExtended(const IntegralTypeExtended & rhs)19IntegralTypeExtended::IntegralTypeExtended(const IntegralTypeExtended& rhs) 20 : IntegralType(copyData<IntegralTypeExtended>(*rhs.d_func())) 21 { 22 } 23 IntegralTypeExtended(IntegralTypeExtendedData & data)24IntegralTypeExtended::IntegralTypeExtended(IntegralTypeExtendedData& data) 25 : IntegralType(data) 26 { 27 } 28 IntegralTypeExtended(uint type)29IntegralTypeExtended::IntegralTypeExtended(uint type) 30 : IntegralType(createData<IntegralTypeExtended>()) 31 { 32 setDataType(type); 33 setModifiers(ConstModifier); 34 } 35 36 toString() const37QString IntegralTypeExtended::toString() const 38 { 39 if ( d_func()->m_dataType == TypeResource ) { 40 return "resource"; 41 } 42 return KDevelop::IntegralType::toString(); 43 } 44 clone() const45KDevelop::AbstractType* IntegralTypeExtended::clone() const 46 { 47 return new IntegralTypeExtended(*this); 48 } 49 hash() const50uint IntegralTypeExtended::hash() const 51 { 52 return 4 * KDevelop::IntegralType::hash(); 53 } 54 equals(const KDevelop::AbstractType * rhs) const55bool IntegralTypeExtended::equals(const KDevelop::AbstractType* rhs) const 56 { 57 if( this == rhs ) { 58 return true; 59 } 60 61 if ( !IntegralType::equals(rhs) ) { 62 return false; 63 } 64 65 Q_ASSERT( fastCast<const IntegralTypeExtended*>(rhs) ); 66 67 const IntegralTypeExtended* type = static_cast<const IntegralTypeExtended*>(rhs); 68 69 return d_func()->m_dataType == type->d_func()->m_dataType; 70 } 71 72 } 73