devalang_core/core/store/
global.rs1use std::collections::HashMap;
2use crate::core::{
3 preprocessor::module::Module,
4 store::{ function::FunctionTable, variable::VariableTable },
5};
6
7#[derive(Debug, Clone)]
8pub struct GlobalStore {
9 pub modules: HashMap<String, Module>,
10 pub variables: VariableTable,
11 pub functions: FunctionTable,
12}
13
14impl GlobalStore {
15 pub fn new() -> Self {
16 GlobalStore {
17 modules: HashMap::new(),
18 functions: FunctionTable::new(),
19 variables: VariableTable::new(),
20 }
21 }
22
23 pub fn insert_module(&mut self, path: String, module: Module) {
24 self.modules.insert(path, module);
25 }
26
27 pub fn modules_mut(&mut self) -> &mut HashMap<String, Module> {
28 &mut self.modules
29 }
30
31 pub fn get_module(&self, path: &str) -> Option<&Module> {
32 self.modules.get(path)
33 }
34
35 pub fn remove_module(&mut self, path: &str) -> Option<Module> {
36 self.modules.remove(path)
37 }
38}