use crate::analysis::core::alias_analysis::default::types::ValueKind;
use rustc_data_structures::fx::FxHashMap;
#[derive(Debug, Clone)]
pub struct Value {
pub index: usize,
pub local: usize,
pub need_drop: bool,
pub may_drop: bool,
pub kind: ValueKind,
pub father: Option<FatherInfo>,
pub fields: FxHashMap<usize, usize>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct FatherInfo {
pub father_value_id: usize,
pub field_id: usize,
}
impl FatherInfo {
pub fn new(father_value_id: usize, field_id: usize) -> Self {
FatherInfo {
father_value_id,
field_id,
}
}
}
impl Value {
pub fn new(index: usize, local: usize, need_drop: bool, may_drop: bool) -> Self {
Value {
index,
local,
need_drop,
may_drop,
kind: ValueKind::Adt,
father: None,
fields: FxHashMap::default(),
}
}
pub fn is_tuple(&self) -> bool {
self.kind == ValueKind::Tuple
}
pub fn is_ptr(&self) -> bool {
self.kind == ValueKind::RawPtr || self.kind == ValueKind::Ref
}
pub fn is_ref(&self) -> bool {
self.kind == ValueKind::Ref
}
pub fn is_ref_count(&self) -> bool {
self.kind == ValueKind::SpecialPtr
}
}