use super::assign::*;
use crate::analysis::graphs::scc::SccInfo;
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::mir::Terminator;
#[derive(Debug, Clone)]
pub struct Block<'tcx> {
pub index: usize,
pub is_cleanup: bool,
pub next: FxHashSet<usize>,
pub assignments: Vec<Assignment<'tcx>>,
pub const_value: Vec<ConstValue>,
pub assigned_locals: FxHashSet<usize>,
pub terminator: Term<'tcx>,
pub scc: SccInfo,
}
#[derive(Debug, Clone)]
pub enum Term<'tcx> {
Call(Terminator<'tcx>),
Drop(Terminator<'tcx>),
Switch(Terminator<'tcx>),
None,
}
#[derive(Debug, Clone)]
pub struct ConstValue {
pub local: usize,
pub value: usize,
}
impl ConstValue {
pub fn new(local: usize, value: usize) -> Self {
ConstValue { local, value }
}
}
impl<'tcx> Block<'tcx> {
pub fn new(index: usize, is_cleanup: bool) -> Block<'tcx> {
Block {
index,
is_cleanup,
next: FxHashSet::<usize>::default(),
assignments: Vec::<Assignment<'tcx>>::new(),
const_value: Vec::<ConstValue>::new(),
assigned_locals: FxHashSet::<usize>::default(),
terminator: Term::None,
scc: SccInfo::new(index),
}
}
pub fn add_next(&mut self, index: usize) {
self.next.insert(index);
}
}