1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use crate::{cfgir::absint::*, parser::ast::Var};
use std::{cmp::Ordering, collections::BTreeSet};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct LivenessState(pub BTreeSet<Var>);
impl LivenessState {
pub fn initial() -> Self {
LivenessState(BTreeSet::new())
}
pub fn extend(&mut self, other: &Self) {
self.0.extend(other.0.iter().cloned());
}
}
impl AbstractDomain for LivenessState {
fn join(&mut self, other: &Self) -> JoinResult {
let before = self.0.len();
self.extend(other);
let after = self.0.len();
match before.cmp(&after) {
Ordering::Less => JoinResult::Changed,
Ordering::Equal => JoinResult::Unchanged,
Ordering::Greater => panic!("ICE set union made a set smaller than before"),
}
}
}