use crate::source_range::SourceRange; use std::hash::{Hash, Hasher}; use std::rc::Rc; pub struct VariableSymbol { declared_name: Rc, declared_name_source_range: SourceRange, is_mut: bool, scope_id: usize, } impl VariableSymbol { pub fn new( name: &Rc, declared_name_source_range: &SourceRange, is_mut: bool, scope_id: usize, ) -> Self { Self { declared_name: name.clone(), declared_name_source_range: declared_name_source_range.clone(), is_mut, scope_id, } } pub fn declared_name(&self) -> &str { &self.declared_name } pub fn declared_name_owned(&self) -> Rc { self.declared_name.clone() } pub fn declared_name_source_range(&self) -> &SourceRange { &self.declared_name_source_range } pub fn is_mut(&self) -> bool { self.is_mut } pub fn scope_id(&self) -> usize { self.scope_id } } impl Eq for VariableSymbol {} impl PartialEq for VariableSymbol { fn eq(&self, other: &Self) -> bool { self.declared_name == other.declared_name && self.scope_id == other.scope_id } } impl Hash for VariableSymbol { fn hash(&self, state: &mut H) { self.declared_name.hash(state); self.scope_id.hash(state); } }