mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00:00
LibJS: Add the WeakMap built-in object
This commit is contained in:
parent
1a8ee5d8d7
commit
39554f3787
9 changed files with 243 additions and 0 deletions
32
Userland/Libraries/LibJS/Runtime/WeakMap.cpp
Normal file
32
Userland/Libraries/LibJS/Runtime/WeakMap.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/WeakMap.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
WeakMap* WeakMap::create(GlobalObject& global_object)
|
||||
{
|
||||
return global_object.heap().allocate<WeakMap>(global_object, *global_object.weak_map_prototype());
|
||||
}
|
||||
|
||||
WeakMap::WeakMap(Object& prototype)
|
||||
: Object(prototype)
|
||||
, WeakContainer(heap())
|
||||
{
|
||||
}
|
||||
|
||||
WeakMap::~WeakMap()
|
||||
{
|
||||
}
|
||||
|
||||
void WeakMap::remove_sweeped_cells(Badge<Heap>, Vector<Cell*>& cells)
|
||||
{
|
||||
for (auto* cell : cells)
|
||||
m_values.remove(cell);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue