1#![deny(missing_docs, unused_extern_crates)]
8#![warn(unused_import_braces)]
9#![allow(clippy::new_without_default)]
10#![warn(
11 clippy::float_arithmetic,
12 clippy::mut_mut,
13 clippy::nonminimal_bool,
14 clippy::map_unwrap_or,
15 clippy::print_stdout,
16 clippy::unicode_not_nfc,
17 clippy::use_self
18)]
19#![cfg_attr(docsrs, feature(doc_cfg))]
20
21pub mod error;
22mod exception;
23mod features;
24mod indexes;
25mod initializers;
26mod libcalls;
27mod memory;
28mod module;
29mod module_hash;
30mod progress;
31mod serialize;
32mod stack;
33mod store_id;
34mod table;
35pub mod target;
36mod trapcode;
37mod types;
38mod units;
39mod utils;
40mod value;
41mod vmoffsets;
42
43pub use error::{
44 CompileError, DeserializeError, ImportError, MemoryError, MiddlewareError,
45 ParseCpuFeatureError, PreInstantiationError, SerializeError, WasmError, WasmResult,
46};
47
48pub mod entity;
50pub use crate::features::Features;
51pub use crate::indexes::{
52 CustomSectionIndex, DataIndex, ElemIndex, ExportIndex, FunctionIndex, GlobalIndex, ImportIndex,
53 LocalFunctionIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, LocalTagIndex,
54 MemoryIndex, SignatureHash, SignatureIndex, TableIndex, Tag, TagIndex,
55};
56pub use crate::initializers::{
57 ArchivedDataInitializerLocation, ArchivedOwnedDataInitializer, DataInitializer,
58 DataInitializerLike, DataInitializerLocation, DataInitializerLocationLike,
59 OwnedDataInitializer, TableInitializer,
60};
61pub use crate::memory::{Memory32, Memory64, MemorySize};
62pub use crate::module::{ExportsIterator, ImportKey, ImportsIterator, ModuleInfo};
63pub use crate::module_hash::ModuleHash;
64pub use crate::progress::{CompilationProgress, CompilationProgressCallback, UserAbort};
65pub use crate::types::{
66 ExportType, ExternType, FunctionType, GlobalInit, GlobalType, ImportType, InitExpr, InitExprOp,
67 MemoryType, Mutability, TableType, TagKind, TagType, Type, V128,
68};
69pub use crate::units::{
70 Bytes, PageCountOutOfRange, Pages, WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE,
71};
72pub use value::{RawValue, ValueType};
73
74pub use crate::libcalls::LibCall;
75pub use crate::memory::MemoryStyle;
76pub use crate::table::TableStyle;
77pub use serialize::MetadataHeader;
78pub use crate::exception::CATCH_ALL_TAG_VALUE;
80pub use crate::stack::{FrameInfo, SourceLoc, TrapInformation};
81pub use crate::store_id::StoreId;
82pub use crate::trapcode::{OnCalledAction, TrapCode};
83pub use crate::utils::is_wasm;
84pub use crate::vmoffsets::{VMBuiltinFunctionIndex, VMOffsets, vmctx_offset};
85
86pub type CodeOffset = u32;
88
89pub type Addend = i64;
91
92pub const VERSION: &str = env!("CARGO_PKG_VERSION");
94
95mod native {
96 use super::Type;
97 use crate::memory::{Memory32, Memory64, MemorySize};
98 use std::fmt;
99
100 pub trait NativeWasmType: Sized {
116 type Abi: Copy + fmt::Debug;
118
119 const WASM_TYPE: Type;
121 }
122
123 impl NativeWasmType for u32 {
124 const WASM_TYPE: Type = Type::I32;
125 type Abi = Self;
126 }
127
128 impl NativeWasmType for i32 {
129 const WASM_TYPE: Type = Type::I32;
130 type Abi = Self;
131 }
132
133 impl NativeWasmType for i64 {
134 const WASM_TYPE: Type = Type::I64;
135 type Abi = Self;
136 }
137
138 impl NativeWasmType for u64 {
139 const WASM_TYPE: Type = Type::I64;
140 type Abi = Self;
141 }
142
143 impl NativeWasmType for f32 {
144 const WASM_TYPE: Type = Type::F32;
145 type Abi = Self;
146 }
147
148 impl NativeWasmType for f64 {
149 const WASM_TYPE: Type = Type::F64;
150 type Abi = Self;
151 }
152
153 impl NativeWasmType for u128 {
154 const WASM_TYPE: Type = Type::V128;
155 type Abi = Self;
156 }
157
158 impl NativeWasmType for Memory32 {
159 const WASM_TYPE: Type = <<Self as MemorySize>::Native as NativeWasmType>::WASM_TYPE;
160 type Abi = <<Self as MemorySize>::Native as NativeWasmType>::Abi;
161 }
162
163 impl NativeWasmType for Memory64 {
164 const WASM_TYPE: Type = <<Self as MemorySize>::Native as NativeWasmType>::WASM_TYPE;
165 type Abi = <<Self as MemorySize>::Native as NativeWasmType>::Abi;
166 }
167
168 impl<T: NativeWasmType> NativeWasmType for Option<T> {
169 const WASM_TYPE: Type = T::WASM_TYPE;
170 type Abi = T::Abi;
171 }
172}
173
174pub use crate::native::*;