mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +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
|
@ -777,19 +777,21 @@ private:
|
|||
|
||||
class NewFunction final : public Instruction {
|
||||
public:
|
||||
explicit NewFunction(FunctionNode const& function_node)
|
||||
explicit NewFunction(FunctionNode const& function_node, Optional<Register> home_object = {})
|
||||
: Instruction(Type::NewFunction)
|
||||
, m_function_node(function_node)
|
||||
, m_home_object(move(home_object))
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
|
||||
void replace_references_impl(Register, Register) { }
|
||||
void replace_references_impl(Register, Register);
|
||||
|
||||
private:
|
||||
FunctionNode const& m_function_node;
|
||||
Optional<Register> m_home_object;
|
||||
};
|
||||
|
||||
class Return final : public Instruction {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue