mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:15:06 +00: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
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