use crate::data::{
functions::Scope,
token::Span,
};
#[derive(Clone, Debug)]
pub struct CallStack {
pub frames: Vec<StackFrame>,
}
impl CallStack {
pub fn new() -> Self {
Self {
frames: Vec::new(),
}
}
pub fn operator(&self) -> &StackFrame {
self.frames.last()
.expect("Tried to get operator from empty call stack")
}
pub fn caller(&self) -> Option<&StackFrame> {
if self.frames.len() < 2 {
return None;
}
Some(&self.frames[self.frames.len() - 2])
}
}
#[derive(Clone, Debug)]
pub struct StackFrame {
pub scope: Scope,
pub span: Span,
}