1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::collections::HashMap;
use ergotree_ir::mir::val_def::ValId;
use ergotree_ir::mir::value::Value;
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct Env {
store: HashMap<ValId, Value>,
}
impl Env {
pub fn empty() -> Env {
Env {
store: HashMap::new(),
}
}
pub fn extend(&self, idx: ValId, v: Value) -> Env {
let mut new_store = self.store.clone();
new_store.insert(idx, v);
Env { store: new_store }
}
pub fn insert(&mut self, idx: ValId, v: Value) {
self.store.insert(idx, v);
}
pub fn get(&self, idx: ValId) -> Option<&Value> {
self.store.get(&idx)
}
}