1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use erg_common::config::ErgConfig;
use crate::context::Context;
use super::cache::SharedModuleCache;
use super::graph::SharedModuleGraph;
use super::impls::SharedTraitImpls;
use super::index::SharedModuleIndex;
#[derive(Debug, Clone, Default)]
pub struct SharedCompilerResource {
pub mod_cache: SharedModuleCache,
pub py_mod_cache: SharedModuleCache,
pub index: SharedModuleIndex,
pub graph: SharedModuleGraph,
pub trait_impls: SharedTraitImpls,
}
impl SharedCompilerResource {
pub fn new(cfg: ErgConfig) -> Self {
let self_ = Self {
mod_cache: SharedModuleCache::new(),
py_mod_cache: SharedModuleCache::new(),
index: SharedModuleIndex::new(),
graph: SharedModuleGraph::new(),
trait_impls: SharedTraitImpls::new(),
};
Context::init_builtins(cfg, self_.clone());
self_
}
pub fn clear_all(&self) {
self.mod_cache.initialize();
self.py_mod_cache.initialize();
self.index.initialize();
self.graph.initialize();
self.trait_impls.initialize();
}
}