use solang_parser::pt::Loc;
use solang_parser::pt::OptionalCodeLocation;
#[derive(Clone)]
pub enum AvailableVariable {
Available(usize, Loc),
Invalidated,
Unavailable,
}
impl AvailableVariable {
pub fn get_var_number(&self) -> Option<usize> {
match self {
AvailableVariable::Available(number, _) => Some(*number),
_ => None,
}
}
pub fn is_available(&self) -> bool {
matches!(self, AvailableVariable::Available(..))
}
pub fn is_invalid(&self) -> bool {
matches!(self, AvailableVariable::Invalidated)
}
}
impl OptionalCodeLocation for AvailableVariable {
fn loc_opt(&self) -> Option<Loc> {
match self {
AvailableVariable::Available(_, loc) => Some(*loc),
_ => None,
}
}
}