1//! Update the block indices to make sure they are consecutive
23use std::mem;
45use crate::ids::*;
6use crate::transform::TransformCtx;
7use crate::ullbc_ast::*;
89use super::ctx::UllbcPass;
1011pub struct Transform;
12impl UllbcPass for Transform {
13fn transform_body(&self, _ctx: &mut TransformCtx, b: &mut ExprBody) {
14// Push each block into a new vector to make it consecutive and return the map from old to
15 // new ids.
16let id_map: Vector<BlockId, BlockId> =
17 mem::take(&mut b.body).map(|block| b.body.push(block));
1819// Update the ids.
20b.body
21 .dyn_visit_in_body_mut(|id: &mut BlockId| *id = id_map[*id]);
22 }
23}