mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
LibJS/Bytecode: Set "home object" of functions within object expression
We manage this by having a stack of home objects in Generator, and then adding an optional home object parameter to the NewFunction instruction.
This commit is contained in:
parent
a33af174b2
commit
c9bd324369
Notes:
sideshowbarker
2024-07-16 20:51:53 +09:00
Author: https://github.com/awesomekling
Commit: c9bd324369
Pull-request: https://github.com/SerenityOS/serenity/pull/19416
5 changed files with 45 additions and 4 deletions
|
@ -448,4 +448,22 @@ void Generator::generate_continue(DeprecatedFlyString const& continue_label)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void Generator::push_home_object(Register register_)
|
||||
{
|
||||
m_home_objects.append(register_);
|
||||
}
|
||||
|
||||
void Generator::pop_home_object()
|
||||
{
|
||||
m_home_objects.take_last();
|
||||
}
|
||||
|
||||
void Generator::emit_new_function(FunctionNode const& function_node)
|
||||
{
|
||||
if (m_home_objects.is_empty())
|
||||
emit<Op::NewFunction>(function_node);
|
||||
else
|
||||
emit<Op::NewFunction>(function_node, m_home_objects.last());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue