Allow multiple exports.

This commit is contained in:
Stephen Chung
2020-11-09 14:38:33 +08:00
parent 173f8474d6
commit 821e64adc4
8 changed files with 43 additions and 38 deletions

View File

@@ -1380,10 +1380,14 @@ impl Module {
// Create new module
let mut module = Module::new();
scope.into_iter().for_each(|(_, _, value, alias)| {
scope.into_iter().for_each(|(_, _, value, mut aliases)| {
// Variables with an alias left in the scope become module variables
if let Some(alias) = alias {
module.variables.insert(alias, value);
if aliases.len() > 1 {
aliases.into_iter().for_each(|alias| {
module.variables.insert(alias, value.clone());
});
} else if aliases.len() == 1 {
module.variables.insert(aliases.pop().unwrap(), value);
}
});