#![deny(warnings)]
#![deny(missing_docs)]
#![deny(rustdoc::broken_intra_doc_links)]
extern crate alloc;
mod code_translator;
mod component;
mod config;
mod error;
mod intrinsics;
mod miden_abi;
mod module;
mod ssa;
mod translation_utils;
#[cfg(test)]
mod test_utils;
use component::build_ir::translate_component;
use error::WasmResult;
use midenc_session::Session;
use module::build_ir::translate_module_as_component;
use wasmparser::WasmFeatures;
pub use self::{config::*, error::WasmError};
pub fn translate(
wasm: &[u8],
config: &WasmTranslationConfig,
session: &Session,
) -> WasmResult<midenc_hir::Component> {
if wasm[4..8] == [0x01, 0x00, 0x00, 0x00] {
translate_module_as_component(wasm, config, session)
} else {
translate_component(wasm, config, session)
}
}
pub(crate) fn supported_features() -> WasmFeatures {
WasmFeatures::BULK_MEMORY
| WasmFeatures::FLOATS
| WasmFeatures::FUNCTION_REFERENCES
| WasmFeatures::MULTI_VALUE
| WasmFeatures::MUTABLE_GLOBAL
| WasmFeatures::SATURATING_FLOAT_TO_INT
| WasmFeatures::SIGN_EXTENSION
| WasmFeatures::TAIL_CALL
}
pub(crate) fn supported_component_model_features() -> WasmFeatures {
supported_features() | WasmFeatures::COMPONENT_MODEL
}