1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-28 21:02:07 +00:00

LibJS: Fix codegen for nodes after try statements without 'finally'

Previously we were just dropping them on the ground :P
This commit is contained in:
Ali Mohammad Pur 2021-11-10 22:22:26 +03:30 committed by Linus Groh
parent 5a38f86f1b
commit b96118b5d1
4 changed files with 43 additions and 2 deletions

View file

@ -1189,8 +1189,15 @@ void TryStatement::generate_bytecode(Bytecode::Generator& generator) const
generator.switch_to_basic_block(target_block);
m_block->generate_bytecode(generator);
if (m_finalizer && !generator.is_current_block_terminated())
generator.emit<Bytecode::Op::Jump>(finalizer_target);
if (!generator.is_current_block_terminated()) {
if (m_finalizer) {
generator.emit<Bytecode::Op::Jump>(finalizer_target);
} else {
auto& block = generator.make_block();
generator.emit<Bytecode::Op::FinishUnwind>(Bytecode::Label { block });
next_block = &block;
}
}
generator.switch_to_basic_block(next_block ? *next_block : saved_block);
}