2021-10-13 21:08:48 +01:00
|
|
|
/*
|
2022-01-24 19:14:04 +00:00
|
|
|
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
2021-10-13 21:08:48 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/Completion.h>
|
2022-02-07 22:39:57 +01:00
|
|
|
#include <LibJS/Runtime/ExecutionContext.h>
|
2021-10-13 21:09:45 +01:00
|
|
|
#include <LibJS/Runtime/Object.h>
|
2021-10-13 21:08:48 +01:00
|
|
|
#include <LibJS/Runtime/Realm.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2021-10-13 21:09:45 +01:00
|
|
|
class ShadowRealm final : public Object {
|
|
|
|
JS_OBJECT(ShadowRealm, Object);
|
2023-11-19 09:45:05 +01:00
|
|
|
JS_DECLARE_ALLOCATOR(ShadowRealm);
|
2021-10-13 21:09:45 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~ShadowRealm() override = default;
|
|
|
|
|
|
|
|
[[nodiscard]] Realm const& shadow_realm() const { return m_shadow_realm; }
|
|
|
|
[[nodiscard]] Realm& shadow_realm() { return m_shadow_realm; }
|
2023-11-27 16:45:45 +01:00
|
|
|
[[nodiscard]] ExecutionContext const& execution_context() const { return *m_execution_context; }
|
|
|
|
[[nodiscard]] ExecutionContext& execution_context() { return *m_execution_context; }
|
2021-10-13 21:09:45 +01:00
|
|
|
|
|
|
|
private:
|
2023-11-27 16:45:45 +01:00
|
|
|
ShadowRealm(Realm&, NonnullOwnPtr<ExecutionContext>, Object& prototype);
|
2022-08-28 23:51:28 +02:00
|
|
|
|
2021-10-13 21:09:45 +01:00
|
|
|
virtual void visit_edges(Visitor&) override;
|
|
|
|
|
|
|
|
// 3.5 Properties of ShadowRealm Instances, https://tc39.es/proposal-shadowrealm/#sec-properties-of-shadowrealm-instances
|
2023-11-27 16:45:45 +01:00
|
|
|
NonnullGCPtr<Realm> m_shadow_realm; // [[ShadowRealm]]
|
|
|
|
NonnullOwnPtr<ExecutionContext> m_execution_context; // [[ExecutionContext]]
|
2021-10-13 21:09:45 +01:00
|
|
|
};
|
|
|
|
|
2022-08-21 17:58:23 +01:00
|
|
|
ThrowCompletionOr<void> copy_name_and_length(VM&, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix = {}, Optional<unsigned> arg_count = {});
|
|
|
|
ThrowCompletionOr<Value> perform_shadow_realm_eval(VM&, StringView source_text, Realm& caller_realm, Realm& eval_realm);
|
2023-12-16 17:49:34 +03:30
|
|
|
ThrowCompletionOr<Value> shadow_realm_import_value(VM&, ByteString specifier_string, ByteString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context);
|
2022-08-21 17:58:23 +01:00
|
|
|
ThrowCompletionOr<Value> get_wrapped_value(VM&, Realm& caller_realm, Value);
|
2021-10-13 21:08:48 +01:00
|
|
|
|
|
|
|
}
|