summaryrefslogtreecommitdiff
path: root/src/eval/scope.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval/scope.rs')
-rw-r--r--src/eval/scope.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/eval/scope.rs b/src/eval/scope.rs
index c0624393..c9ce1423 100644
--- a/src/eval/scope.rs
+++ b/src/eval/scope.rs
@@ -3,12 +3,12 @@
use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter};
-use super::value::ValueFunc;
+use super::Value;
/// A map from identifiers to functions.
#[derive(Default, Clone, PartialEq)]
pub struct Scope {
- functions: HashMap<String, ValueFunc>,
+ values: HashMap<String, Value>,
}
impl Scope {
@@ -18,19 +18,19 @@ impl Scope {
Self::default()
}
- /// Return the function with the given name if there is one.
- pub fn get(&self, name: &str) -> Option<&ValueFunc> {
- self.functions.get(name)
+ /// Return the value of the given variable.
+ pub fn get(&self, var: &str) -> Option<&Value> {
+ self.values.get(var)
}
- /// Associate the given name with the function.
- pub fn set(&mut self, name: impl Into<String>, function: ValueFunc) {
- self.functions.insert(name.into(), function);
+ /// Store the value for the given variable.
+ pub fn set(&mut self, var: impl Into<String>, value: impl Into<Value>) {
+ self.values.insert(var.into(), value.into());
}
}
impl Debug for Scope {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- f.debug_set().entries(self.functions.keys()).finish()
+ self.values.fmt(f)
}
}