mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:27:35 +00:00
LibJS/Bytecode: Setup lexical environment boundary for with statements
This allows us to properly unwind the object environment for `with` on a block terminating instruction, e.g. an unconditional throw.
This commit is contained in:
parent
9f4cc6435d
commit
04774f923f
1 changed files with 8 additions and 1 deletions
|
@ -1625,8 +1625,15 @@ Bytecode::CodeGenerationErrorOr<void> WithStatement::generate_bytecode(Bytecode:
|
||||||
{
|
{
|
||||||
TRY(m_object->generate_bytecode(generator));
|
TRY(m_object->generate_bytecode(generator));
|
||||||
generator.emit<Bytecode::Op::EnterObjectEnvironment>();
|
generator.emit<Bytecode::Op::EnterObjectEnvironment>();
|
||||||
|
|
||||||
|
// EnterObjectEnvironment sets the running execution context's lexical_environment to a new Object Environment.
|
||||||
|
generator.start_boundary(Bytecode::Generator::BlockBoundaryType::LeaveLexicalEnvironment);
|
||||||
TRY(m_body->generate_bytecode(generator));
|
TRY(m_body->generate_bytecode(generator));
|
||||||
generator.emit<Bytecode::Op::LeaveEnvironment>(Bytecode::Op::EnvironmentMode::Lexical);
|
generator.end_boundary(Bytecode::Generator::BlockBoundaryType::LeaveLexicalEnvironment);
|
||||||
|
|
||||||
|
if (!generator.is_current_block_terminated())
|
||||||
|
generator.emit<Bytecode::Op::LeaveEnvironment>(Bytecode::Op::EnvironmentMode::Lexical);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue