1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use crate::{
    eval::{Eval, Expr, GetEntry},
    op::Ret,
    types,
};

pub fn zero_value<O>() -> Ret<Zero, O>
where
    O: types::Value,
{
    Ret::new(Zero(()))
}

pub struct Zero(());

impl<O, E> Eval<E> for Ret<Zero, O>
where
    O: types::Value,
    E: GetEntry,
{
    type Out = O;

    fn eval(self, en: &mut E) -> Expr {
        let en = en.get_entry();
        let ty = en.new_type(O::VALUE_TYPE.ty());
        en.zero_value(ty)
    }
}