mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 13:09:41 +00:00
This has quite a lot of fall out. But the majority of it is just type or UDL substitution, where the changes just fall through to other function calls. By changing property key storage to UTF-16, the main affected areas are: * NativeFunction names must now be UTF-16 * Bytecode identifiers must now be UTF-16 * Module/binding names must now be UTF-16
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2021, David Tuin <davidot@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/StringView.h>
|
|
#include <AK/Utf16FlyString.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibGC/CellAllocator.h>
|
|
#include <LibJS/Heap/Cell.h>
|
|
|
|
namespace JS {
|
|
|
|
struct PrivateName {
|
|
PrivateName() = default;
|
|
PrivateName(u64 unique_id, Utf16FlyString description)
|
|
: unique_id(unique_id)
|
|
, description(move(description))
|
|
{
|
|
}
|
|
|
|
u64 unique_id { 0 };
|
|
Utf16FlyString description;
|
|
|
|
bool operator==(PrivateName const& rhs) const;
|
|
};
|
|
|
|
class PrivateEnvironment : public Cell {
|
|
GC_CELL(PrivateEnvironment, Cell);
|
|
GC_DECLARE_ALLOCATOR(PrivateEnvironment);
|
|
|
|
public:
|
|
PrivateName resolve_private_identifier(Utf16FlyString const& identifier) const;
|
|
|
|
void add_private_name(Utf16FlyString description);
|
|
|
|
PrivateEnvironment* outer_environment() { return m_outer_environment; }
|
|
PrivateEnvironment const* outer_environment() const { return m_outer_environment; }
|
|
|
|
private:
|
|
explicit PrivateEnvironment(PrivateEnvironment* parent);
|
|
|
|
virtual void visit_edges(Visitor&) override;
|
|
|
|
auto find_private_name(Utf16FlyString const& description) const
|
|
{
|
|
return m_private_names.find_if([&](PrivateName const& private_name) {
|
|
return private_name.description == description;
|
|
});
|
|
}
|
|
|
|
static u64 s_next_id;
|
|
|
|
GC::Ptr<PrivateEnvironment> m_outer_environment; // [[OuterEnv]]
|
|
Vector<PrivateName> m_private_names; // [[Names]]
|
|
u64 m_unique_id;
|
|
};
|
|
|
|
}
|