Do not build index for multiple packages to avoid Engine creation regression.

This commit is contained in:
Stephen Chung
2020-05-08 13:27:51 +08:00
parent e6fabe58cc
commit e0745ef069
4 changed files with 52 additions and 45 deletions

View File

@@ -176,9 +176,17 @@ impl<'a> State<'a> {
}
}
/// An external native Rust function.
#[cfg(not(feature = "sync"))]
pub type NativeFunction = Rc<Box<FnAny>>;
/// An external native Rust function.
#[cfg(feature = "sync")]
pub type NativeFunction = Arc<Box<FnAny>>;
/// A sharable script-defined function.
#[cfg(feature = "sync")]
pub type ScriptedFunction = Arc<FnDef>;
/// A sharable script-defined function.
#[cfg(not(feature = "sync"))]
pub type ScriptedFunction = Rc<FnDef>;
@@ -512,6 +520,15 @@ impl Engine {
self.packages.push(package);
}
/// Load a new package into the `Engine`.
///
/// When searching for functions, packages loaded later are preferred.
/// In other words, loaded packages are searched in reverse order.
pub fn load_packages(&mut self, package: PackageLibrary) {
// Push the package to the top - packages are searched in reverse order
self.packages.push(package);
}
/// Control whether and how the `Engine` will optimize an AST after compilation.
///
/// Not available under the `no_optimize` feature.