mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
LibJS: Make MarkedValueList copyable and move assignable
This is required to store a MarkedValueList as the value of a HashMap.
This commit is contained in:
parent
c97244d3a5
commit
4a14455dff
3 changed files with 29 additions and 16 deletions
|
@ -10,21 +10,42 @@
|
|||
namespace JS {
|
||||
|
||||
MarkedValueList::MarkedValueList(Heap& heap)
|
||||
: m_heap(heap)
|
||||
: m_heap(&heap)
|
||||
{
|
||||
m_heap.did_create_marked_value_list({}, *this);
|
||||
m_heap->did_create_marked_value_list({}, *this);
|
||||
}
|
||||
|
||||
MarkedValueList::MarkedValueList(MarkedValueList const& other)
|
||||
: Vector<Value, 32>(other)
|
||||
, m_heap(other.m_heap)
|
||||
{
|
||||
m_heap->did_create_marked_value_list({}, *this);
|
||||
}
|
||||
|
||||
MarkedValueList::MarkedValueList(MarkedValueList&& other)
|
||||
: Vector<Value, 32>(move(static_cast<Vector<Value, 32>&>(other)))
|
||||
, m_heap(other.m_heap)
|
||||
{
|
||||
m_heap.did_create_marked_value_list({}, *this);
|
||||
m_heap->did_create_marked_value_list({}, *this);
|
||||
}
|
||||
|
||||
MarkedValueList::~MarkedValueList()
|
||||
{
|
||||
m_heap.did_destroy_marked_value_list({}, *this);
|
||||
m_heap->did_destroy_marked_value_list({}, *this);
|
||||
}
|
||||
|
||||
MarkedValueList& MarkedValueList::operator=(JS::MarkedValueList const& other)
|
||||
{
|
||||
Vector<Value, 32>::operator=(other);
|
||||
|
||||
if (m_heap != other.m_heap) {
|
||||
m_heap = other.m_heap;
|
||||
|
||||
// NOTE: IntrusiveList will remove this MarkedValueList from the old heap it was part of.
|
||||
m_heap->did_create_marked_value_list({}, *this);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue