Allow getting nested map values

This commit is contained in:
Jeff 2023-06-23 22:52:08 -04:00
parent 47cc649f8d
commit fda852f69a

View File

@ -85,8 +85,18 @@ impl VariableMap {
impl Context for VariableMap { impl Context for VariableMap {
fn get_value(&self, identifier: &str) -> Option<&Value> { fn get_value(&self, identifier: &str) -> Option<&Value> {
let split = identifier.split_once(".");
if let Some((map_name, next_identifier)) = split {
let value = self.variables.get(map_name)?;
if let Value::Map(map) = value {
map.get_value(next_identifier)
} else {
None
}
} else {
self.variables.get(identifier) self.variables.get(identifier)
} }
}
fn call_function(&self, identifier: &str, argument: &Value) -> EvalexprResult<Value> { fn call_function(&self, identifier: &str, argument: &Value) -> EvalexprResult<Value> {
match identifier { match identifier {