ladybird/Userland/Libraries/LibJS/Runtime/ShadowRealm.h
Linus Groh 5910a41adb LibJS: Implement ShadowRealm.prototype.importValue()
Well... sort of. This adds the function itself and all the scaffolding
from the ShadowRealm API (and basically completes its implementation).
However, we do not nearly have enough support for modules and imports,
so we currently pretend whatever was attempted to be imported failed -
once we have HostImportModuleDynamically it should be relatively easy to
complete the implementation.
2021-10-15 09:36:21 +01:00

40 lines
1.5 KiB
C++

/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Realm.h>
namespace JS {
class ShadowRealm final : public Object {
JS_OBJECT(ShadowRealm, Object);
public:
ShadowRealm(Realm&, ExecutionContext, Object& prototype);
virtual ~ShadowRealm() override = default;
[[nodiscard]] Realm const& shadow_realm() const { return m_shadow_realm; }
[[nodiscard]] Realm& shadow_realm() { return m_shadow_realm; }
[[nodiscard]] ExecutionContext const& execution_context() const { return m_execution_context; }
[[nodiscard]] ExecutionContext& execution_context() { return m_execution_context; }
private:
virtual void visit_edges(Visitor&) override;
// 3.5 Properties of ShadowRealm Instances, https://tc39.es/proposal-shadowrealm/#sec-properties-of-shadowrealm-instances
Realm& m_shadow_realm; // [[ShadowRealm]]
ExecutionContext m_execution_context; // [[ExecutionContext]]
};
ThrowCompletionOr<Value> perform_shadow_realm_eval(GlobalObject&, StringView source_text, Realm& caller_realm, Realm& eval_realm);
ThrowCompletionOr<Value> shadow_realm_import_value(GlobalObject&, String specifier_string, String export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context);
ThrowCompletionOr<Value> get_wrapped_value(GlobalObject&, Realm& caller_realm, Value);
}