sieve/runtime/
variables.rs1use crate::Context;
8
9use super::Variable;
10
11impl Context<'_> {
12 pub(crate) fn set_match_variables(&mut self, set_vars: Vec<(usize, String)>) {
13 for (var_num, value) in set_vars {
14 if let Some(var) = self.vars_match.get_mut(var_num) {
15 *var = value.into();
16 } else {
17 debug_assert!(false, "Invalid match variable {var_num}");
18 }
19 }
20 }
21
22 pub(crate) fn clear_match_variables(&mut self, mut positions: u64) {
23 while positions != 0 {
24 let index = 63 - positions.leading_zeros();
25 positions ^= 1 << index;
26 if let Some(match_var) = self.vars_match.get_mut(index as usize) {
27 if !match_var.is_empty() {
28 *match_var = Variable::default();
29 }
30 } else {
31 debug_assert!(false, "Failed to clear match variable at index {index}.");
32 }
33 }
34 }
35}