Allow getting nested map values
This commit is contained in:
parent
47cc649f8d
commit
fda852f69a
@ -85,7 +85,17 @@ 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> {
|
||||||
self.variables.get(identifier)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call_function(&self, identifier: &str, argument: &Value) -> EvalexprResult<Value> {
|
fn call_function(&self, identifier: &str, argument: &Value) -> EvalexprResult<Value> {
|
||||||
|
Loading…
Reference in New Issue
Block a user