microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
compiler/qsc_eval/src/debug.rs
45lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | use qsc_data_structures::span::Span; |
| 5 | |
| 6 | use qsc_data_structures::functors::FunctorApp; |
| 7 | use qsc_fir::fir::{PackageId, StoreItemId}; |
| 8 | |
| 9 | #[derive(Clone, Copy, Debug, PartialEq)] |
| 10 | pub struct Frame { |
| 11 | pub span: Span, |
| 12 | pub id: StoreItemId, |
| 13 | pub caller: PackageId, |
| 14 | pub functor: FunctorApp, |
| 15 | } |
| 16 | |
| 17 | #[derive(Debug, Default, Clone, PartialEq)] |
| 18 | pub struct CallStack { |
| 19 | frames: Vec<Frame>, |
| 20 | } |
| 21 | |
| 22 | impl CallStack { |
| 23 | #[must_use] |
| 24 | pub fn is_empty(&self) -> bool { |
| 25 | self.frames.is_empty() |
| 26 | } |
| 27 | |
| 28 | #[must_use] |
| 29 | pub fn len(&self) -> usize { |
| 30 | self.frames.len() |
| 31 | } |
| 32 | |
| 33 | #[must_use] |
| 34 | pub fn into_frames(self) -> Vec<Frame> { |
| 35 | self.frames |
| 36 | } |
| 37 | |
| 38 | pub fn push_frame(&mut self, frame: Frame) { |
| 39 | self.frames.push(frame); |
| 40 | } |
| 41 | |
| 42 | pub fn pop_frame(&mut self) -> Option<Frame> { |
| 43 | self.frames.pop() |
| 44 | } |
| 45 | } |