The following two helpers, handle else or end instructions when the compiler has entered into an unreachable code state. These instructions must be observed to determine if the reachability state should be restored. When the compiler is in an unreachable state, all the other instructions are not visited.
(&mut self)
| 277 | /// When the compiler is in an unreachable state, all the other instructions |
| 278 | /// are not visited. |
| 279 | pub fn handle_unreachable_else(&mut self) -> Result<()> { |
| 280 | let frame = self |
| 281 | .control_frames |
| 282 | .last_mut() |
| 283 | .ok_or_else(|| CodeGenError::control_frame_expected())?; |
| 284 | ensure!(frame.is_if(), CodeGenError::if_control_frame_expected()); |
| 285 | if frame.is_next_sequence_reachable() { |
| 286 | // We entered an unreachable state when compiling the |
| 287 | // if-then branch, but if the `if` was reachable at |
| 288 | // entry, the if-else branch will be reachable. |
| 289 | self.context.reachable = true; |
| 290 | frame.ensure_stack_state(self.masm, &mut self.context)?; |
| 291 | frame.bind_else(self.masm, &mut self.context)?; |
| 292 | } |
| 293 | Ok(()) |
| 294 | } |
| 295 | |
| 296 | pub fn handle_unreachable_end(&mut self) -> Result<()> { |
| 297 | let mut frame = self.pop_control_frame()?; |
no test coverage detected