nexus_lib/evaluator/
env.rs1use std::collections::HashMap;
2
3use super::objects::Object;
4
5#[derive(Debug)]
6pub struct Environment {
7 store: HashMap<String, EnvObj>
8}
9
10#[derive(Debug)]
11pub struct EnvObj {
12 pub obj: Object,
13 pub is_const: bool,
14}
15
16impl Environment {
17 pub fn new() -> Self {
18 Self { store: HashMap::new() }
19 }
20
21 pub fn set(&mut self, key: String, obj: EnvObj) {
22 self.store.insert(key, obj);
23 }
24
25 pub fn get(&mut self, key: String) -> Option<&EnvObj> {
26 self.store.get(&key)
27 }
28}