diff options
author | davidot <davidot@serenityos.org> | 2021-10-20 21:29:47 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-20 23:19:17 +0100 |
commit | 6b2accce317e1226feaf627ddd5fbca100eb7265 (patch) | |
tree | 3a3e8a589bdb17ba630109ec3d2b4268076a6b48 /Userland/Libraries/LibJS/AST.h | |
parent | 1245512c508d88e2a025d9d4e58297f76afd34bb (diff) | |
download | serenity-6b2accce317e1226feaf627ddd5fbca100eb7265.zip |
LibJS: Add static initializers to classes
Diffstat (limited to 'Userland/Libraries/LibJS/AST.h')
-rw-r--r-- | Userland/Libraries/LibJS/AST.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h index be7806a4f0..774e34df74 100644 --- a/Userland/Libraries/LibJS/AST.h +++ b/Userland/Libraries/LibJS/AST.h @@ -1013,6 +1013,7 @@ public: enum class ElementKind { Method, Field, + StaticInitializer, }; virtual ElementKind class_element_kind() const = 0; @@ -1023,6 +1024,7 @@ public: ECMAScriptFunctionObject* initializer { nullptr }; }; + // We use the Completion also as a ClassStaticBlockDefinition Record. using ClassValue = Variant<ClassFieldDefinition, Completion>; virtual ThrowCompletionOr<ClassValue> class_element_evaluation(Interpreter&, GlobalObject&, Object& home_object) const = 0; @@ -1082,6 +1084,25 @@ private: RefPtr<Expression> m_initializer; }; +class StaticInitializer final : public ClassElement { +public: + StaticInitializer(SourceRange source_range, NonnullRefPtr<FunctionBody> function_body, bool contains_direct_call_to_eval) + : ClassElement(source_range, true) + , m_function_body(move(function_body)) + , m_contains_direct_call_to_eval(contains_direct_call_to_eval) + { + } + + virtual ElementKind class_element_kind() const override { return ElementKind::StaticInitializer; } + virtual ThrowCompletionOr<ClassValue> class_element_evaluation(Interpreter&, GlobalObject&, Object& home_object) const override; + + virtual void dump(int indent) const override; + +private: + NonnullRefPtr<FunctionBody> m_function_body; + bool m_contains_direct_call_to_eval { false }; +}; + class SuperExpression final : public Expression { public: explicit SuperExpression(SourceRange source_range) |