Added GetDIEByPredicate() template method simplifying the task of check an
entry, its abstract origin and specification for something. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33312 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -28,7 +28,38 @@ public:
|
|||||||
const char*& _directory,
|
const char*& _directory,
|
||||||
const char*& _file,
|
const char*& _file,
|
||||||
int32& _line, int32& _column);
|
int32& _line, int32& _column);
|
||||||
|
|
||||||
|
template<typename EntryType, typename Predicate>
|
||||||
|
static EntryType* GetDIEByPredicate(EntryType* entry,
|
||||||
|
const Predicate& predicate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename EntryType, typename Predicate>
|
||||||
|
/*static*/ EntryType*
|
||||||
|
DwarfUtils::GetDIEByPredicate(EntryType* entry, const Predicate& predicate)
|
||||||
|
{
|
||||||
|
if (predicate(entry))
|
||||||
|
return entry;
|
||||||
|
|
||||||
|
// try the abstract origin
|
||||||
|
if (EntryType* abstractOrigin = dynamic_cast<EntryType*>(
|
||||||
|
entry->AbstractOrigin())) {
|
||||||
|
entry = abstractOrigin;
|
||||||
|
if (predicate(entry))
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try the specification
|
||||||
|
if (EntryType* specification = dynamic_cast<EntryType*>(
|
||||||
|
entry->Specification())) {
|
||||||
|
entry = specification;
|
||||||
|
if (predicate(entry))
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // DWARF_UTILS_H
|
#endif // DWARF_UTILS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user