use std::fmt;
use std::fmt::Display;
use dupe::Dupe;
use crate::eval::runtime::frozen_file_span::FrozenFileSpan;
use crate::eval::runtime::inlined_frame::InlinedFrames;
#[derive(Debug, Clone, Copy, Dupe, PartialEq, Eq, Default)]
pub(crate) struct FrameSpan {
pub(crate) span: FrozenFileSpan,
pub(crate) inlined_frames: InlinedFrames,
}
impl FrameSpan {
pub(crate) const fn new(span: FrozenFileSpan) -> FrameSpan {
FrameSpan {
span,
inlined_frames: InlinedFrames { frames: None },
}
}
pub(crate) fn end_span(&self) -> FrameSpan {
FrameSpan {
span: self.span.end_span(),
inlined_frames: self.inlined_frames,
}
}
}
impl Display for FrameSpan {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Display::fmt(&self.span, f)
}
}
impl FrameSpan {
pub(crate) fn merge(&self, other: &FrameSpan) -> FrameSpan {
FrameSpan {
span: self.span.merge(&other.span),
inlined_frames: self.inlined_frames,
}
}
}