| 1630 | } |
| 1631 | |
| 1632 | fn set_globals(&'r mut self, new_vars: VariableDefinitions, mathml: Element<'c>) -> Result<()> { |
| 1633 | // for each var/value pair, evaluate the value and add the var/value to the base context |
| 1634 | for def in &new_vars.defs { |
| 1635 | // set the new value |
| 1636 | let new_value = match def.value.evaluate(&self.base, mathml) { |
| 1637 | Ok(val) => val, |
| 1638 | Err(_) => bail!(format!("Can't evaluate variable def for {}", def)), |
| 1639 | }; |
| 1640 | let qname = QName::new(def.name.as_str()); |
| 1641 | self.base.set_variable(qname, new_value); |
| 1642 | } |
| 1643 | return Ok( () ); |
| 1644 | } |
| 1645 | |
| 1646 | fn push(&'r mut self, new_vars: VariableDefinitions, mathml: Element<'c>) -> Result<()> { |
| 1647 | // store the old value and set the new one |