Expose the `validate_module` function and `ValidatedModule` to crate users
This commit is contained in:
parent
438eab9ada
commit
6779913a9f
|
@ -380,6 +380,7 @@ pub use self::module::{ModuleInstance, ModuleRef, ExternVal, NotStartedModuleRef
|
||||||
pub use self::global::{GlobalInstance, GlobalRef};
|
pub use self::global::{GlobalInstance, GlobalRef};
|
||||||
pub use self::func::{FuncInstance, FuncRef, FuncInvocation, ResumableError};
|
pub use self::func::{FuncInstance, FuncRef, FuncInvocation, ResumableError};
|
||||||
pub use self::types::{Signature, ValueType, GlobalDescriptor, TableDescriptor, MemoryDescriptor};
|
pub use self::types::{Signature, ValueType, GlobalDescriptor, TableDescriptor, MemoryDescriptor};
|
||||||
|
pub use self::validation::{ValidatedModule, validate_module};
|
||||||
|
|
||||||
/// WebAssembly-specific sizes and units.
|
/// WebAssembly-specific sizes and units.
|
||||||
pub mod memory_units {
|
pub mod memory_units {
|
||||||
|
|
|
@ -40,8 +40,11 @@ impl From<stack::Error> for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
/// A deserialized and validated module
|
||||||
pub struct ValidatedModule {
|
pub struct ValidatedModule {
|
||||||
|
/// The instructions in each Function, represented using isa::Instructions
|
||||||
pub code_map: Vec<isa::Instructions>,
|
pub code_map: Vec<isa::Instructions>,
|
||||||
|
/// The deserialized module
|
||||||
pub module: Module,
|
pub module: Module,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +168,7 @@ pub fn deny_floating_point(module: &Module) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Validate a module. This checks all of the invariants given by the WebAssembly spec.
|
||||||
pub fn validate_module(module: Module) -> Result<ValidatedModule, Error> {
|
pub fn validate_module(module: Module) -> Result<ValidatedModule, Error> {
|
||||||
let mut context_builder = ModuleContextBuilder::new();
|
let mut context_builder = ModuleContextBuilder::new();
|
||||||
let mut imported_globals = Vec::new();
|
let mut imported_globals = Vec::new();
|
||||||
|
|
Loading…
Reference in New Issue