mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
LibJS: De-duplicate ClassFieldDefinition Records
This was defined twice, despite being the very same thing: - ClassElement::ClassFieldDefinition - ECMAScriptFunctionObject::InstanceField Move the former to a new header and use it everywhere. Also update the define_field() AO to take a single field instead of separate name and initializer arguments.
This commit is contained in:
parent
7a02d33cd5
commit
e815d3f9ce
9 changed files with 66 additions and 41 deletions
|
@ -68,13 +68,8 @@ public:
|
|||
String const& source_text() const { return m_source_text; }
|
||||
void set_source_text(String source_text) { m_source_text = move(source_text); }
|
||||
|
||||
struct InstanceField {
|
||||
Variant<PropertyKey, PrivateName> name;
|
||||
ECMAScriptFunctionObject* initializer { nullptr };
|
||||
};
|
||||
|
||||
Vector<InstanceField> const& fields() const { return m_fields; }
|
||||
void add_field(Variant<PropertyKey, PrivateName> property_key, ECMAScriptFunctionObject* initializer);
|
||||
Vector<ClassFieldDefinition> const& fields() const { return m_fields; }
|
||||
void add_field(ClassFieldDefinition field) { m_fields.append(move(field)); }
|
||||
|
||||
Vector<PrivateElement> const& private_methods() const { return m_private_methods; }
|
||||
void add_private_method(PrivateElement method) { m_private_methods.append(move(method)); };
|
||||
|
@ -123,7 +118,7 @@ private:
|
|||
ScriptOrModule m_script_or_module; // [[ScriptOrModule]]
|
||||
Object* m_home_object { nullptr }; // [[HomeObject]]
|
||||
String m_source_text; // [[SourceText]]
|
||||
Vector<InstanceField> m_fields; // [[Fields]]
|
||||
Vector<ClassFieldDefinition> m_fields; // [[Fields]]
|
||||
Vector<PrivateElement> m_private_methods; // [[PrivateMethods]]
|
||||
Variant<PropertyKey, PrivateName, Empty> m_class_field_initializer_name; // [[ClassFieldInitializerName]]
|
||||
ConstructorKind m_constructor_kind : 1 { ConstructorKind::Base }; // [[ConstructorKind]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue