1use cl_interpret::{convalue::ConValue, env::Environment, error::IResult, interpret::Interpret};
2
3#[derive(Clone, Debug)]
4pub struct Context {
5 pub env: Environment,
6}
7
8impl Context {
9 pub fn new() -> Self {
10 Self { env: Environment::new() }
11 }
12 pub fn with_env(env: Environment) -> Self {
13 Self { env }
14 }
15 pub fn run(&mut self, code: &impl Interpret) -> IResult<ConValue> {
16 code.interpret(&mut self.env)
17 }
18}
19
20impl Default for Context {
21 fn default() -> Self {
22 Self::new()
23 }
24}