#![deny(
dead_code,
missing_docs,
nonstandard_style,
unused_imports,
unused_mut,
unused_variables,
unused_unsafe,
unreachable_patterns
)]
#![doc(html_favicon_url = "https://wasmer.io/static/icons/favicon.ico")]
#![doc(html_logo_url = "https://avatars3.githubusercontent.com/u/44205449?s=200&v=4")]
pub use wasmer_runtime_core::backend::{Backend, Features};
pub use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler};
pub use wasmer_runtime_core::export::Export;
pub use wasmer_runtime_core::global::Global;
pub use wasmer_runtime_core::import::{ImportObject, LikeNamespace};
pub use wasmer_runtime_core::instance::{DynFunc, Instance};
pub use wasmer_runtime_core::memory::ptr::{Array, Item, WasmPtr};
pub use wasmer_runtime_core::memory::Memory;
pub use wasmer_runtime_core::module::Module;
pub use wasmer_runtime_core::table::Table;
pub use wasmer_runtime_core::types::Value;
pub use wasmer_runtime_core::vm::Ctx;
pub use wasmer_runtime_core::Func;
pub use wasmer_runtime_core::{compile_with, validate};
pub use wasmer_runtime_core::{func, imports};
pub mod memory {
pub use wasmer_runtime_core::memory::{Atomically, Memory, MemoryView};
}
pub mod wasm {
pub use wasmer_runtime_core::global::Global;
pub use wasmer_runtime_core::table::Table;
pub use wasmer_runtime_core::types::{
FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor, Type, Value,
};
}
pub mod error {
pub use wasmer_runtime_core::cache::Error as CacheError;
pub use wasmer_runtime_core::error::*;
}
pub mod units {
pub use wasmer_runtime_core::units::{Bytes, Pages};
}
pub mod types {
pub use wasmer_runtime_core::types::*;
}
pub mod cache;
pub use wasmer_runtime_core::backend::{Compiler, CompilerConfig};
pub fn compile(wasm: &[u8]) -> error::CompileResult<Module> {
wasmer_runtime_core::compile_with(&wasm[..], &default_compiler())
}
pub fn compile_with_config(
wasm: &[u8],
compiler_config: CompilerConfig,
) -> error::CompileResult<Module> {
wasmer_runtime_core::compile_with_config(&wasm[..], &default_compiler(), compiler_config)
}
pub fn compile_with_config_with(
wasm: &[u8],
compiler_config: CompilerConfig,
compiler: &dyn Compiler,
) -> error::CompileResult<Module> {
wasmer_runtime_core::compile_with_config(&wasm[..], compiler, compiler_config)
}
pub fn instantiate(wasm: &[u8], import_object: &ImportObject) -> error::Result<Instance> {
let module = compile(wasm)?;
module.instantiate(import_object)
}
pub fn default_compiler() -> impl Compiler {
#[cfg(any(
all(
feature = "default-backend-llvm",
not(feature = "docs"),
any(
feature = "default-backend-cranelift",
feature = "default-backend-singlepass"
)
),
all(
not(feature = "docs"),
feature = "default-backend-cranelift",
feature = "default-backend-singlepass"
)
))]
compile_error!(
"The `default-backend-X` features are mutually exclusive. Please choose just one"
);
#[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))]
use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler;
#[cfg(all(feature = "default-backend-singlepass", not(feature = "docs")))]
use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler;
#[cfg(any(feature = "default-backend-cranelift", feature = "docs"))]
use wasmer_clif_backend::CraneliftCompiler as DefaultCompiler;
DefaultCompiler::new()
}
pub fn compiler_for_backend(backend: Backend) -> Option<Box<dyn Compiler>> {
match backend {
#[cfg(feature = "cranelift")]
Backend::Cranelift => Some(Box::new(wasmer_clif_backend::CraneliftCompiler::new())),
#[cfg(feature = "singlepass")]
Backend::Singlepass => Some(Box::new(
wasmer_singlepass_backend::SinglePassCompiler::new(),
)),
#[cfg(feature = "llvm")]
Backend::LLVM => Some(Box::new(wasmer_llvm_backend::LLVMCompiler::new())),
#[cfg(any(
not(feature = "llvm"),
not(feature = "singlepass"),
not(feature = "cranelift")
))]
_ => None,
}
}
pub const VERSION: &str = env!("CARGO_PKG_VERSION");