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

language/duchain

integraltype.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 "integraltype.h"
00022 
00023 #include "../indexedstring.h"
00024 #include "typesystemdata.h"
00025 #include "typeregister.h"
00026 #include "typesystem.h"
00027 
00028 namespace KDevelop
00029 {
00030 
00031 REGISTER_TYPE(IntegralType);
00032 
00033 IntegralType::IntegralType(const IntegralType& rhs) : AbstractType(copyData<IntegralType>(*rhs.d_func())) {
00034 }
00035 
00036 IntegralType::IntegralType(IntegralTypeData& data) : AbstractType(data) {
00037 }
00038 
00039 uint IntegralType::dataType() const
00040 {
00041   return d_func()->m_dataType;
00042 }
00043 
00044 void IntegralType::setDataType(uint dataType)
00045 {
00046   d_func_dynamic()->m_dataType = dataType;
00047 }
00048 
00049 AbstractType* IntegralType::clone() const {
00050   return new IntegralType(*this);
00051 }
00052 
00053 bool IntegralType::equals(const AbstractType* _rhs) const
00054 {
00055   if( this == _rhs )
00056     return true;
00057 
00058   if (!AbstractType::equals(_rhs))
00059     return false;
00060 
00061   Q_ASSERT(fastCast<const IntegralType*>(_rhs));
00062 
00063   const IntegralType* rhs = static_cast<const IntegralType*>(_rhs);
00064 
00065   return d_func()->m_dataType == rhs->d_func()->m_dataType;
00066 }
00067 
00068 IntegralType::IntegralType(uint type)
00069   : AbstractType(createData<IntegralType>())
00070 {
00071   d_func_dynamic()->setTypeClassId<IntegralType>();
00072   setDataType(type);
00073 }
00074 
00075 IntegralType::~IntegralType()
00076 {
00077 }
00078 
00079 QString IntegralType::toString() const
00080 {
00081   TYPE_D(IntegralType);
00082 
00083   QString name;
00084 
00085   switch (d->m_dataType) {
00086     case TypeChar:
00087       name = "char";
00088       break;
00089     case TypeWchar_t:
00090       name = "wchar_t";
00091       break;
00092     case TypeBoolean:
00093       name = "bool";
00094       break;
00095     case TypeInt:
00096       name = "int";
00097       break;
00098     case TypeFloat:
00099       name = "float";
00100       break;
00101     case TypeDouble:
00102       name = "double";
00103       break;
00104     case TypeVoid:
00105       name = "void";
00106       break;
00107     case TypeMixed:
00108       name = "mixed";
00109       break;
00110     case TypeString:
00111       name = "string";
00112       break;
00113     case TypeArray:
00114       name = "array";
00115       break;
00116     case TypeNull:
00117       name = "null";
00118       break;
00119     default:
00120       name = "<unknown>";
00121       break;
00122   }
00123 
00124   if (modifiers() & UnsignedModifier)
00125     name.prepend("unsigned ");
00126   else if (modifiers() & SignedModifier)
00127     name.prepend("signed ");
00128 
00129   if (modifiers() & ShortModifier)
00130     name.prepend("short ");
00131   else if (modifiers() & LongModifier)
00132     name.prepend("long ");
00133 
00134   return AbstractType::toString() + name;
00135 }
00136 
00137 void IntegralType::accept0(TypeVisitor *v) const
00138 {
00139   v->visit (this);
00140 }
00141 
00142 AbstractType::WhichType IntegralType::whichType() const
00143 {
00144   return TypeIntegral;
00145 }
00146 
00147 uint IntegralType::hash() const
00148 {
00149   return AbstractType::hash() + d_func()->m_dataType * 11;
00150 }
00151 
00152 }
00153 
00154 // 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