Implement DwarfType::CreateDerivedArrayType().

Will be used for array typecasting.
This commit is contained in:
Rene Gollent 2013-04-12 23:23:00 -04:00
parent 8db1d0fc06
commit d18be78af7
2 changed files with 56 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copryight 2012, Rene Gollent, rene@gollent.com.
* Copryight 2012-2013, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
@ -245,6 +245,52 @@ DwarfType::CreateDerivedAddressType(address_type_kind addressType,
if (resultType == NULL)
return B_NO_MEMORY;
resultType->SetByteSize(fTypeContext->GetArchitecture()->AddressSize());
_resultType = resultType;
return B_OK;
}
status_t
DwarfType::CreateDerivedArrayType(uint64 elementCount, bool extendExisting,
ArrayType*& _resultType)
{
DwarfArrayType* resultType = NULL;
BReference<DwarfType> baseTypeReference;
if (extendExisting)
resultType = dynamic_cast<DwarfArrayType*>(this);
if (resultType == NULL) {
resultType = new(std::nothrow)
DwarfArrayType(fTypeContext, fName, NULL, this);
baseTypeReference.SetTo(resultType, true);
}
if (resultType == NULL)
return B_NO_MEMORY;
DwarfSubrangeType* subrangeType = new(std::nothrow) DwarfSubrangeType(
fTypeContext, fName, NULL, resultType, BVariant((uint64)0),
BVariant(elementCount - 1));
if (subrangeType == NULL)
return B_NO_MEMORY;
BReference<DwarfSubrangeType> subrangeReference(subrangeType, true);
DwarfArrayDimension* dimension = new(std::nothrow) DwarfArrayDimension(
subrangeType);
if (dimension == NULL)
return B_NO_MEMORY;
BReference<DwarfArrayDimension> dimensionReference(dimension, true);
if (!resultType->AddDimension(dimension))
return B_NO_MEMORY;
dimensionReference.Detach();
subrangeReference.Detach();
baseTypeReference.Detach();
_resultType = resultType;
return B_OK;
}
@ -949,8 +995,9 @@ DwarfArrayType::ResolveElementLocation(const ArrayIndexPath& indexPath,
// If the array entry has a bit stride, get it. Otherwise fall back to the
// element type size.
int64 bitStride;
if (DIEArrayType* bitStrideOwnerEntry = DwarfUtils::GetDIEByPredicate(
fEntry, HasBitStridePredicate<DIEArrayType>())) {
DIEArrayType* bitStrideOwnerEntry = NULL;
if (fEntry != NULL && (bitStrideOwnerEntry = DwarfUtils::GetDIEByPredicate(
fEntry, HasBitStridePredicate<DIEArrayType>()))) {
BVariant value;
status_t error = typeContext->File()->EvaluateDynamicValue(
typeContext->GetCompilationUnit(), typeContext->AddressSize(),

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copryight 2012, Rene Gollent, rene@gollent.com.
* Copyright 2012-2013, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#ifndef DWARF_TYPES_H
@ -114,6 +114,11 @@ public:
address_type_kind kind,
AddressType*& _resultType);
virtual status_t CreateDerivedArrayType(
uint64 elementCount,
bool extendExisting,
ArrayType*& _resultType);
virtual status_t ResolveObjectDataLocation(
const ValueLocation& objectLocation,
ValueLocation*& _location);