Bug 1024774 - Part 8: Add JS::ubi::Node::isLive; r=jimb

This commit is contained in:
Nick Fitzgerald 2015-04-22 11:09:54 -07:00
Родитель a55c57cabc
Коммит 0e6dcee572
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -187,6 +187,11 @@ class Base {
}
bool operator!=(const Base& rhs) const { return !(*this == rhs); }
// Returns true if this node is pointing to something on the live heap, as
// opposed to something from a deserialized core dump. Returns false,
// otherwise.
virtual bool isLive() const { return true; };
// Return a human-readable name for the referent's type. The result should
// be statically allocated. (You can use MOZ_UTF16("strings") for this.)
//
@ -321,6 +326,8 @@ class Node {
return base()->ptr != nullptr;
}
bool isLive() const { return base()->isLive(); }
template<typename T>
bool is() const {
return base()->typeName() == Concrete<T>::concreteTypeName;
@ -328,12 +335,14 @@ class Node {
template<typename T>
T* as() const {
MOZ_ASSERT(isLive());
MOZ_ASSERT(is<T>());
return static_cast<T*>(base()->ptr);
}
template<typename T>
T* asOrNull() const {
MOZ_ASSERT(isLive());
return is<T>() ? static_cast<T*>(base()->ptr) : nullptr;
}