|
@@ -831,8 +831,16 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation
|
|
|
Bytecode::Label { end_block });
|
|
|
}
|
|
|
|
|
|
+ if (m_update) {
|
|
|
+ generator.switch_to_basic_block(*update_block_ptr);
|
|
|
+ TRY(m_update->generate_bytecode(generator));
|
|
|
+ generator.emit<Bytecode::Op::Jump>().set_targets(
|
|
|
+ Bytecode::Label { *test_block_ptr },
|
|
|
+ {});
|
|
|
+ }
|
|
|
+
|
|
|
generator.switch_to_basic_block(*body_block_ptr);
|
|
|
- generator.begin_continuable_scope(Bytecode::Label { *update_block_ptr }, label_set);
|
|
|
+ generator.begin_continuable_scope(Bytecode::Label { m_update ? *update_block_ptr : *test_block_ptr }, label_set);
|
|
|
generator.begin_breakable_scope(Bytecode::Label { end_block }, label_set);
|
|
|
TRY(m_body->generate_bytecode(generator));
|
|
|
generator.end_breakable_scope();
|
|
@@ -843,14 +851,11 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation
|
|
|
generator.emit<Bytecode::Op::Jump>().set_targets(
|
|
|
Bytecode::Label { *update_block_ptr },
|
|
|
{});
|
|
|
-
|
|
|
- generator.switch_to_basic_block(*update_block_ptr);
|
|
|
- TRY(m_update->generate_bytecode(generator));
|
|
|
+ } else {
|
|
|
+ generator.emit<Bytecode::Op::Jump>().set_targets(
|
|
|
+ Bytecode::Label { *test_block_ptr },
|
|
|
+ {});
|
|
|
}
|
|
|
-
|
|
|
- generator.emit<Bytecode::Op::Jump>().set_targets(
|
|
|
- Bytecode::Label { *test_block_ptr },
|
|
|
- {});
|
|
|
}
|
|
|
|
|
|
generator.switch_to_basic_block(end_block);
|