Insert a block at the current position and switch to it. As far as possible, this method behaves as if the block header were an instruction inserted at the current position. - If the cursor is pointing at an existing instruction, *the current block is split in two and the current instruction becomes the first instruction in the inserted block. - If the cursor points at the bottom of a block, the
(&mut self, new_block: ir::Block)
| 591 | /// This means that it is always valid to call this method, and it always leaves the cursor in |
| 592 | /// a state that will insert instructions into the new block. |
| 593 | fn insert_block(&mut self, new_block: ir::Block) { |
| 594 | use self::CursorPosition::*; |
| 595 | match self.position() { |
| 596 | At(inst) => { |
| 597 | self.layout_mut().split_block(new_block, inst); |
| 598 | // All other cases move to `After(block)`, but in this case we'll stay `At(inst)`. |
| 599 | return; |
| 600 | } |
| 601 | Nowhere => self.layout_mut().append_block(new_block), |
| 602 | Before(block) => self.layout_mut().insert_block(new_block, block), |
| 603 | After(block) => self.layout_mut().insert_block_after(new_block, block), |
| 604 | } |
| 605 | // For everything but `At(inst)` we end up appending to the new block. |
| 606 | self.set_position(After(new_block)); |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | /// Function cursor. |
nothing calls this directly
no test coverage detected