|
Expand Up
|
@@ -3384,8 +3384,6 @@ impl Compiler { |
|
|
)?; |
|
|
} |
|
|
|
|
|
let else_block = self.new_block(); |
|
|
|
|
|
// if handlers is empty, compile body directly |
|
|
// without wrapping in TryExcept (only FinallyTry is needed) |
|
|
if handlers.is_empty() { |
|
Expand Down
Expand Up
|
@@ -3487,19 +3485,11 @@ impl Compiler { |
|
|
self.compile_statements(body)?; |
|
|
emit!(self, PseudoInstruction::PopBlock); |
|
|
self.set_no_location(); |
|
|
self.remove_last_no_location_nop(); |
|
|
self.pop_fblock(FBlockType::TryExcept); |
|
|
emit!( |
|
|
self, |
|
|
PseudoInstruction::JumpNoInterrupt { delta: else_block } |
|
|
); |
|
|
self.set_no_location(); |
|
|
self.remove_last_no_location_nop(); |
|
|
|
|
|
let cleanup_block = self.new_block(); |
|
|
// We successfully ran the try block: |
|
|
// else: |
|
|
self.switch_to_block(else_block); |
|
|
self.compile_statements(orelse)?; |
|
|
|
|
|
emit!( |
|
Expand Down
Expand Up
|
@@ -5839,17 +5829,10 @@ impl Compiler { |
|
|
if is_async { |
|
|
self.set_source_range(with_range); |
|
|
} |
|
|
let preserve_pop_block_nop = !is_async && self.current_block_follows_end_async_for(); |
|
|
if preserve_pop_block_nop { |
|
|
emit!(self, Instruction::Nop); |
|
|
self.preserve_last_redundant_nop(); |
|
|
} |
|
|
emit!(self, PseudoInstruction::PopBlock); |
|
|
if !is_async { |
|
|
self.set_no_location(); |
|
|
if !preserve_pop_block_nop { |
|
|
self.remove_last_no_location_nop(); |
|
|
} |
|
|
self.remove_last_no_location_nop(); |
|
|
self.set_source_range(with_range); |
|
|
} |
|
|
self.pop_fblock(if is_async { |
|
Expand Down
Expand Up
|
@@ -10877,29 +10860,6 @@ impl Compiler { |
|
|
&mut info.blocks[info.current_block] |
|
|
} |
|
|
|
|
|
fn current_block_follows_end_async_for(&mut self) -> bool { |
|
|
let info = self.current_code_info(); |
|
|
let current = info.current_block; |
|
|
if info.blocks[current] |
|
|
.instructions |
|
|
.iter() |
|
|
.rev() |
|
|
.find_map(|info| info.instr.real()) |
|
|
.is_some_and(|instr| matches!(instr, Instruction::EndAsyncFor)) |
|
|
{ |
|
|
return true; |
|
|
} |
|
|
info.blocks.iter().any(|block| { |
|
|
block.next == current |
|
|
&& block |
|
|
.instructions |
|
|
.iter() |
|
|
.rev() |
|
|
.find_map(|info| info.instr.real()) |
|
|
.is_some_and(|instr| matches!(instr, Instruction::EndAsyncFor)) |
|
|
}) |
|
|
} |
|
|
|
|
|
fn new_block(&mut self) -> BlockIdx { |
|
|
let code = self.current_code_info(); |
|
|
let idx = BlockIdx::new(code.blocks.len().to_u32()); |
|
Expand Down
|
|