erg/crates/erg_compiler/module/global.rs
2023-01-15 12:03:19 +09:00

35 lines
975 B
Rust

use erg_common::config::ErgConfig;
use super::cache::SharedModuleCache;
use super::graph::SharedModuleGraph;
#[cfg(feature = "els")]
use super::index::SharedModuleIndex;
#[derive(Debug, Clone, Default)]
pub struct SharedCompilerResource {
pub mod_cache: SharedModuleCache,
pub py_mod_cache: SharedModuleCache,
#[cfg(feature = "els")]
pub index: SharedModuleIndex,
pub graph: SharedModuleGraph,
}
impl SharedCompilerResource {
pub fn new(cfg: ErgConfig) -> Self {
Self {
mod_cache: SharedModuleCache::new(cfg.copy()),
py_mod_cache: SharedModuleCache::new(cfg),
#[cfg(feature = "els")]
index: SharedModuleIndex::new(),
graph: SharedModuleGraph::new(),
}
}
pub fn clear_all(&self) {
self.mod_cache.initialize();
self.py_mod_cache.initialize();
#[cfg(feature = "els")]
self.index.initialize();
self.graph.initialize();
}
}