2022-09-24 15:39:23 -06:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibJS/Forward.h>
|
|
|
|
#include <LibJS/Runtime/NativeFunction.h>
|
|
|
|
#include <LibJS/Runtime/Object.h>
|
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2024-11-08 04:03:55 +13:00
|
|
|
#include <LibWeb/Bindings/PrincipalHostDefined.h>
|
2024-11-08 16:07:04 +13:00
|
|
|
#include <LibWeb/Bindings/SyntheticHostDefined.h>
|
2022-09-24 15:39:23 -06:00
|
|
|
|
|
|
|
namespace Web::Bindings {
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DEFINE_ALLOCATOR(Intrinsics);
|
2023-11-19 19:47:52 +01:00
|
|
|
|
2022-09-24 15:39:23 -06:00
|
|
|
void Intrinsics::visit_edges(JS::Cell::Visitor& visitor)
|
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
2024-04-15 13:58:21 +02:00
|
|
|
visitor.visit(m_namespaces);
|
|
|
|
visitor.visit(m_prototypes);
|
|
|
|
visitor.visit(m_constructors);
|
2023-03-21 10:08:44 -07:00
|
|
|
visitor.visit(m_realm);
|
2022-09-24 15:39:23 -06:00
|
|
|
}
|
|
|
|
|
2023-12-07 15:53:38 -07:00
|
|
|
bool Intrinsics::is_exposed(StringView name) const
|
|
|
|
{
|
|
|
|
return m_constructors.contains(name) || m_prototypes.contains(name) || m_namespaces.contains(name);
|
|
|
|
}
|
|
|
|
|
2024-11-08 04:03:55 +13:00
|
|
|
Intrinsics& host_defined_intrinsics(JS::Realm& realm)
|
|
|
|
{
|
|
|
|
VERIFY(realm.host_defined());
|
2024-11-08 16:07:04 +13:00
|
|
|
return verify_cast<Bindings::HostDefined>(*realm.host_defined()).intrinsics;
|
2024-11-08 04:03:55 +13:00
|
|
|
}
|
|
|
|
|
2022-09-24 15:39:23 -06:00
|
|
|
}
|