mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
LibJS: Add support for public fields in classes
This commit is contained in:
parent
3b6a8d1d53
commit
def8b44c40
Notes:
sideshowbarker
2024-07-18 04:58:01 +09:00
Author: https://github.com/davidot
Commit: def8b44c40
Pull-request: https://github.com/SerenityOS/serenity/pull/9664
Reviewed-by: https://github.com/linusg ✅
9 changed files with 265 additions and 11 deletions
|
@ -63,6 +63,17 @@ public:
|
|||
// This is for IsSimpleParameterList (static semantics)
|
||||
bool has_simple_parameter_list() const { return m_has_simple_parameter_list; }
|
||||
|
||||
// [[Fields]]
|
||||
struct InstanceField {
|
||||
StringOrSymbol name;
|
||||
FunctionObject* initializer { nullptr };
|
||||
|
||||
void define_field(VM& vm, Object& receiver) const;
|
||||
};
|
||||
|
||||
Vector<InstanceField> const& fields() const { return m_fields; }
|
||||
void add_field(StringOrSymbol property_key, FunctionObject* initializer);
|
||||
|
||||
protected:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
|
@ -79,6 +90,7 @@ private:
|
|||
ConstructorKind m_constructor_kind = ConstructorKind::Base;
|
||||
ThisMode m_this_mode { ThisMode::Global };
|
||||
bool m_has_simple_parameter_list { false };
|
||||
Vector<InstanceField> m_fields;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue