mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 20:32:56 +03: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
Notes:
sideshowbarker
2024-07-17 21:38:00 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/4a14455dff8 Pull-request: https://github.com/SerenityOS/serenity/pull/11412 Reviewed-by: https://github.com/linusg
@ -24,7 +24,7 @@ struct ExecutionContext {
|
||||
|
||||
[[nodiscard]] ExecutionContext copy() const
|
||||
{
|
||||
ExecutionContext copy { arguments.copy() };
|
||||
ExecutionContext copy { arguments };
|
||||
|
||||
copy.function = function;
|
||||
copy.realm = realm;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,26 +15,18 @@
|
||||
namespace JS {
|
||||
|
||||
class MarkedValueList : public Vector<Value, 32> {
|
||||
AK_MAKE_NONCOPYABLE(MarkedValueList);
|
||||
|
||||
public:
|
||||
explicit MarkedValueList(Heap&);
|
||||
MarkedValueList(MarkedValueList const&);
|
||||
MarkedValueList(MarkedValueList&&);
|
||||
~MarkedValueList();
|
||||
|
||||
MarkedValueList& operator=(MarkedValueList&&) = delete;
|
||||
|
||||
Vector<Value, 32>& values() { return *this; }
|
||||
|
||||
MarkedValueList copy() const
|
||||
{
|
||||
MarkedValueList copy { m_heap };
|
||||
copy.extend(*this);
|
||||
return copy;
|
||||
}
|
||||
MarkedValueList& operator=(JS::MarkedValueList const& other);
|
||||
|
||||
private:
|
||||
Heap& m_heap;
|
||||
Heap* m_heap;
|
||||
|
||||
IntrusiveListNode<MarkedValueList> m_list_node;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user