wasmer_compiler/
lib.rs

1//! The `wasmer-compiler` crate provides the necessary abstractions
2//! to create a compiler.
3//!
4//! It provides an universal way of parsing a module via `wasmparser`,
5//! while giving the responsibility of compiling specific function
6//! WebAssembly bodies to the `Compiler` implementation.
7
8#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
9#![warn(unused_import_braces)]
10#![cfg_attr(not(feature = "std"), no_std)]
11#![allow(clippy::new_without_default, clippy::upper_case_acronyms)]
12#![warn(
13    clippy::float_arithmetic,
14    clippy::mut_mut,
15    clippy::nonminimal_bool,
16    clippy::map_unwrap_or,
17    clippy::print_stdout,
18    clippy::unicode_not_nfc,
19    clippy::use_self
20)]
21#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
22
23#[cfg(all(feature = "std", feature = "core"))]
24compile_error!(
25    "The `std` and `core` features are both enabled, which is an error. Please enable only once."
26);
27
28#[cfg(all(not(feature = "std"), not(feature = "core")))]
29compile_error!("Both the `std` and `core` features are disabled. Please enable one of them.");
30
31#[cfg(feature = "core")]
32extern crate alloc;
33
34#[allow(unused_imports)]
35mod lib {
36    #[cfg(feature = "core")]
37    pub mod std {
38        pub use alloc::{borrow, boxed, str, string, sync, vec};
39        pub use core::fmt;
40        pub use hashbrown as collections;
41    }
42
43    #[cfg(feature = "std")]
44    pub mod std {
45        pub use std::{borrow, boxed, collections, fmt, str, string, sync, vec};
46    }
47}
48
49mod engine;
50mod traits;
51
52pub mod object;
53pub mod serialize;
54pub mod types;
55
56pub use crate::engine::*;
57pub use crate::traits::*;
58
59mod artifact_builders;
60
61pub use self::artifact_builders::*;
62
63#[cfg(feature = "translator")]
64mod compiler;
65
66#[cfg(feature = "translator")]
67#[macro_use]
68mod translator;
69#[cfg(feature = "translator")]
70pub use crate::compiler::{Compiler, CompilerConfig};
71#[cfg(feature = "translator")]
72pub use crate::translator::{
73    from_binaryreadererror_wasmerror, translate_module, wpheaptype_to_type, wptype_to_type,
74    FunctionBinaryReader, FunctionBodyData, FunctionMiddleware, MiddlewareBinaryReader,
75    MiddlewareReaderState, ModuleEnvironment, ModuleMiddleware, ModuleMiddlewareChain,
76    ModuleTranslationState,
77};
78
79pub use wasmer_types::{Addend, CodeOffset, Features};
80
81#[cfg(feature = "translator")]
82/// wasmparser is exported as a module to slim compiler dependencies
83pub use wasmparser;
84
85/// Version number of this crate.
86pub const VERSION: &str = env!("CARGO_PKG_VERSION");