Extend CompoundType to handle template parameters.
- Adjust CompoundType to add accessors for template type and value parameters. - Add DwarfCompoundType/DwarfTypeFactory handling for template template type parameters.
This commit is contained in:
@@ -102,6 +102,17 @@ struct HasBaseTypesPredicate {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - HasTemplateTypeParametersPredicate
|
||||||
|
|
||||||
|
|
||||||
|
struct HasTemplateTypeParametersPredicate {
|
||||||
|
inline bool operator()(DIEClassBaseType* entry) const
|
||||||
|
{
|
||||||
|
return !entry->TemplateTypeParameters().IsEmpty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - HasParametersPredicate
|
// #pragma mark - HasParametersPredicate
|
||||||
|
|
||||||
|
|
||||||
@@ -516,7 +527,7 @@ printf(" -> failed to add type to cache\n");
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the type is a class/struct/interface type, we also need to add its
|
// If the type is a class/struct/interface type, we also need to add its
|
||||||
// base types.
|
// base types, and possibly template parameters.
|
||||||
if (DIEClassBaseType* classTypeEntry
|
if (DIEClassBaseType* classTypeEntry
|
||||||
= dynamic_cast<DIEClassBaseType*>(typeEntry)) {
|
= dynamic_cast<DIEClassBaseType*>(typeEntry)) {
|
||||||
// find the abstract origin or specification that defines the base types
|
// find the abstract origin or specification that defines the base types
|
||||||
@@ -549,6 +560,34 @@ printf(" -> failed to add type to cache\n");
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// find the abstract origin or specification that defines the template
|
||||||
|
// parameters
|
||||||
|
classTypeEntry = DwarfUtils::GetDIEByPredicate(
|
||||||
|
dynamic_cast<DIEClassBaseType*>(typeEntry),
|
||||||
|
HasTemplateTypeParametersPredicate());
|
||||||
|
|
||||||
|
if (classTypeEntry != NULL) {
|
||||||
|
for (DebugInfoEntryList::ConstIterator it
|
||||||
|
= classTypeEntry->TemplateTypeParameters()
|
||||||
|
.GetIterator();
|
||||||
|
DebugInfoEntry* _typeEntry = it.Next();) {
|
||||||
|
DIETemplateTypeParameter* templateTypeEntry =
|
||||||
|
dynamic_cast<DIETemplateTypeParameter*>(_typeEntry);
|
||||||
|
DwarfType* templateType;
|
||||||
|
if (CreateType(templateTypeEntry->GetType(), templateType)
|
||||||
|
!= B_OK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BReference<DwarfType> templateTypeReference(templateType,
|
||||||
|
true);
|
||||||
|
if (!type->AddTemplateTypeParameter(templateType)) {
|
||||||
|
cacheLocker.Lock();
|
||||||
|
fTypeCache->RemoveType(type);
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_type = typeReference.Detach();
|
_type = typeReference.Detach();
|
||||||
|
|||||||
@@ -567,6 +567,9 @@ DwarfCompoundType::~DwarfCompoundType()
|
|||||||
}
|
}
|
||||||
for (int32 i = 0; DwarfDataMember* member = fDataMembers.ItemAt(i); i++)
|
for (int32 i = 0; DwarfDataMember* member = fDataMembers.ItemAt(i); i++)
|
||||||
member->ReleaseReference();
|
member->ReleaseReference();
|
||||||
|
|
||||||
|
for (int32 i = 0; DwarfType* type = fTemplateTypeParameters.ItemAt(i); i++)
|
||||||
|
type->ReleaseReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -605,6 +608,36 @@ DwarfCompoundType::DataMemberAt(int32 index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
DwarfCompoundType::CountTemplateTypeParameters() const
|
||||||
|
{
|
||||||
|
return fTemplateTypeParameters.CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Type*
|
||||||
|
DwarfCompoundType::TemplateTypeParameterAt(int32 index) const
|
||||||
|
{
|
||||||
|
return fTemplateTypeParameters.ItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
DwarfCompoundType::CountTemplateValueParameters() const
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Type*
|
||||||
|
DwarfCompoundType::TemplateValueParameterAt(int32 index) const
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DwarfCompoundType::ResolveBaseTypeLocation(BaseType* _baseType,
|
DwarfCompoundType::ResolveBaseTypeLocation(BaseType* _baseType,
|
||||||
const ValueLocation& parentLocation, ValueLocation*& _location)
|
const ValueLocation& parentLocation, ValueLocation*& _location)
|
||||||
@@ -736,6 +769,17 @@ DwarfCompoundType::AddDataMember(DwarfDataMember* member)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
DwarfCompoundType::AddTemplateTypeParameter(DwarfType* type)
|
||||||
|
{
|
||||||
|
if (!fTemplateTypeParameters.AddItem(type))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
type->AcquireReference();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DwarfCompoundType::_ResolveDataMemberLocation(DwarfType* memberType,
|
DwarfCompoundType::_ResolveDataMemberLocation(DwarfType* memberType,
|
||||||
const MemberLocation* memberLocation,
|
const MemberLocation* memberLocation,
|
||||||
|
|||||||
@@ -271,6 +271,12 @@ public:
|
|||||||
virtual int32 CountDataMembers() const;
|
virtual int32 CountDataMembers() const;
|
||||||
virtual DataMember* DataMemberAt(int32 index) const;
|
virtual DataMember* DataMemberAt(int32 index) const;
|
||||||
|
|
||||||
|
virtual int32 CountTemplateTypeParameters() const;
|
||||||
|
virtual Type* TemplateTypeParameterAt(int32 index) const;
|
||||||
|
|
||||||
|
virtual int32 CountTemplateValueParameters() const;
|
||||||
|
virtual Type* TemplateValueParameterAt(int32 index) const;
|
||||||
|
|
||||||
virtual status_t ResolveBaseTypeLocation(BaseType* _baseType,
|
virtual status_t ResolveBaseTypeLocation(BaseType* _baseType,
|
||||||
const ValueLocation& parentLocation,
|
const ValueLocation& parentLocation,
|
||||||
ValueLocation*& _location);
|
ValueLocation*& _location);
|
||||||
@@ -285,10 +291,12 @@ public:
|
|||||||
|
|
||||||
bool AddInheritance(DwarfInheritance* inheritance);
|
bool AddInheritance(DwarfInheritance* inheritance);
|
||||||
bool AddDataMember(DwarfDataMember* member);
|
bool AddDataMember(DwarfDataMember* member);
|
||||||
|
bool AddTemplateTypeParameter(DwarfType* type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BObjectList<DwarfDataMember> DataMemberList;
|
typedef BObjectList<DwarfDataMember> DataMemberList;
|
||||||
typedef BObjectList<DwarfInheritance> InheritanceList;
|
typedef BObjectList<DwarfInheritance> InheritanceList;
|
||||||
|
typedef BObjectList<DwarfType> TemplateTypeList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _ResolveDataMemberLocation(
|
status_t _ResolveDataMemberLocation(
|
||||||
@@ -302,6 +310,7 @@ private:
|
|||||||
DIECompoundType* fEntry;
|
DIECompoundType* fEntry;
|
||||||
InheritanceList fInheritances;
|
InheritanceList fInheritances;
|
||||||
DataMemberList fDataMembers;
|
DataMemberList fDataMembers;
|
||||||
|
TemplateTypeList fTemplateTypeParameters;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,13 @@ public:
|
|||||||
virtual int32 CountDataMembers() const = 0;
|
virtual int32 CountDataMembers() const = 0;
|
||||||
virtual DataMember* DataMemberAt(int32 index) const = 0;
|
virtual DataMember* DataMemberAt(int32 index) const = 0;
|
||||||
|
|
||||||
|
virtual int32 CountTemplateTypeParameters() const = 0;
|
||||||
|
virtual Type* TemplateTypeParameterAt(int32 index) const = 0;
|
||||||
|
|
||||||
|
virtual int32 CountTemplateValueParameters() const = 0;
|
||||||
|
virtual Type* TemplateValueParameterAt(int32 index) const
|
||||||
|
= 0;
|
||||||
|
|
||||||
virtual status_t ResolveBaseTypeLocation(BaseType* baseType,
|
virtual status_t ResolveBaseTypeLocation(BaseType* baseType,
|
||||||
const ValueLocation& parentLocation,
|
const ValueLocation& parentLocation,
|
||||||
ValueLocation*& _location) = 0;
|
ValueLocation*& _location) = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user