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
use cl_interpret::{
    env::Environment, error::IResult, interpret::Interpret, convalue::ConValue,
};

#[derive(Clone, Debug)]
pub struct Context {
    pub env: Environment,
}

impl Context {
    pub fn new() -> Self {
        Self { env: Environment::new() }
    }
    pub fn with_env(env: Environment) -> Self {
        Self { env }
    }
    pub fn run(&mut self, code: &impl Interpret) -> IResult<ConValue> {
        code.interpret(&mut self.env)
    }
}

impl Default for Context {
    fn default() -> Self {
        Self::new()
    }
}