-
Notifications
You must be signed in to change notification settings - Fork 74
/
ir.rs
63 lines (55 loc) · 1.48 KB
/
ir.rs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#[derive(Debug)]
pub struct Input {
pub universal_regions: Vec<String>,
pub blocks: Vec<Block>,
}
#[derive(Debug)]
pub struct Block {
pub name: String,
pub statements: Vec<Statement>,
pub goto: Vec<String>,
}
#[derive(Debug)]
pub struct Statement {
/// Effects destined to be emitted at the Statement's Start point
pub effects_start: Vec<Effect>,
/// Effects destined to be emitted at the Statement's Mid point
pub effects: Vec<Effect>,
}
#[derive(Clone, Debug, PartialEq)]
pub enum Effect {
Use { regions: Vec<String> },
Fact(Fact),
}
#[derive(Clone, Debug, PartialEq)]
pub enum Fact {
Outlives { a: String, b: String },
BorrowRegionAt { region: String, loan: String },
Invalidates { loan: String },
Kill { loan: String },
RegionLiveAt { region: String },
}
impl Statement {
pub(crate) fn new(effects: Vec<Effect>) -> Self {
// Anything live on entry to the "mid point" is also live on
// entry to the start point.
let effects_start = effects
.iter()
.filter(|effect| match effect {
Effect::Fact(Fact::RegionLiveAt { .. }) => true,
_ => false,
})
.cloned()
.collect();
Self {
effects_start,
effects,
}
}
pub(crate) fn with_start_effects(effects_start: Vec<Effect>, effects: Vec<Effect>) -> Self {
Self {
effects_start,
effects,
}
}
}