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
//! Compilation environment use std::collections::HashMap; use ergotree_ir::mir::constant::Constant; /// Environment with values substituted for identifiers during compilation pub struct ScriptEnv(HashMap<String, Constant>); impl Default for ScriptEnv { fn default() -> Self { Self::new() } } impl ScriptEnv { /// Empty environment pub fn new() -> Self { ScriptEnv(HashMap::new()) } /// Returns the value([`Constant`]) for the given identifier (if any) pub fn get(&self, ident: &str) -> Option<&Constant> { self.0.get(ident) } }