difftreelog
fix(evaluator) wrap TLA evaluation in state
in: master
1 file changed
crates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth330330331 /// If passed value is function then call with set TLA331 /// If passed value is function then call with set TLA332 pub fn with_tla(&self, val: Val) -> Result<Val> {332 pub fn with_tla(&self, val: Val) -> Result<Val> {333 self.run_in_state(|| {333 Ok(match val {334 Ok(match val {334 Val::Func(func) => func.evaluate_map(335 Val::Func(func) => func.evaluate_map(335 self.create_default_context()?,336 self.create_default_context()?,338 )?,339 )?,339 v => v,340 v => v,340 })341 })341 }342 })343 }342}344}343345408 pub fn add_tla_code(&self, name: Rc<str>, code: Rc<str>) -> Result<()> {410 pub fn add_tla_code(&self, name: Rc<str>, code: Rc<str>) -> Result<()> {409 let value =411 let value =410 self.evaluate_snippet_raw(Rc::new(PathBuf::from(format!("tla_code {}", name))), code)?;412 self.evaluate_snippet_raw(Rc::new(PathBuf::from(format!("tla_code {}", name))), code)?;411 self.add_ext_var(name, value);413 self.add_tla(name, value);412 Ok(())414 Ok(())413 }415 }414416