1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +00:00

LibJS/Bytecode: Support class field initializers

Fixes 513 test262 tests. :^)
This commit is contained in:
Andreas Kling 2023-06-17 10:11:23 +02:00
parent 82828ad936
commit d89e0b36d4
3 changed files with 49 additions and 36 deletions

View file

@ -1455,6 +1455,26 @@ private:
NonnullRefPtr<ClassExpression const> m_class_expression;
};
// We use this class to mimic Initializer : = AssignmentExpression of
// 10.2.1.3 Runtime Semantics: EvaluateBody, https://tc39.es/ecma262/#sec-runtime-semantics-evaluatebody
class ClassFieldInitializerStatement final : public Statement {
public:
ClassFieldInitializerStatement(SourceRange source_range, NonnullRefPtr<Expression const> expression, DeprecatedFlyString field_name)
: Statement(move(source_range))
, m_expression(move(expression))
, m_class_field_identifier_name(move(field_name))
{
}
virtual Completion execute(Interpreter& interpreter) const override;
virtual void dump(int) const override;
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
private:
NonnullRefPtr<Expression const> m_expression;
DeprecatedFlyString m_class_field_identifier_name; // [[ClassFieldIdentifierName]]
};
class SpreadExpression final : public Expression {
public:
explicit SpreadExpression(SourceRange source_range, NonnullRefPtr<Expression const> target)