Replace a block parameter with a new value of type `ty`. The `old_value` must be an attached block parameter. It is removed from its place in the list of parameters and replaced by a new value of type `new_type`. The new value gets the same position in the list, and other parameters are not disturbed. The old value is left detached, so it should probably be changed into something else. Returns
(&mut self, old_value: Value, new_type: Type)
| 1365 | /// |
| 1366 | /// Returns the new value. |
| 1367 | pub fn replace_block_param(&mut self, old_value: Value, new_type: Type) -> Value { |
| 1368 | // Create new value identical to the old one except for the type. |
| 1369 | let (block, num) = |
| 1370 | if let ValueData::Param { num, block, .. } = ValueData::from(self.values[old_value]) { |
| 1371 | (block, num) |
| 1372 | } else { |
| 1373 | panic!("{old_value} must be a block parameter"); |
| 1374 | }; |
| 1375 | let new_arg = self.make_value(ValueData::Param { |
| 1376 | ty: new_type, |
| 1377 | num, |
| 1378 | block, |
| 1379 | }); |
| 1380 | |
| 1381 | self.blocks[block] |
| 1382 | .params |
| 1383 | .as_mut_slice(&mut self.value_lists)[num as usize] = new_arg; |
| 1384 | new_arg |
| 1385 | } |
| 1386 | |
| 1387 | /// Detach all the parameters from `block` and return them as a `ValueList`. |
| 1388 | /// |