git.delta.rocks / jrsonnet / refs/commits / 4accdd0afdc9

difftreelog

fix(evaluator) wrap TLA evaluation in state

Lach2020-08-26parent: #ee1b2e4.patch.diff
in: master

1 file changed

modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
330330
331 /// If passed value is function then call with set TLA331 /// If passed value is function then call with set TLA
332 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}
343345
408 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