mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-02 13:41:10 +00:00
Add Runnable::initialize
This commit is contained in:
parent
64dcc17399
commit
7bcc766500
11 changed files with 80 additions and 2 deletions
|
@ -900,6 +900,29 @@ impl Context {
|
|||
}
|
||||
}
|
||||
|
||||
/// This method is intended to be called __only__ in the top-level module.
|
||||
/// `.cfg` is not initialized and is used around.
|
||||
pub fn initialize(&mut self) {
|
||||
let mut mod_cache = mem::take(&mut self.mod_cache);
|
||||
if let Some(mod_cache) = &mut mod_cache {
|
||||
mod_cache.initialize();
|
||||
}
|
||||
let mut py_mod_cache = mem::take(&mut self.py_mod_cache);
|
||||
if let Some(py_mod_cache) = &mut py_mod_cache {
|
||||
py_mod_cache.initialize();
|
||||
}
|
||||
*self = Self::new(
|
||||
self.name.clone(),
|
||||
self.cfg.clone(),
|
||||
self.kind.clone(),
|
||||
vec![],
|
||||
None,
|
||||
mod_cache,
|
||||
py_mod_cache,
|
||||
self.level,
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn grow(
|
||||
&mut self,
|
||||
name: &str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue