Refactor.

This commit is contained in:
Stephen Chung
2022-10-10 16:46:35 +08:00
parent 796206f293
commit d6b0f99781
15 changed files with 161 additions and 166 deletions

View File

@@ -1742,10 +1742,9 @@ impl Module {
}
if let Some(ref variables) = other.variables {
if let Some(ref mut m) = self.variables {
m.extend(variables.iter().map(|(k, v)| (k.clone(), v.clone())));
} else {
self.variables = other.variables.clone();
match self.variables {
Some(ref mut m) => m.extend(variables.iter().map(|(k, v)| (k.clone(), v.clone()))),
None => self.variables = other.variables.clone(),
}
}
@@ -1767,10 +1766,9 @@ impl Module {
self.dynamic_functions_filter += &other.dynamic_functions_filter;
if let Some(ref type_iterators) = other.type_iterators {
if let Some(ref mut t) = self.type_iterators {
t.extend(type_iterators.iter().map(|(&k, v)| (k, v.clone())));
} else {
self.type_iterators = other.type_iterators.clone();
match self.type_iterators {
Some(ref mut t) => t.extend(type_iterators.iter().map(|(&k, v)| (k, v.clone()))),
None => self.type_iterators = other.type_iterators.clone(),
}
}
self.all_functions = None;

View File

@@ -322,10 +322,9 @@ impl FileModuleResolver {
let scope = Scope::new();
let m: Shared<_> = if let Some(global) = global {
Module::eval_ast_as_new_raw(engine, scope, global, &ast)
} else {
Module::eval_ast_as_new(scope, &ast, engine)
let m: Shared<_> = match global {
Some(global) => Module::eval_ast_as_new_raw(engine, scope, global, &ast),
None => Module::eval_ast_as_new(scope, &ast, engine),
}
.map_err(|err| Box::new(ERR::ErrorInModule(path.to_string(), err, pos)))?
.into();