• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

language/duchain

arraytype.cpp

00001 /* This file is part of KDevelop
00002     Copyright 2006 Roberto Raggi <roberto@kdevelop.org>
00003     Copyright 2006-2008 Hamish Rodda <rodda@kde.org>
00004     Copyright 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "arraytype.h"
00022 
00023 #include "../indexedstring.h"
00024 #include "../repositories/typerepository.h"
00025 #include "typesystemdata.h"
00026 #include "typeregister.h"
00027 #include "typesystem.h"
00028 
00029 namespace KDevelop
00030 {
00031 
00032 REGISTER_TYPE(ArrayType);
00033 
00034 ArrayType::ArrayType(const ArrayType& rhs) : AbstractType(copyData<ArrayType>(*rhs.d_func())) {
00035 }
00036 
00037 ArrayType::ArrayType(ArrayTypeData& data) : AbstractType(data) {
00038 }
00039 
00040 AbstractType* ArrayType::clone() const {
00041   return new ArrayType(*this);
00042 }
00043 
00044 bool ArrayType::equals(const AbstractType* _rhs) const
00045 {
00046   if (!AbstractType::equals(_rhs))
00047     return false;
00048 
00049   Q_ASSERT(fastCast<const ArrayType*>(_rhs));
00050 
00051   const ArrayType* rhs = static_cast<const ArrayType*>(_rhs);
00052 
00053   TYPE_D(ArrayType);
00054   if( d->m_dimension != rhs->d_func()->m_dimension )
00055     return false;
00056 
00057   return d->m_elementType == rhs->d_func()->m_elementType;
00058 }
00059 
00060 ArrayType::ArrayType()
00061   : AbstractType(createData<ArrayType>())
00062 {
00063 }
00064 
00065 ArrayType::~ArrayType()
00066 {
00067 }
00068 
00069 int ArrayType::dimension () const
00070 {
00071   return d_func()->m_dimension;
00072 }
00073 
00074 void ArrayType::setDimension(int dimension)
00075 {
00076   d_func_dynamic()->m_dimension = dimension;
00077 }
00078 
00079 AbstractType::Ptr ArrayType::elementType () const
00080 {
00081   return d_func()->m_elementType.abstractType();
00082 }
00083 
00084 void ArrayType::setElementType(AbstractType::Ptr type)
00085 {
00086   d_func_dynamic()->m_elementType = type->indexed();
00087 }
00088 
00089 QString ArrayType::toString() const
00090 {
00091   return QString("%1[%2]").arg(elementType() ? elementType()->toString() : QString("<notype>")).arg(d_func()->m_dimension);
00092 }
00093 
00094 void ArrayType::accept0 (TypeVisitor *v) const
00095 {
00096   if (v->visit (this))
00097     {
00098       acceptType (d_func()->m_elementType.abstractType(), v);
00099     }
00100 
00101   v->endVisit (this);
00102 }
00103 
00104 void ArrayType::exchangeTypes( TypeExchanger* exchanger )
00105 {
00106   TYPE_D_DYNAMIC(ArrayType);
00107   d->m_elementType = exchanger->exchange( d->m_elementType.abstractType() )->indexed();
00108 }
00109 
00110 AbstractType::WhichType ArrayType::whichType() const
00111 {
00112   return TypeArray;
00113 }
00114 
00115 uint ArrayType::hash() const
00116 {
00117   return AbstractType::hash() + (elementType() ? elementType()->hash() : 0) * 47 + 117* dimension();
00118 }
00119 
00120 }
00121 
00122 // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on

language/duchain

Skip menu "language/duchain"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal