use crate::kernel::Position;
#[derive(Debug, Clone, Default, PartialEq)]
pub struct SourceMap {
positions: Vec<Option<Position>>,
}
impl SourceMap {
pub(crate) fn record(&mut self, position: Option<Position>) {
self.positions.push(position);
}
pub(crate) fn pop(&mut self) {
self.positions.pop();
}
pub fn position(&self, instruction: usize) -> Option<Position> {
self.positions.get(instruction).copied().flatten()
}
pub fn len(&self) -> usize {
self.positions.len()
}
pub fn is_empty(&self) -> bool {
self.positions.is_empty()
}
}