wasmer_clif_fork_wasm/state/module_state.rs
1use crate::translation_utils::SignatureIndex;
2use cranelift_entity::PrimaryMap;
3use std::boxed::Box;
4
5/// Map of signatures to a function's parameter and return types.
6pub(crate) type WasmTypes =
7 PrimaryMap<SignatureIndex, (Box<[wasmparser::Type]>, Box<[wasmparser::Type]>)>;
8
9/// Contains information decoded from the Wasm module that must be referenced
10/// during each Wasm function's translation.
11///
12/// This is only for data that is maintained by `cranelift-wasm` itself, as
13/// opposed to being maintained by the embedder. Data that is maintained by the
14/// embedder is represented with `ModuleEnvironment`.
15#[derive(Debug)]
16pub struct ModuleTranslationState {
17 /// A map containing a Wasm module's original, raw signatures.
18 ///
19 /// This is used for translating multi-value Wasm blocks inside functions,
20 /// which are encoded to refer to their type signature via index.
21 pub wasm_types: WasmTypes,
22}
23
24impl ModuleTranslationState {
25 /// Creates a new empty ModuleTranslationState.
26 pub fn new() -> Self {
27 Self {
28 wasm_types: PrimaryMap::new(),
29 }
30 }
31}