Skip to content

Commit

Permalink
fix(evaluator): wrap TLA evaluation in state
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Aug 26, 2020
1 parent ee1b2e4 commit 4accdd0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crates/jrsonnet-evaluator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,15 @@ impl EvaluationState {

/// If passed value is function then call with set TLA
pub fn with_tla(&self, val: Val) -> Result<Val> {
Ok(match val {
Val::Func(func) => func.evaluate_map(
self.create_default_context()?,
&self.settings().tla_vars,
true,
)?,
v => v,
self.run_in_state(|| {
Ok(match val {
Val::Func(func) => func.evaluate_map(
self.create_default_context()?,
&self.settings().tla_vars,
true,
)?,
v => v,
})
})
}
}
Expand Down Expand Up @@ -408,7 +410,7 @@ impl EvaluationState {
pub fn add_tla_code(&self, name: Rc<str>, code: Rc<str>) -> Result<()> {
let value =
self.evaluate_snippet_raw(Rc::new(PathBuf::from(format!("tla_code {}", name))), code)?;
self.add_ext_var(name, value);
self.add_tla(name, value);
Ok(())
}

Expand Down

0 comments on commit 4accdd0

Please sign in to comment.