deimos-lang/dmc-lib/src/scope/function_scope.rs

33 lines
843 B
Rust

use crate::symbol::parameter_symbol::ParameterSymbol;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
pub struct FunctionScope {
debug_name: String,
parent_id: usize,
parameter_symbols: HashMap<Rc<str>, Rc<RefCell<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<RefCell<ParameterSymbol>>> {
&self.parameter_symbols
}
pub fn parameter_symbols_mut(&mut self) -> &mut HashMap<Rc<str>, Rc<RefCell<ParameterSymbol>>> {
&mut self.parameter_symbols
}
pub fn parent_id(&self) -> usize {
self.parent_id
}
}