MCPcopy Create free account
hub / github.com/ControlCplusControlV/Scribe / get_const_variables

Method get_const_variables

crates/papyrus/src/ast_optimization.rs:54–65  ·  view source on GitHub ↗

Checks for variables that are only assigned once and returns a hashmap of the variables to convert into constants.

(&self)

Source from the content-addressed store, hash-verified

52impl 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected