mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 22:25:07 +00:00
LibJS/Bytecode: Add some basic codegen for ExportStatement
This is by no means complete, but at least a bunch of test-js and test262 tests start working. :^)
This commit is contained in:
parent
5d79431859
commit
06ac768c8b
2 changed files with 28 additions and 0 deletions
|
@ -2743,4 +2743,30 @@ Bytecode::CodeGenerationErrorOr<void> ImportCall::generate_bytecode(Bytecode::Ge
|
|||
return {};
|
||||
}
|
||||
|
||||
Bytecode::CodeGenerationErrorOr<void> ExportStatement::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
if (!is_default_export()) {
|
||||
if (m_statement) {
|
||||
return m_statement->generate_bytecode(generator);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
VERIFY(m_statement);
|
||||
|
||||
if (is<FunctionDeclaration>(*m_statement) || is<ClassDeclaration>(*m_statement)) {
|
||||
return m_statement->generate_bytecode(generator);
|
||||
}
|
||||
|
||||
if (is<ClassExpression>(*m_statement)) {
|
||||
TODO();
|
||||
}
|
||||
|
||||
// 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));
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue