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))]
22
23macro_rules! cfg_std_or_core {
24    ($($item:item)*) => {
25        $(
26            #[cfg(any(
27                feature = "std",
28                feature = "core",
29            ))]
30            $item
31        )*
32    };
33}
34
35#[cfg(all(feature = "std", feature = "core"))]
36compile_error!(
37    "The `std` and `core` features are both enabled, which is an error. Please enable only once."
38);
39
40#[cfg(all(not(feature = "std"), not(feature = "core")))]
41compile_error!("Both the `std` and `core` features are disabled. Please enable one of them.");
42
43#[cfg(feature = "core")]
44extern crate alloc;
45
46#[allow(unused_imports)]
47#[cfg(any(feature = "std", feature = "core"))]
48mod lib {
49    #[cfg(feature = "core")]
50    pub mod std {
51        pub use alloc::{borrow, boxed, str, string, sync, vec};
52        pub use core::fmt;
53        pub use hashbrown as collections;
54    }
55
56    #[cfg(feature = "std")]
57    pub mod std {
58        pub use std::{borrow, boxed, collections, fmt, str, string, sync, vec};
59    }
60}
61
62cfg_std_or_core! {
63    mod engine;
64    mod traits;
65
66    pub mod misc;
67    pub mod object;
68    pub mod serialize;
69    pub mod types;
70
71    pub use crate::engine::*;
72    pub use crate::traits::*;
73
74    mod artifact_builders;
75
76    pub use self::artifact_builders::*;
77}
78
79#[cfg(feature = "compiler")]
80mod compiler;
81#[cfg(feature = "compiler")]
82pub use crate::compiler::{Compiler, CompilerConfig};
83
84#[cfg(feature = "translator")]
85#[macro_use]
86mod translator;
87#[cfg(feature = "translator")]
88pub use crate::translator::{
89    FunctionBinaryReader, FunctionBodyData, FunctionMiddleware, MiddlewareBinaryReader,
90    MiddlewareReaderState, ModuleEnvironment, ModuleMiddleware, ModuleMiddlewareChain,
91    ModuleTranslationState, from_binaryreadererror_wasmerror, translate_module, wpheaptype_to_type,
92    wptype_to_type,
93};
94
95pub use wasmer_types::{Addend, CodeOffset, Features};
96
97#[cfg(feature = "translator")]
98/// wasmparser is exported as a module to slim compiler dependencies
99pub use wasmparser;
100
101/// Version number of this crate.
102pub const VERSION: &str = env!("CARGO_PKG_VERSION");