| 413 | } |
| 414 | |
| 415 | fn pop_stack_shape(&mut self, n: usize) { |
| 416 | // The `stack_shape` vec represents the *clean* slots (already |
| 417 | // flushed to memory); its length is always less than or equal |
| 418 | // to `stack`, but indices always correspond between the |
| 419 | // two. Thus a pop on `stack` may or may not pop something on |
| 420 | // `stack_shape`; but if `stack` is truncated down to a length |
| 421 | // L by some number of pops, truncating `stack_shape` to that |
| 422 | // same length L will pop exactly the right shapes and will |
| 423 | // ensure that any new pushes that are "dirty" will be |
| 424 | // correctly represented as such. |
| 425 | let new_len = self.stack.len() - n; |
| 426 | self.stack_shape.truncate(new_len); |
| 427 | } |
| 428 | |
| 429 | /// Peek at the top `n` values on the stack in the order they were pushed. |
| 430 | pub(crate) fn peekn(&self, n: usize) -> &[Value] { |