language/duchain
KDevelop::AbstractType Class Reference
Base class for all types. More...
#include <abstracttype.h>

Public Types | |
| enum | { Identity = 1 } |
| enum | CommonModifiers { NoModifiers = 0, ConstModifier = 1 << 0, VolatileModifier = 1 << 1, TransientModifier = 1 << 2, NewModifier = 1 << 3, SealedModifier = 1 << 4, UnsafeModifier = 1 << 5, FixedModifier = 1 << 6, ShortModifier = 1 << 7, LongModifier = 1 << 8, LongLongModifier = 1 << 9, SignedModifier = 1 << 10, UnsignedModifier = 1 << 11, LanguageSpecificModifier = 1 << 12 } |
| typedef AbstractTypeData | Data |
| typedef TypePtr< AbstractType > | Ptr |
| enum | WhichType { TypeAbstract, TypeIntegral, TypePointer, TypeReference, TypeFunction, TypeStructure, TypeArray, TypeDelayed, TypeEnumeration, TypeEnumerator, TypeAlias, TypeUnsure } |
Public Member Functions | |
| AbstractType (AbstractTypeData &dd) | |
| AbstractType () | |
| virtual | ~AbstractType () |
| void | accept (TypeVisitor *v) const |
| virtual AbstractType * | clone () const =0 |
| virtual bool | equals (const AbstractType *rhs) const |
| virtual void | exchangeTypes (TypeExchanger *exchanger) |
| virtual uint | hash () const |
| IndexedType | indexed () const |
| void | makeDynamic () |
| quint64 | modifiers () const |
| void | setModifiers (quint64 modifiers) |
| virtual QString | toString () const |
| virtual WhichType | whichType () const |
Static Public Member Functions | |
| static void | acceptType (AbstractType::Ptr type, TypeVisitor *v) |
| template<class Type > | |
| static Type::Data & | copyData (const typename Type::Data &rhs) |
| template<class DataType > | |
| static DataType & | copyDataDirectly (const DataType &rhs) |
| template<class Type > | |
| static Type::Data & | createData () |
Protected Member Functions | |
| virtual void | accept0 (TypeVisitor *v) const =0 |
| QString | toString (bool spaceOnLeft) const |
Protected Attributes | |
| AbstractTypeData * | d_ptr |
Detailed Description
Base class for all types.
The AbstractType class is a base class from which all types derive. It features:
- mechanisms for visiting types
- toString() feature
- equivalence feature
- cloning of types, and
- hashing and indexing
Type classes are created in a way that allows storing them in memory or on disk efficiently. They are classes which can store arbitrary lists immediately after their private data structures in memory (thus enabling them to be mmapped or memcopied), or being "dynamic" where you use exactly the same class and same access functions, but the list data is stored in a temporary KDevVarLengthArray from a central repository, until we save it back to the static memory-region again.
When creating an own type, you must:
- Implement equals(..), hash(). They should _fully_ distinguish all types, in regard to all stored information. * implement a copy-constructor in which you copy the data from the source using copyData<YourType>() * Implement clone() in which you use the copy-constructor to clone the type
- Add an enumerator "Identity" that contains an arbitrary unique identity value of the type
- Add a typedef "BaseType" that specifies the base type, which must be a type that also follows these rules(
- See also:
- typeregister.h
- Add a typedef "Data", that contains the actual data of the type using the mechanisms described in appendedlist.h. That data type must follow the same inheritance chain as the type itself, so it must be based on BaseType::Data.
- See also:
- AbstractTypeData
- When creating a data object in a constructor, use createData<YourType>()
- Use TYPE_DECLARE_DATA(YourType) to declare the data access functions, and then use d_func() and d_func_dynamic() to access your type data
- Create a constructor that only takes a reference to the type data, and passes it to the parent type
Every type can have only one other type as base-type, but it can have additional base-classes that are not a direct part of the type-system(
- See also:
- IdentifiedType).
- appendedlist.h
Definition at line 81 of file abstracttype.h.
Member Enumeration Documentation
An enumeration of common modifiers for data types.
If you have any language-specific modifiers that don't belong here, you can add them at/after LanguageSpecificModifier
- Warning:
- Think twice what information you store into the type-system. The type-system should store information that is shared among many declarations, and attributes of specific Declarations like public/private should be stored in the Declarations themselves, not in the type-system.
Definition at line 95 of file abstracttype.h.
Enumeration of major data types.
- Enumerator:
Definition at line 180 of file abstracttype.h.
Constructor & Destructor Documentation
| KDevelop::AbstractType::AbstractType | ( | ) |
Constructor.
Definition at line 60 of file abstracttype.cpp.
| KDevelop::AbstractType::AbstractType | ( | AbstractTypeData & | dd | ) |
Constructor from data.
Definition at line 45 of file abstracttype.cpp.
| KDevelop::AbstractType::~AbstractType | ( | ) | [virtual] |
Destructor.
Definition at line 65 of file abstracttype.cpp.
Member Function Documentation
| void KDevelop::AbstractType::accept | ( | TypeVisitor * | v | ) | const |
Visitor method.
Called by TypeVisitor to visit the type heirachy. Do not reimplement this, reimplement accept0 instead.
- Parameters:
-
v visitor which is calling this function.
Definition at line 73 of file abstracttype.cpp.
| virtual void KDevelop::AbstractType::accept0 | ( | TypeVisitor * | v | ) | const [protected, pure virtual] |
Visitor method, reimplement to allow visiting of types.
- Parameters:
-
v visitor which is visiting.
Implemented in KDevelop::DelayedType, KDevelop::FunctionType, KDevelop::IntegralType, KDevelop::PointerType, KDevelop::ReferenceType, and KDevelop::StructureType.
| void KDevelop::AbstractType::acceptType | ( | AbstractType::Ptr | type, | |
| TypeVisitor * | v | |||
| ) | [static] |
Convenience visitor method which can be called with a null type.
- Parameters:
-
type type to visit, may be null. v visitor which is visiting the given type
Definition at line 81 of file abstracttype.cpp.
| virtual AbstractType* KDevelop::AbstractType::clone | ( | ) | const [pure virtual] |
Should create a clone of the source-type, with as much data copied as possible without breaking the du-chain.
Implemented in KDevelop::DelayedType, KDevelop::FunctionType, KDevelop::IntegralType, KDevelop::PointerType, KDevelop::ReferenceType, and KDevelop::StructureType.
| static Type::Data& KDevelop::AbstractType::copyData | ( | const typename Type::Data & | rhs | ) | [inline, static] |
Method to create copies of internal type data.
You must use this to create the internal data instances in copy constructors. It is needed, because it may need to allocate more memory for appended lists.
- Parameters:
-
rhs data to copy
- Returns:
- copy of the data
Definition at line 224 of file abstracttype.h.
| static DataType& KDevelop::AbstractType::copyDataDirectly | ( | const DataType & | rhs | ) | [inline, static] |
As above, but does not support copying data into a lower class(Should not be used while cloning).
Definition at line 240 of file abstracttype.h.
| static Type::Data& KDevelop::AbstractType::createData | ( | ) | [inline, static] |
Method to create internal data structures.
Use this in normal constructors.
- Returns:
- the internal data structure
Definition at line 256 of file abstracttype.h.
| bool KDevelop::AbstractType::equals | ( | const AbstractType * | rhs | ) | const [virtual] |
Should return whether this type's content equals the given one Since this is used by the type-repository, it must compare ALL members of the data type.
Definition at line 105 of file abstracttype.cpp.
| void KDevelop::AbstractType::exchangeTypes | ( | TypeExchanger * | exchanger | ) | [virtual] |
Should, like accept0, be implemented by all types that hold references to other types.
If this is called on one type, that type should call exchangeTypes(..) with all its referenced sub-types. The type itself does not recurse into the sub-types, that can be done by the exchanger itself if desired.
Reimplemented in KDevelop::FunctionType, KDevelop::PointerType, and KDevelop::ReferenceType.
Definition at line 94 of file abstracttype.cpp.
| uint KDevelop::AbstractType::hash | ( | ) | const [virtual] |
A hash-value that should have the following properties:
- When two types match on equals(), it should be same.
- When two types don't match on equals(), it should be different with a high probability.
Reimplemented in KDevelop::DelayedType, KDevelop::FunctionType, KDevelop::IntegralType, KDevelop::PointerType, KDevelop::ReferenceType, and KDevelop::StructureType.
Definition at line 111 of file abstracttype.cpp.
| IndexedType KDevelop::AbstractType::indexed | ( | ) | const |
This can also be called on zero types, those can then be reconstructed from the zero index.
Definition at line 97 of file abstracttype.cpp.
| void KDevelop::AbstractType::makeDynamic | ( | ) |
Must always be called before anything in the data pointer is changed! If it's not called beforehand, the type-repository gets corrupted.
Definition at line 34 of file abstracttype.cpp.
| quint64 KDevelop::AbstractType::modifiers | ( | ) | const |
Access the type modifiers.
- Returns:
- the type's modifiers.
Definition at line 50 of file abstracttype.cpp.
| void KDevelop::AbstractType::setModifiers | ( | quint64 | modifiers | ) |
Set the type's modifiers.
- Parameters:
-
modifiers modifiers of this type.
Definition at line 55 of file abstracttype.cpp.
| QString KDevelop::AbstractType::toString | ( | bool | spaceOnLeft | ) | const [protected] |
toString() function which can provide spaceOnLeft rather than on right if desired.
Definition at line 138 of file abstracttype.cpp.
| QString KDevelop::AbstractType::toString | ( | ) | const [virtual] |
Returns this type as a string, preferably the same as it is expressed in the code.
- Returns:
- this type as a string
Reimplemented in KDevelop::DelayedType, KDevelop::FunctionType, KDevelop::IntegralType, KDevelop::PointerType, KDevelop::ReferenceType, and KDevelop::StructureType.
Definition at line 133 of file abstracttype.cpp.
| AbstractType::WhichType KDevelop::AbstractType::whichType | ( | ) | const [virtual] |
Determine which data type this abstract type represents.
- Returns:
- the data type represented by this type.
Reimplemented in KDevelop::DelayedType, KDevelop::FunctionType, KDevelop::IntegralType, KDevelop::PointerType, KDevelop::ReferenceType, and KDevelop::StructureType.
Definition at line 89 of file abstracttype.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference