mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
LibJS: Fix that in Bytecode mode functions where not created anymore
This is not a proper fix as we should follow the spec here but it gets us back to a slightly more working state.
This commit is contained in:
parent
0f5fe3b70e
commit
715f9666f2
1 changed files with 18 additions and 0 deletions
|
@ -26,6 +26,24 @@ void ASTNode::generate_bytecode(Bytecode::Generator&) const
|
|||
|
||||
void ScopeNode::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
// FIXME: This is an ad-hoc fix but should be done as the spec says in
|
||||
// {Global, Block, Function, Eval}DeclarationInstantiation.
|
||||
for (auto& function : m_functions_hoistable_with_annexB_extension) {
|
||||
generator.emit<Bytecode::Op::NewFunction>(function);
|
||||
generator.emit<Bytecode::Op::SetVariable>(generator.intern_string(function.name()));
|
||||
}
|
||||
|
||||
HashTable<FlyString> functions_initialized;
|
||||
for_each_var_function_declaration_in_reverse_order([&](FunctionDeclaration const& function) {
|
||||
if (functions_initialized.set(function.name()) != AK::HashSetResult::InsertedNewEntry)
|
||||
return IterationDecision::Continue;
|
||||
|
||||
generator.emit<Bytecode::Op::NewFunction>(function);
|
||||
generator.emit<Bytecode::Op::SetVariable>(generator.intern_string(function.name()));
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
// FIXME: Register lexical and variable scope declarations
|
||||
for (auto& child : children()) {
|
||||
child.generate_bytecode(generator);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue