mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:27:45 +00:00
LibJS: Add slot [[PrivateElements]] and related methods to Object
This commit is contained in:
parent
13ead80ee6
commit
d94b5e511f
3 changed files with 124 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
|||
#include <LibJS/Runtime/IndexedProperties.h>
|
||||
#include <LibJS/Runtime/MarkedValueList.h>
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/PrivateEnvironment.h>
|
||||
#include <LibJS/Runtime/PropertyDescriptor.h>
|
||||
#include <LibJS/Runtime/PropertyName.h>
|
||||
#include <LibJS/Runtime/Shape.h>
|
||||
|
@ -28,6 +29,18 @@ public: \
|
|||
using Base = base_class; \
|
||||
virtual const char* class_name() const override { return #class_; }
|
||||
|
||||
struct PrivateElement {
|
||||
enum class Kind {
|
||||
Field,
|
||||
Method,
|
||||
Accessor
|
||||
};
|
||||
|
||||
PrivateName key;
|
||||
Kind kind { Kind::Field };
|
||||
Value value;
|
||||
};
|
||||
|
||||
class Object : public Cell {
|
||||
public:
|
||||
static Object* create(GlobalObject&, Object* prototype);
|
||||
|
@ -90,6 +103,13 @@ public:
|
|||
ThrowCompletionOr<MarkedValueList> enumerable_own_property_names(PropertyKind kind) const;
|
||||
ThrowCompletionOr<Object*> copy_data_properties(Value source, HashTable<PropertyName, PropertyNameTraits> const& seen_names, GlobalObject& global_object);
|
||||
|
||||
PrivateElement* private_element_find(PrivateName const& name);
|
||||
ThrowCompletionOr<void> private_field_add(PrivateName const& name, Value value);
|
||||
ThrowCompletionOr<void> private_method_or_accessor_add(PrivateElement element);
|
||||
ThrowCompletionOr<Value> private_get(PrivateName const& name);
|
||||
ThrowCompletionOr<void> private_set(PrivateName const& name, Value value);
|
||||
ThrowCompletionOr<void> define_field(Variant<PropertyName, PrivateName> name, ECMAScriptFunctionObject* initializer);
|
||||
|
||||
// 10.1 Ordinary Object Internal Methods and Internal Slots, https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots
|
||||
|
||||
virtual ThrowCompletionOr<Object*> internal_get_prototype_of() const;
|
||||
|
@ -192,6 +212,7 @@ private:
|
|||
Shape* m_shape { nullptr };
|
||||
Vector<Value> m_storage;
|
||||
IndexedProperties m_indexed_properties;
|
||||
Vector<PrivateElement> m_private_elements; // [[PrivateElements]]
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue