LibJS/Bytecode: Make ClassDeclaration not clobber the accumulator

2 new passes on test262. :^)
This commit is contained in:
Andreas Kling 2023-07-05 12:51:44 +02:00
parent e87d84f883
commit 7430dee5cf

View file

@ -2303,8 +2303,13 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
Bytecode::CodeGenerationErrorOr<void> ClassDeclaration::generate_bytecode(Bytecode::Generator& generator) const
{
auto accumulator_backup_reg = generator.allocate_register();
generator.emit<Bytecode::Op::Store>(accumulator_backup_reg);
TRY(m_class_expression->generate_bytecode(generator));
generator.emit<Bytecode::Op::SetVariable>(generator.intern_identifier(m_class_expression.ptr()->name()), Bytecode::Op::SetVariable::InitializationMode::Initialize);
generator.emit<Bytecode::Op::Load>(accumulator_backup_reg);
return {};
}