mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-30 17:11:33 +00:00
Added Module.verify function
This commit is contained in:
@ -4,7 +4,6 @@ pub mod memory;
|
||||
pub mod module;
|
||||
pub mod utils;
|
||||
|
||||
use cranelift_codegen::isa;
|
||||
use cranelift_native;
|
||||
use std::panic;
|
||||
use std::ptr;
|
||||
@ -12,8 +11,6 @@ use std::str::FromStr;
|
||||
use std::time::{Duration, Instant};
|
||||
use target_lexicon::{self, Triple};
|
||||
use wasmparser;
|
||||
// use cranelift_codegen::print_errors::pretty_verifier_error;
|
||||
// use cranelift_codegen::verifier;
|
||||
|
||||
pub use self::errors::{Error, ErrorKind};
|
||||
pub use self::instance::Instance;
|
||||
@ -33,17 +30,14 @@ pub struct ImportObject {}
|
||||
|
||||
/// The webassembly::instantiate() function allows you to compile and
|
||||
/// instantiate WebAssembly code
|
||||
|
||||
/// Params:
|
||||
/// * `buffer_source`: A `Vec<u8>` containing the
|
||||
/// binary code of the .wasm module you want to compile.
|
||||
|
||||
/// * `import_object`: An object containing the values to be imported
|
||||
/// into the newly-created Instance, such as functions or
|
||||
/// webassembly::Memory objects. There must be one matching property
|
||||
/// for each declared import of the compiled module or else a
|
||||
/// webassembly::LinkError is thrown.
|
||||
|
||||
/// Errors:
|
||||
/// If the operation fails, the Result rejects with a
|
||||
/// webassembly::CompileError, webassembly::LinkError, or
|
||||
@ -61,11 +55,9 @@ pub fn instantiate(
|
||||
/// from WebAssembly binary code. This function is useful if it
|
||||
/// is necessary to a compile a module before it can be instantiated
|
||||
/// (otherwise, the webassembly::instantiate() function should be used).
|
||||
|
||||
/// Params:
|
||||
/// * `buffer_source`: A `Vec<u8>` containing the
|
||||
/// binary code of the .wasm module you want to compile.
|
||||
|
||||
/// Errors:
|
||||
/// If the operation fails, the Result rejects with a
|
||||
/// webassembly::CompileError.
|
||||
@ -77,23 +69,12 @@ pub fn compile(buffer_source: Vec<u8>) -> Result<Module, ErrorKind> {
|
||||
|
||||
let module = Module::from_bytes(buffer_source, triple!("riscv64"), None)?;
|
||||
|
||||
// let isa = isa::lookup(module.info.triple)
|
||||
// .unwrap()
|
||||
// .finish(module.info.flags);
|
||||
|
||||
// for func in module.info.function_bodies.values() {
|
||||
// verifier::verify_function(func, &*isa)
|
||||
// .map_err(|errors| panic!(pretty_verifier_error(func, Some(&*isa), None, errors)))
|
||||
// .unwrap();
|
||||
// };
|
||||
|
||||
Ok(module)
|
||||
}
|
||||
|
||||
/// The webassembly::validate() function validates a given typed
|
||||
/// array of WebAssembly binary code, returning whether the bytes
|
||||
/// form a valid wasm module (true) or not (false).
|
||||
|
||||
/// Params:
|
||||
/// * `buffer_source`: A `Vec<u8>` containing the
|
||||
/// binary code of the .wasm module you want to compile.
|
||||
|
Reference in New Issue
Block a user