Check that an entity refers to a valid object.
(&self, entity: Entity)
| 117 | impl<F: Function, R: RegInfo> Context<'_, F, R> { |
| 118 | /// Check that an entity refers to a valid object. |
| 119 | fn check_entity(&self, entity: Entity) -> Result<()> { |
| 120 | let (index, len) = match entity { |
| 121 | Entity::Block(x) => (x.index(), self.func.num_blocks()), |
| 122 | Entity::Value(x) => (x.index(), self.func.num_values()), |
| 123 | Entity::ValueGroup(x) => (x.index(), self.func.num_value_groups()), |
| 124 | Entity::Inst(x) => (x.index(), self.func.num_insts()), |
| 125 | }; |
| 126 | ensure!(index < len, "{entity}: Invalid entity reference"); |
| 127 | Ok(()) |
| 128 | } |
| 129 | |
| 130 | /// Checks a range of instructions. |
| 131 | fn check_inst_range(&mut self, range: InstRange) -> Result<()> { |
no test coverage detected