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:
parent
07eedfea60
commit
ce6b908edb
@ -102,6 +102,17 @@ struct HasBaseTypesPredicate {
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - HasTemplateTypeParametersPredicate
|
||||
|
||||
|
||||
struct HasTemplateTypeParametersPredicate {
|
||||
inline bool operator()(DIEClassBaseType* entry) const
|
||||
{
|
||||
return !entry->TemplateTypeParameters().IsEmpty();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// #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
|
||||
// base types.
|
||||
// base types, and possibly template parameters.
|
||||
if (DIEClassBaseType* classTypeEntry
|
||||
= dynamic_cast<DIEClassBaseType*>(typeEntry)) {
|
||||
// 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();
|
||||
|
@ -567,6 +567,9 @@ DwarfCompoundType::~DwarfCompoundType()
|
||||
}
|
||||
for (int32 i = 0; DwarfDataMember* member = fDataMembers.ItemAt(i); i++)
|
||||
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
|
||||
DwarfCompoundType::ResolveBaseTypeLocation(BaseType* _baseType,
|
||||
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
|
||||
DwarfCompoundType::_ResolveDataMemberLocation(DwarfType* memberType,
|
||||
const MemberLocation* memberLocation,
|
||||
|
@ -271,6 +271,12 @@ public:
|
||||
virtual int32 CountDataMembers() 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,
|
||||
const ValueLocation& parentLocation,
|
||||
ValueLocation*& _location);
|
||||
@ -285,10 +291,12 @@ public:
|
||||
|
||||
bool AddInheritance(DwarfInheritance* inheritance);
|
||||
bool AddDataMember(DwarfDataMember* member);
|
||||
bool AddTemplateTypeParameter(DwarfType* type);
|
||||
|
||||
private:
|
||||
typedef BObjectList<DwarfDataMember> DataMemberList;
|
||||
typedef BObjectList<DwarfInheritance> InheritanceList;
|
||||
typedef BObjectList<DwarfType> TemplateTypeList;
|
||||
|
||||
private:
|
||||
status_t _ResolveDataMemberLocation(
|
||||
@ -302,6 +310,7 @@ private:
|
||||
DIECompoundType* fEntry;
|
||||
InheritanceList fInheritances;
|
||||
DataMemberList fDataMembers;
|
||||
TemplateTypeList fTemplateTypeParameters;
|
||||
};
|
||||
|
||||
|
||||
|
@ -158,6 +158,13 @@ public:
|
||||
virtual int32 CountDataMembers() 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,
|
||||
const ValueLocation& parentLocation,
|
||||
ValueLocation*& _location) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user