1
/* This file is part of KDevelop
2
Copyright 2002-2005 Roberto Raggi <roberto@kdevelop.org>
3
Copyright 2006 Adam Treat <treat@kde.org>
4
Copyright 2006 Hamish Rodda <rodda@kde.org>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License version 2 as published by the Free Software Foundation.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
Boston, MA 02110-1301, USA.
23
#include <language/duchain/classfunctiondeclaration.h>
24
#include <language/duchain/abstractfunctiondeclaration.h>
25
#include <language/duchain/indexedstring.h>
26
#include <language/duchain/types/typeregister.h>
27
#include "templateparameterdeclaration.h"
28
#include <language/duchain/ducontext.h> //Only for FOREACH_ARRAY
29
#include "templatedeclaration.h"
31
using namespace KDevelop;
33
//Because all these classes have no d-pointers, shallow copies are perfectly fine
35
REGISTER_TYPE(CppClassType);
36
REGISTER_TYPE(CppTemplateParameterType);
38
AbstractType* CppClassType::clone() const {
39
return new CppClassType(*this);
42
CppClassType::CppClassType() : KDevelop::StructureType(createData<CppClassType>()) {
45
uint CppClassType::hash() const
47
return 3 * StructureType::hash();
50
QString CppClassType::toString() const
52
QualifiedIdentifier id = qualifiedIdentifier();
54
if(declarationId().specialization().index())
55
return AbstractType::toString() + Cpp::IndexedInstantiationInformation(declarationId().specialization()).information().applyToIdentifier(id).toString();
57
return AbstractType::toString() + id.toString();
60
//This path usually is not taken
61
QString type = "class";
63
return QString("<%1>%2").arg(type).arg(AbstractType::toString(true));
67
bool moreExpressiveThan(IntegralType* lhs, IntegralType* rhs) {
68
bool ret = lhs->dataType() > rhs->dataType() && !((rhs->modifiers() & AbstractType::SignedModifier) && !(lhs->modifiers() & AbstractType::SignedModifier));
69
if((rhs->modifiers() & AbstractType::LongLongModifier) && !(lhs->modifiers() & AbstractType::LongLongModifier))
71
if((rhs->modifiers() & AbstractType::LongModifier) && !(lhs->modifiers() & AbstractType::LongLongModifier) && !(lhs->modifiers() & AbstractType::LongModifier))
76
AbstractType* CppTemplateParameterType::clone() const {
77
return new CppTemplateParameterType(*this);
80
bool CppTemplateParameterType::equals(const AbstractType* _rhs) const
82
if( !fastCast<const CppTemplateParameterType*>(_rhs))
84
const CppTemplateParameterType* rhs = static_cast<const CppTemplateParameterType*>(_rhs);
89
return IdentifiedType::equals(rhs) && AbstractType::equals(rhs);
92
TemplateParameterDeclaration* CppTemplateParameterType::declaration(const TopDUContext* top) const {
93
return static_cast<TemplateParameterDeclaration*>(IdentifiedType::declaration(top));
96
QString CppTemplateParameterType::toString() const {
97
return AbstractType::toString(false) + "<template> " + IdentifiedType::qualifiedIdentifier().toString();
100
void CppTemplateParameterType::accept0 (KDevelop::TypeVisitor *v) const {
102
/* v->endVisit(this);*/
105
uint CppTemplateParameterType::hash() const {
106
return 41*IdentifiedType::hash() + AbstractType::hash();