cranelift_wasm/
lib.rs

1//! Performs translation from a wasm module in binary format to the in-memory form
2//! of Cranelift IR. More particularly, it translates the code of all the functions bodies and
3//! interacts with an environment implementing the
4//! [`ModuleEnvironment`](trait.ModuleEnvironment.html)
5//! trait to deal with tables, globals and linear memory.
6//!
7//! The main function of this module is [`translate_module`](fn.translate_module.html).
8
9#![deny(missing_docs)]
10#![no_std]
11
12#[cfg(not(feature = "std"))]
13#[macro_use]
14extern crate alloc as std;
15#[cfg(feature = "std")]
16#[macro_use]
17extern crate std;
18
19#[cfg(not(feature = "std"))]
20use hashbrown::{
21    hash_map,
22    hash_map::Entry::{Occupied, Vacant},
23    HashMap,
24};
25#[cfg(feature = "std")]
26use std::collections::{
27    hash_map,
28    hash_map::Entry::{Occupied, Vacant},
29    HashMap,
30};
31
32mod code_translator;
33mod environ;
34mod func_translator;
35mod heap;
36mod module_translator;
37mod sections_translator;
38mod state;
39mod table;
40mod translation_utils;
41
42pub use crate::environ::{FuncEnvironment, GlobalVariable, ModuleEnvironment, TargetEnvironment};
43pub use crate::func_translator::FuncTranslator;
44pub use crate::heap::{Heap, HeapData, HeapStyle};
45pub use crate::module_translator::translate_module;
46pub use crate::state::FuncTranslationState;
47pub use crate::table::{TableData, TableSize};
48pub use crate::translation_utils::*;
49pub use cranelift_frontend::FunctionBuilder;
50pub use wasmtime_types::*;
51
52// Convenience reexport of the wasmparser crate that we're linking against,
53// since a number of types in `wasmparser` show up in the public API of
54// `cranelift-wasm`.
55pub use wasmparser;
56
57/// Version number of this crate.
58pub const VERSION: &str = env!("CARGO_PKG_VERSION");