Checks for variables that are only assigned once and returns a hashmap of the variables to convert into constants.
(&self)
| 52 | impl VariableAssignmentVisitor { |
| 53 | // Checks for variables that are only assigned once and returns a hashmap of the variables to convert into constants. |
| 54 | fn get_const_variables(&self) -> HashMap<String, ExprLiteral> { |
| 55 | self.assignment_counter |
| 56 | .iter() |
| 57 | .filter(|(_k, v)| **v == 1) |
| 58 | .filter_map(|(k, _)| { |
| 59 | if let Some(value) = self.last_assignment.get(k) { |
| 60 | return Some((k.clone(), value.clone())); |
| 61 | } |
| 62 | None |
| 63 | }) |
| 64 | .collect::<HashMap<String, ExprLiteral>>() |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // TODO: unstable for now, as it will incorrectly transform for loops that modify the iterator in |
nothing calls this directly
no outgoing calls
no test coverage detected