mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 21:58:20 +00:00
Move get_module_info into the Engine
This commit is contained in:
@@ -56,19 +56,8 @@ impl Artifact {
|
||||
data: &[u8],
|
||||
tunables: &dyn Tunables,
|
||||
) -> Result<Self, CompileError> {
|
||||
let artifact = Self::get_artifact_build(engine, data, tunables)?;
|
||||
let mut inner_engine = engine.inner_mut();
|
||||
Self::from_parts(&mut inner_engine, artifact)
|
||||
}
|
||||
|
||||
#[cfg(feature = "compiler")]
|
||||
fn get_artifact_build(
|
||||
engine: &Engine,
|
||||
data: &[u8],
|
||||
tunables: &dyn Tunables,
|
||||
) -> Result<ArtifactBuild, CompileError> {
|
||||
let environ = ModuleEnvironment::new();
|
||||
let mut inner_engine = engine.inner_mut();
|
||||
let translation = environ.translate(data).map_err(CompileError::Wasm)?;
|
||||
let module = translation.module;
|
||||
let memory_styles: PrimaryMap<MemoryIndex, MemoryStyle> = module
|
||||
@@ -90,18 +79,7 @@ impl Artifact {
|
||||
table_styles,
|
||||
)?;
|
||||
|
||||
Ok(artifact)
|
||||
}
|
||||
|
||||
/// Compile a data buffer into a `ArtifactBuild`, which may then be instantiated.
|
||||
#[cfg(feature = "compiler")]
|
||||
pub fn get_module_info(
|
||||
engine: &Engine,
|
||||
data: &[u8],
|
||||
tunables: &dyn Tunables,
|
||||
) -> Result<ModuleInfo, CompileError> {
|
||||
let artifact = Self::get_artifact_build(engine, data, tunables)?;
|
||||
Ok(artifact.create_module_info())
|
||||
Self::from_parts(&mut inner_engine, artifact)
|
||||
}
|
||||
|
||||
/// Compile a data buffer into a `ArtifactBuild`, which may then be instantiated.
|
||||
|
||||
@@ -74,6 +74,15 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns only the `ModuleInfo` given a `wasm` byte slice
|
||||
#[cfg(feature = "compiler")]
|
||||
pub fn get_module_info(data: &[u8]) -> Result<ModuleInfo, CompileError> {
|
||||
// this is from `artifact_builder.rs`
|
||||
let environ = crate::ModuleEnvironment::new();
|
||||
let translation = environ.translate(data).map_err(CompileError::Wasm)?;
|
||||
Ok(translation.module)
|
||||
}
|
||||
|
||||
/// Returns the name of this engine
|
||||
pub fn name(&self) -> &str {
|
||||
self.name.as_str()
|
||||
|
||||
Reference in New Issue
Block a user