use std::collections::HashMap;
#[derive(Clone)]
pub struct EvalContext {
pub(crate) allow_random: bool,
pub(crate) allow_side_effects: bool,
pub(crate) prng_state: u64,
pub(crate) gauss_spare: Option<f64>,
pub(crate) memory_registers: HashMap<String, f64>,
pub(crate) user_variables: HashMap<String, f64>,
}
impl EvalContext {
pub fn new() -> Self {
Self {
allow_random: true,
allow_side_effects: true,
prng_state: 123456789,
gauss_spare: None,
memory_registers: HashMap::new(),
user_variables: HashMap::new(),
}
}
pub fn mcp_mode() -> Self {
Self {
allow_random: false,
allow_side_effects: false,
prng_state: 123456789,
gauss_spare: None,
memory_registers: HashMap::new(),
user_variables: HashMap::new(),
}
}
pub fn with_prng_state(mut self, state: u64) -> Self {
self.prng_state = if state == 0 { 123456789 } else { state };
self
}
pub fn with_memory_registers(mut self, registers: HashMap<String, f64>) -> Self {
self.memory_registers = registers;
self
}
pub fn with_user_variables(mut self, variables: HashMap<String, f64>) -> Self {
self.user_variables = variables;
self
}
}
impl Default for EvalContext {
fn default() -> Self {
Self::new()
}
}