(
&mut self,
body: &[ast::Stmt],
handlers: &[ast::ExceptHandler],
orelse: &[ast::Stmt],
finalbody: &[ast::Stmt],
)
| 3610 | } |
| 3611 | |
| 3612 | fn compile_try_star_except( |
| 3613 | &mut self, |
| 3614 | body: &[ast::Stmt], |
| 3615 | handlers: &[ast::ExceptHandler], |
| 3616 | orelse: &[ast::Stmt], |
| 3617 | finalbody: &[ast::Stmt], |
| 3618 | ) -> CompileResult<()> { |
| 3619 | // compiler_try_star_except |
| 3620 | // Stack layout during handler processing: [prev_exc, orig, list, rest] |
| 3621 | let handler_block = self.new_block(); |
| 3622 | let finally_block = self.new_block(); |
| 3623 | let else_block = self.new_block(); |
| 3624 | let end_block = self.new_block(); |
| 3625 | let reraise_star_block = self.new_block(); |
| 3626 | let reraise_block = self.new_block(); |
| 3627 | let finally_cleanup_block = if !finalbody.is_empty() { |
| 3628 | Some(self.new_block()) |
| 3629 | } else { |
| 3630 | None |
| 3631 | }; |
| 3632 | let exit_block = self.new_block(); |
| 3633 | |
| 3634 | // Emit NOP at the try: line so LINE events fire for it |
| 3635 | emit!(self, Instruction::Nop); |
| 3636 | |
| 3637 | // Push fblock with handler info for exception table generation |
| 3638 | if !finalbody.is_empty() { |
| 3639 | emit!( |
| 3640 | self, |
| 3641 | PseudoInstruction::SetupFinally { |
| 3642 | delta: finally_block |
| 3643 | } |
| 3644 | ); |
| 3645 | self.push_fblock_full( |
| 3646 | FBlockType::FinallyTry, |
| 3647 | finally_block, |
| 3648 | finally_block, |
| 3649 | FBlockDatum::FinallyBody(finalbody.to_vec()), |
| 3650 | )?; |
| 3651 | } |
| 3652 | |
| 3653 | // SETUP_FINALLY for try body |
| 3654 | emit!( |
| 3655 | self, |
| 3656 | PseudoInstruction::SetupFinally { |
| 3657 | delta: handler_block |
| 3658 | } |
| 3659 | ); |
| 3660 | self.push_fblock(FBlockType::TryExcept, handler_block, handler_block)?; |
| 3661 | self.compile_statements(body)?; |
| 3662 | emit!(self, PseudoInstruction::PopBlock); |
| 3663 | self.pop_fblock(FBlockType::TryExcept); |
| 3664 | emit!(self, PseudoInstruction::Jump { delta: else_block }); |
| 3665 | |
| 3666 | // Exception handler entry |
| 3667 | self.switch_to_block(handler_block); |
| 3668 | // Stack: [exc] (from exception table) |
| 3669 |
no test coverage detected