32 lines
775 B
Rust
32 lines
775 B
Rust
use crate::symbol::variable_symbol::VariableSymbol;
|
|
use std::collections::HashMap;
|
|
use std::rc::Rc;
|
|
|
|
pub struct BlockScope {
|
|
debug_name: String,
|
|
parent_id: usize,
|
|
variable_symbols: HashMap<Rc<str>, Rc<VariableSymbol>>,
|
|
}
|
|
|
|
impl BlockScope {
|
|
pub fn new(debug_name: &str, parent_id: usize) -> Self {
|
|
Self {
|
|
debug_name: debug_name.into(),
|
|
parent_id,
|
|
variable_symbols: HashMap::new(),
|
|
}
|
|
}
|
|
|
|
pub fn variable_symbols(&self) -> &HashMap<Rc<str>, Rc<VariableSymbol>> {
|
|
&self.variable_symbols
|
|
}
|
|
|
|
pub fn variable_symbols_mut(&mut self) -> &mut HashMap<Rc<str>, Rc<VariableSymbol>> {
|
|
&mut self.variable_symbols
|
|
}
|
|
|
|
pub fn parent_id(&self) -> usize {
|
|
self.parent_id
|
|
}
|
|
}
|