INNER CODE UNIT · Rust
save_loop_image
GuildOfWeavers/distaff · src/processor/decoder/mod.rs:375
fn save_loop_image(&mut self, loop_image: u128) {
// increment loop depth and make sure it doesn't overflow the stack
self.loop_depth += 1;
assert!(self.loop_depth <= MAX_LOOP_DEPTH, "loop stack overflow at step {}", self.step);
// if the depth exceeds current number of registers allocated for the loop stack,
// add a new register trace to the stack
if self.loop_depth > self.loop_stack.len() {
self.loop_stack.push(vec![field::ZERO; self.trace_length()]);
}
// shift all stack values by one to the right
for i in 1..self.loop_stack.len() {
self.loop_stack[i][self.step] = self.loop_stack[i - 1][self.step - 1];
}
// set the top of the stack to loop_image
self.loop_stack[0][self.step] = loop_image;