neo_solidity/
dataflow.rs

1//! Data Flow Analysis
2//!
3//! Tracks variable definitions and uses.
4
5use std::collections::HashSet;
6
7/// Variable state
8#[derive(Debug, Clone, Default)]
9pub struct VarState {
10    pub defined: HashSet<String>,
11    pub used: HashSet<String>,
12}
13
14impl VarState {
15    pub fn define(&mut self, name: &str) {
16        self.defined.insert(name.to_string());
17    }
18
19    pub fn use_var(&mut self, name: &str) {
20        self.used.insert(name.to_string());
21    }
22
23    pub fn unused(&self) -> Vec<&String> {
24        self.defined.difference(&self.used).collect()
25    }
26}