mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +00:00
LibJS: Add Object.defineProperty() and start caring about attributes
We now care (a little bit) about the "configurable" and "writable" property attributes. Property attributes are stored together with the property name in the Shape object. Forward transitions are not attribute-savvy and will cause poor Shape reuse in the case of multiple same-name properties with different attributes. Oh, and this patch also adds Object.getOwnPropertyDescriptor() :^)
This commit is contained in:
parent
1570e67881
commit
e6d920d87d
7 changed files with 121 additions and 16 deletions
|
@ -35,6 +35,14 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
struct Attribute {
|
||||
enum {
|
||||
Configurable = 1 << 0,
|
||||
Enumerable = 1 << 1,
|
||||
Writable = 1 << 2,
|
||||
};
|
||||
};
|
||||
|
||||
struct PropertyMetadata {
|
||||
size_t offset { 0 };
|
||||
u8 attributes { 0 };
|
||||
|
@ -45,7 +53,7 @@ public:
|
|||
virtual ~Shape() override;
|
||||
|
||||
Shape();
|
||||
Shape(Shape* previous_shape, const FlyString& property_name, u8 property_attributes);
|
||||
Shape(Shape* previous_shape, const FlyString& property_name, u8 attributes);
|
||||
Shape(Shape* previous_shape, Object* new_prototype);
|
||||
|
||||
Shape* create_put_transition(const FlyString& name, u8 attributes);
|
||||
|
@ -71,7 +79,7 @@ private:
|
|||
HashMap<FlyString, Shape*> m_forward_transitions;
|
||||
Shape* m_previous { nullptr };
|
||||
FlyString m_property_name;
|
||||
u8 m_property_attributes { 0 };
|
||||
u8 m_attributes { 0 };
|
||||
Object* m_prototype { nullptr };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue