39 lines
1005 B
Rust
39 lines
1005 B
Rust
use crate::symbol::parameter_symbol::ParameterSymbol;
|
|
use std::collections::HashMap;
|
|
use std::fmt::{Debug, Formatter};
|
|
use std::rc::Rc;
|
|
|
|
pub struct FunctionScope {
|
|
debug_name: String,
|
|
parent_id: usize,
|
|
parameter_symbols: HashMap<Rc<str>, Rc<ParameterSymbol>>,
|
|
}
|
|
|
|
impl FunctionScope {
|
|
pub fn new(debug_name: &str, parent_id: usize) -> Self {
|
|
Self {
|
|
debug_name: debug_name.into(),
|
|
parent_id,
|
|
parameter_symbols: HashMap::new(),
|
|
}
|
|
}
|
|
|
|
pub fn parameter_symbols(&self) -> &HashMap<Rc<str>, Rc<ParameterSymbol>> {
|
|
&self.parameter_symbols
|
|
}
|
|
|
|
pub fn parameter_symbols_mut(&mut self) -> &mut HashMap<Rc<str>, Rc<ParameterSymbol>> {
|
|
&mut self.parameter_symbols
|
|
}
|
|
|
|
pub fn parent_id(&self) -> usize {
|
|
self.parent_id
|
|
}
|
|
}
|
|
|
|
impl Debug for FunctionScope {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "FunctionScope({}, {})", self.debug_name, self.parent_id)
|
|
}
|
|
}
|