Bring module's environment when activating overlay (#6425)

This commit is contained in:
Jakub Žádník
2022-08-27 01:32:19 +03:00
committed by GitHub
parent 3f1824111d
commit 34d7c17e78
4 changed files with 107 additions and 18 deletions

View File

@ -11,6 +11,7 @@ pub struct Module {
pub decls: IndexMap<Vec<u8>, DeclId>,
pub aliases: IndexMap<Vec<u8>, AliasId>,
pub env_vars: IndexMap<Vec<u8>, BlockId>,
pub env_block: Option<BlockId>,
pub span: Option<Span>,
}
@ -20,6 +21,7 @@ impl Module {
decls: IndexMap::new(),
aliases: IndexMap::new(),
env_vars: IndexMap::new(),
env_block: None,
span: None,
}
}
@ -29,6 +31,7 @@ impl Module {
decls: IndexMap::new(),
aliases: IndexMap::new(),
env_vars: IndexMap::new(),
env_block: None,
span: Some(span),
}
}
@ -45,6 +48,10 @@ impl Module {
self.env_vars.insert(name, block_id)
}
pub fn add_env_block(&mut self, block_id: BlockId) {
self.env_block = Some(block_id);
}
pub fn extend(&mut self, other: &Module) {
self.decls.extend(other.decls.clone());
self.env_vars.extend(other.env_vars.clone());