Get a handle to the next frame up the activation (the one that called this frame), if any.
(&self, mut store: impl AsContextMut)
| 457 | /// Get a handle to the next frame up the activation (the one that |
| 458 | /// called this frame), if any. |
| 459 | pub fn parent(&self, mut store: impl AsContextMut) -> Result<Option<FrameHandle>> { |
| 460 | let mut store = store.as_context_mut(); |
| 461 | if !self.is_valid(&mut store) { |
| 462 | crate::error::bail!("Frame handle is no longer valid."); |
| 463 | } |
| 464 | |
| 465 | let mut parent = self.clone(); |
| 466 | parent.virtual_frame_idx += 1; |
| 467 | |
| 468 | while !parent.cursor.done() { |
| 469 | let (cache, registry) = store |
| 470 | .0 |
| 471 | .as_store_opaque() |
| 472 | .frame_data_cache_mut_and_registry(); |
| 473 | let frames = cache.lookup_or_compute(registry, parent.cursor.frame()); |
| 474 | if parent.virtual_frame_idx < frames.len() { |
| 475 | return Ok(Some(parent)); |
| 476 | } |
| 477 | parent.virtual_frame_idx = 0; |
| 478 | // SAFETY: activation is valid because we checked validity |
| 479 | // wrt execution version at the top of this function, and |
| 480 | // we have not returned since. |
| 481 | unsafe { |
| 482 | parent.cursor.advance(store.0.as_store_opaque().unwinder()); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | Ok(None) |
| 487 | } |
| 488 | |
| 489 | fn frame_data<'a>(&self, store: &'a mut StoreOpaque) -> Result<&'a FrameData> { |
| 490 | if !self.is_valid_impl(store) { |
no test coverage detected