
This function now takes an optional out parameter for callers who would like to what kind of property we ended up getting. This will be used to implement inline caching for property lookups. Also, to prepare for adding more forms of caching, the out parameter is a struct CacheablePropertyMetadata rather than just an offset. :^)
42 lines
1.9 KiB
C++
42 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2022, David Tuin <davidot@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Module.h>
|
|
#include <LibJS/Runtime/Completion.h>
|
|
#include <LibJS/Runtime/Object.h>
|
|
|
|
namespace JS {
|
|
|
|
class ModuleNamespaceObject final : public Object {
|
|
JS_OBJECT(ModuleNamespaceObject, Object);
|
|
|
|
public:
|
|
// 10.4.6 Module Namespace Exotic Objects, https://tc39.es/ecma262/#sec-module-namespace-exotic-objects
|
|
|
|
virtual ThrowCompletionOr<Object*> internal_get_prototype_of() const override;
|
|
virtual ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override;
|
|
virtual ThrowCompletionOr<bool> internal_is_extensible() const override;
|
|
virtual ThrowCompletionOr<bool> internal_prevent_extensions() override;
|
|
virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyKey const&) const override;
|
|
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&) override;
|
|
virtual ThrowCompletionOr<bool> internal_has_property(PropertyKey const&) const override;
|
|
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata* = nullptr) const override;
|
|
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver) override;
|
|
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
|
|
virtual ThrowCompletionOr<MarkedVector<Value>> internal_own_property_keys() const override;
|
|
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
|
|
|
private:
|
|
ModuleNamespaceObject(Realm&, Module* module, Vector<DeprecatedFlyString> exports);
|
|
|
|
// FIXME: UHHH how do we want to store this to avoid cycles but be safe??
|
|
GCPtr<Module> m_module; // [[Module]]
|
|
Vector<DeprecatedFlyString> m_exports; // [[Exports]]
|
|
};
|
|
|
|
}
|