This commit is contained in:
JT 2021-10-26 06:46:26 +13:00
parent 5d19017603
commit f84582ca2b
2 changed files with 3 additions and 43 deletions

View File

@ -1,9 +1,9 @@
mod call_info; mod call_info;
mod command; mod command;
mod engine_state; mod engine_state;
mod evaluation_context; mod stack;
pub use call_info::*; pub use call_info::*;
pub use command::*; pub use command::*;
pub use engine_state::*; pub use engine_state::*;
pub use evaluation_context::*; pub use stack::*;

View File

@ -1,46 +1,6 @@
use super::EngineState;
use std::collections::HashMap; use std::collections::HashMap;
use crate::{Example, ShellError, Signature, Value, VarId}; use crate::{ShellError, Value, VarId};
#[derive(Clone)]
pub struct EvaluationContext {
pub engine_state: Box<EngineState>,
pub stack: Stack,
}
impl EvaluationContext {
pub fn get_var(&self, var_id: VarId) -> Result<Value, ShellError> {
self.stack.get_var(var_id)
}
pub fn enter_scope(&self) -> EvaluationContext {
Self {
engine_state: self.engine_state.clone(),
stack: self.stack.clone().enter_scope(),
}
}
pub fn add_var(&mut self, var_id: VarId, value: Value) {
self.stack.add_var(var_id, value);
}
pub fn add_env_var(&mut self, var: String, value: String) {
self.stack.add_env_var(var, value);
}
pub fn print_stack(&self) {
self.stack.print_stack();
}
pub fn get_signatures(&self) -> Vec<Signature> {
self.engine_state.get_signatures()
}
pub fn get_signatures_with_examples(&self) -> Vec<(Signature, Vec<Example>)> {
self.engine_state.get_signatures_with_examples()
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct StackFrame { pub struct StackFrame {