mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibJS/Bytecode: Improve export statement handling
This adds support for exporting class expressions, which was previously TODO'd. We now correctly set the binding name of exports to `"*default*"` if they are unnamed. I'm not sure what the difference between the `InitializationMode` kinds is, but using `Initialize` fixes a bunch of tests. Note that some export tests (e.g. `eval-export-dflt-expr-cls-named.js`) still fail, as we don't set the "name" property of exported classes correctly. 176 new passes on test262
This commit is contained in:
parent
11a7014b4e
commit
fc7de74b12
Notes:
sideshowbarker
2024-07-17 20:22:04 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/fc7de74b12 Pull-request: https://github.com/SerenityOS/serenity/pull/19677
|
@ -2857,13 +2857,18 @@ Bytecode::CodeGenerationErrorOr<void> ExportStatement::generate_bytecode(Bytecod
|
|||
}
|
||||
|
||||
if (is<ClassExpression>(*m_statement)) {
|
||||
TODO();
|
||||
TRY(m_statement->generate_bytecode(generator));
|
||||
|
||||
if (!static_cast<ClassExpression const&>(*m_statement).has_name())
|
||||
generator.emit<Bytecode::Op::SetVariable>(generator.intern_identifier(ExportStatement::local_name_for_default), Bytecode::Op::SetVariable::InitializationMode::Initialize);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// ExportDeclaration : export default AssignmentExpression ;
|
||||
VERIFY(is<Expression>(*m_statement));
|
||||
TRY(generator.emit_named_evaluation_if_anonymous_function(static_cast<Expression const&>(*m_statement), DeprecatedFlyString("default"sv)));
|
||||
generator.emit<Bytecode::Op::SetVariable>(generator.intern_identifier("default"sv));
|
||||
generator.emit<Bytecode::Op::SetVariable>(generator.intern_identifier(ExportStatement::local_name_for_default), Bytecode::Op::SetVariable::InitializationMode::Initialize);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue