Rename GlobalRuntimeStatemodules -> imports.
This commit is contained in:
@@ -179,9 +179,9 @@ impl Engine {
|
||||
/// Search order:
|
||||
/// 1) AST - script functions in the AST
|
||||
/// 2) Global namespace - functions registered via Engine::register_XXX
|
||||
/// 3) Global modules - packages
|
||||
/// 3) Global registered modules - packages
|
||||
/// 4) Imported modules - functions marked with global namespace
|
||||
/// 5) Global sub-modules - functions marked with global namespace
|
||||
/// 5) Static registered modules
|
||||
#[must_use]
|
||||
fn resolve_fn<'s>(
|
||||
&self,
|
||||
@@ -220,7 +220,7 @@ impl Engine {
|
||||
loop {
|
||||
let func = lib
|
||||
.iter()
|
||||
.find_map(|m| {
|
||||
.find_map(|&m| {
|
||||
m.get_fn(hash).cloned().map(|func| FnResolutionCacheEntry {
|
||||
func,
|
||||
source: m.id_raw().clone(),
|
||||
@@ -235,13 +235,13 @@ impl Engine {
|
||||
})
|
||||
})
|
||||
.or_else(|| {
|
||||
global
|
||||
.get_fn(hash)
|
||||
.map(|(func, source)| FnResolutionCacheEntry {
|
||||
global.get_qualified_fn(hash).map(|(func, source)| {
|
||||
FnResolutionCacheEntry {
|
||||
func: func.clone(),
|
||||
source: source
|
||||
.map_or_else(|| Identifier::new_const(), Into::into),
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
.or_else(|| {
|
||||
self.global_sub_modules.values().find_map(|m| {
|
||||
|
@@ -199,7 +199,7 @@ impl<'a> NativeCallContext<'a> {
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
#[inline]
|
||||
pub fn iter_imports(&self) -> impl Iterator<Item = (&str, &Module)> {
|
||||
self.global.iter().flat_map(|&m| m.iter_modules())
|
||||
self.global.iter().flat_map(|&m| m.iter_imports())
|
||||
}
|
||||
/// Get an iterator over the current set of modules imported via `import` statements in reverse order.
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
@@ -208,7 +208,7 @@ impl<'a> NativeCallContext<'a> {
|
||||
pub(crate) fn iter_imports_raw(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (&crate::Identifier, &Shared<Module>)> {
|
||||
self.global.iter().flat_map(|&m| m.iter_modules_raw())
|
||||
self.global.iter().flat_map(|&m| m.iter_imports_raw())
|
||||
}
|
||||
/// _(internals)_ The current [`GlobalRuntimeState`], if any.
|
||||
/// Exported under the `internals` feature only.
|
||||
|
@@ -70,7 +70,7 @@ impl Engine {
|
||||
}
|
||||
|
||||
let orig_scope_len = scope.len();
|
||||
let orig_mods_len = global.num_imported_modules();
|
||||
let orig_mods_len = global.num_imports();
|
||||
|
||||
// Put arguments into scope as variables
|
||||
scope.extend(fn_def.params.iter().cloned().zip(args.into_iter().map(|v| {
|
||||
@@ -100,7 +100,7 @@ impl Engine {
|
||||
modules
|
||||
.iter()
|
||||
.cloned()
|
||||
.for_each(|(n, m)| global.push_module(n, m));
|
||||
.for_each(|(n, m)| global.push_import(n, m));
|
||||
}
|
||||
|
||||
// Evaluate the function
|
||||
@@ -144,7 +144,7 @@ impl Engine {
|
||||
// Remove arguments only, leaving new variables in the scope
|
||||
scope.remove_range(orig_scope_len, args.len())
|
||||
}
|
||||
global.truncate_modules(orig_mods_len);
|
||||
global.truncate_imports(orig_mods_len);
|
||||
|
||||
// Restore state
|
||||
state.rewind_fn_resolution_caches(orig_fn_resolution_caches_len);
|
||||
@@ -172,7 +172,7 @@ impl Engine {
|
||||
// Then check the global namespace and packages
|
||||
|| self.global_modules.iter().any(|m| m.contains_fn(hash_script))
|
||||
// Then check imported modules
|
||||
|| global.map_or(false, |m| m.contains_fn(hash_script))
|
||||
|| global.map_or(false, |m| m.contains_qualified_fn(hash_script))
|
||||
// Then check sub-modules
|
||||
|| self.global_sub_modules.values().any(|m| m.contains_qualified_fn(hash_script));
|
||||
|
||||
|
Reference in New Issue
Block a user