mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
LibJS: Add the Map built-in object
This commit is contained in:
parent
f9d58ec0b4
commit
a96ac8bd56
11 changed files with 335 additions and 0 deletions
34
Userland/Libraries/LibJS/Runtime/Map.cpp
Normal file
34
Userland/Libraries/LibJS/Runtime/Map.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Map.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
Map* Map::create(GlobalObject& global_object)
|
||||
{
|
||||
return global_object.heap().allocate<Map>(global_object, *global_object.map_prototype());
|
||||
}
|
||||
|
||||
Map::Map(Object& prototype)
|
||||
: Object(prototype)
|
||||
{
|
||||
}
|
||||
|
||||
Map::~Map()
|
||||
{
|
||||
}
|
||||
|
||||
void Map::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Object::visit_edges(visitor);
|
||||
for (auto& value : m_entries) {
|
||||
visitor.visit(value.key);
|
||||
visitor.visit(value.value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue