Returns true if the stack contains a local with the provided index except if the only time the local appears is the top element.
(&self, index: u32)
| 340 | /// Returns true if the stack contains a local with the provided index |
| 341 | /// except if the only time the local appears is the top element. |
| 342 | pub fn contains_latent_local(&self, index: u32) -> bool { |
| 343 | self.inner |
| 344 | .iter() |
| 345 | // Iterate top-to-bottom so we can skip the top element and stop |
| 346 | // when we see a memory element. |
| 347 | .rev() |
| 348 | // The local is not latent if it's the top element because the top |
| 349 | // element will be popped next which materializes the local. |
| 350 | .skip(1) |
| 351 | // Stop when we see a memory element because that marks where we |
| 352 | // spilled up to so there will not be any locals past this point. |
| 353 | .take_while(|v| !v.is_mem()) |
| 354 | .any(|v| v.is_local_at_index(index)) |
| 355 | } |
| 356 | |
| 357 | /// Extend the stack with the given elements. |
| 358 | pub fn extend(&mut self, values: impl IntoIterator<Item = Val>) { |
no test coverage detected