2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
10 // #pragma mark - BaseType
18 // #pragma mark - DataMember
21 DataMember::~DataMember()
26 // #pragma mark - EnumeratorValue
29 EnumeratorValue::~EnumeratorValue()
34 // #pragma mark - ArrayDimension
37 ArrayDimension::~ArrayDimension()
43 ArrayDimension::CountElements() const
45 Type
* type
= GetType();
47 if (type
->Kind() == TYPE_ENUMERATION
)
48 return dynamic_cast<EnumerationType
*>(type
)->CountValues();
50 if (type
->Kind() == TYPE_SUBRANGE
) {
51 SubrangeType
* subrangeType
= dynamic_cast<SubrangeType
*>(type
);
52 BVariant lower
= subrangeType
->LowerBound();
53 BVariant upper
= subrangeType
->UpperBound();
55 if (!lower
.IsInteger(&isSigned
) || !upper
.IsInteger())
59 ? upper
.ToInt64() - lower
.ToInt64() + 1
60 : upper
.ToUInt64() - lower
.ToUInt64() + 1;
67 // #pragma mark - FunctionParameter
70 FunctionParameter::~FunctionParameter()
75 // #pragma mark - TemplateParameter
78 TemplateParameter::~TemplateParameter()
83 // #pragma mark - Type
92 Type::ResolveRawType(bool nextOneOnly
) const
94 return const_cast<Type
*>(this);
99 Type::CreateDerivedAddressType(address_type_kind kind
,
100 AddressType
*& _resultType
)
108 Type::CreateDerivedArrayType(int64 lowerBound
, int64 elementCount
,
109 bool extendExisting
, ArrayType
*& _resultType
)
116 // #pragma mark - PrimitiveType
119 PrimitiveType::~PrimitiveType()
125 PrimitiveType::Kind() const
127 return TYPE_PRIMITIVE
;
131 // #pragma mark - CompoundType
134 CompoundType::~CompoundType()
140 CompoundType::Kind() const
142 return TYPE_COMPOUND
;
146 // #pragma mark - ModifiedType
149 ModifiedType::~ModifiedType()
155 ModifiedType::Kind() const
157 return TYPE_MODIFIED
;
162 ModifiedType::ResolveRawType(bool nextOneOnly
) const
164 Type
* baseType
= BaseType();
165 return nextOneOnly
? baseType
: baseType
->ResolveRawType(true);
169 // #pragma mark - TypedefType
172 TypedefType::~TypedefType()
178 TypedefType::Kind() const
185 TypedefType::ResolveRawType(bool nextOneOnly
) const
187 Type
* baseType
= BaseType();
188 return nextOneOnly
? baseType
: baseType
->ResolveRawType(true);
192 // #pragma mark - AddressType
195 AddressType::~AddressType()
201 AddressType::Kind() const
207 // #pragma mark - EnumerationType
210 EnumerationType::~EnumerationType()
216 EnumerationType::Kind() const
218 return TYPE_ENUMERATION
;
223 EnumerationType::ValueFor(const BVariant
& value
) const
226 for (int32 i
= 0; EnumeratorValue
* enumValue
= ValueAt(i
); i
++) {
227 if (enumValue
->Value() == value
)
235 // #pragma mark - SubrangeType
238 SubrangeType::~SubrangeType()
244 SubrangeType::Kind() const
246 return TYPE_SUBRANGE
;
250 // #pragma mark - ArrayType
253 ArrayType::~ArrayType()
259 ArrayType::Kind() const
265 // #pragma mark - UnspecifiedType
268 UnspecifiedType::~UnspecifiedType()
274 UnspecifiedType::Kind() const
276 return TYPE_UNSPECIFIED
;
280 // #pragma mark - FunctionType
283 FunctionType::~FunctionType()
289 FunctionType::Kind() const
291 return TYPE_FUNCTION
;
295 // #pragma mark - PointerToMemberType
298 PointerToMemberType::~PointerToMemberType()
304 PointerToMemberType::Kind() const
306 return TYPE_POINTER_TO_MEMBER
;