conlang: Move all cl-libs into the compiler directory
This commit is contained in:
26
compiler/cl-repl/src/ctx.rs
Normal file
26
compiler/cl-repl/src/ctx.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use cl_interpret::{
|
||||
env::Environment, error::IResult, interpret::Interpret, temp_type_impl::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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user