use super::*;
#[derive(Debug)]
pub struct ImlPeek {
body: ImlOp,
}
impl ImlPeek {
pub fn new(body: ImlOp) -> ImlOp {
Self { body }.into_op()
}
}
impl Compileable for ImlPeek {
fn resolve(&mut self, usages: &mut Vec<Vec<ImlOp>>) {
self.body.resolve(usages);
}
fn finalize(
&mut self,
values: &Vec<ImlValue>,
stack: &mut Vec<(usize, bool)>,
) -> Option<Consumable> {
self.body.finalize(values, stack)
}
fn compile(&self, parselet: &ImlParselet) -> Vec<Op> {
let mut ret = Vec::new();
ret.push(Op::Frame(0));
ret.extend(self.body.compile(parselet));
ret.push(Op::Reset);
ret.push(Op::Close);
ret
}
}
impl std::fmt::Display for ImlPeek {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "peek {}", self.body)
}
}