summaryrefslogtreecommitdiff
path: root/crates/types
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2024-03-09 13:51:32 +0100
committerHenry Gressmann <mail@henrygressmann.de>2024-03-09 13:51:32 +0100
commit735c7cb636edfd4704460c94a9c7d65e5bf4df48 (patch)
tree5b60de853a4bb62649d2d1ce4732bdfa49ce29fb /crates/types
parentc50bae752f3e788faf66b376d065374cc4085931 (diff)
chore: improve documentation, tests
Closes #6 Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/types')
-rw-r--r--crates/types/src/lib.rs48
-rw-r--r--crates/types/src/value.rs2
2 files changed, 30 insertions, 20 deletions
diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs
index d2da7d7..679f3bf 100644
--- a/crates/types/src/lib.rs
+++ b/crates/types/src/lib.rs
@@ -41,37 +41,54 @@ pub mod archive;
#[derive(Debug, Clone, Default, PartialEq)]
#[cfg_attr(feature = "archive", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize), archive(check_bytes))]
pub struct TinyWasmModule {
- /// The version of the WebAssembly module.
- pub version: Option<u16>,
-
- /// The start function of the WebAssembly module.
+ /// Optional address of the start function
+ ///
+ /// Corresponds to the `start` section of the original WebAssembly module.
pub start_func: Option<FuncAddr>,
- /// The functions of the WebAssembly module.
- pub funcs: Box<[TypedWasmFunction]>,
+ /// Optimized and validated WebAssembly functions
+ ///
+ /// Contains data from to the `code`, `func`, and `type` sections of the original WebAssembly module.
+ pub funcs: Box<[WasmFunction]>,
- /// The types of the WebAssembly module.
+ /// A vector of type definitions, indexed by `TypeAddr`
+ ///
+ /// Corresponds to the `type` section of the original WebAssembly module.
pub func_types: Box<[FuncType]>,
- /// The exports of the WebAssembly module.
+ /// Exported items of the WebAssembly module.
+ ///
+ /// Corresponds to the `export` section of the original WebAssembly module.
pub exports: Box<[Export]>,
- /// The tables of the WebAssembly module.
+ /// Global components of the WebAssembly module.
+ ///
+ /// Corresponds to the `global` section of the original WebAssembly module.
pub globals: Box<[Global]>,
- /// The tables of the WebAssembly module.
+ /// Table components of the WebAssembly module used to initialize tables.
+ ///
+ /// Corresponds to the `table` section of the original WebAssembly module.
pub table_types: Box<[TableType]>,
- /// The memories of the WebAssembly module.
+ /// Memory components of the WebAssembly module used to initialize memories.
+ ///
+ /// Corresponds to the `memory` section of the original WebAssembly module.
pub memory_types: Box<[MemoryType]>,
- /// The imports of the WebAssembly module.
+ /// Imports of the WebAssembly module.
+ ///
+ /// Corresponds to the `import` section of the original WebAssembly module.
pub imports: Box<[Import]>,
/// Data segments of the WebAssembly module.
+ ///
+ /// Corresponds to the `data` section of the original WebAssembly module.
pub data: Box<[Data]>,
/// Element segments of the WebAssembly module.
+ ///
+ /// Corresponds to the `elem` section of the original WebAssembly module.
pub elements: Box<[Element]>,
}
@@ -164,13 +181,6 @@ pub struct WasmFunction {
pub ty: FuncType,
}
-#[derive(Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "archive", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize), archive(check_bytes))]
-pub struct TypedWasmFunction {
- pub type_addr: u32,
- pub wasm_function: WasmFunction,
-}
-
/// A WebAssembly Module Export
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "archive", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize), archive(check_bytes))]
diff --git a/crates/types/src/value.rs b/crates/types/src/value.rs
index bcd43e5..28ca6e2 100644
--- a/crates/types/src/value.rs
+++ b/crates/types/src/value.rs
@@ -5,7 +5,7 @@ use crate::{ConstInstruction, ExternAddr, FuncAddr};
/// A WebAssembly value.
///
/// See <https://webassembly.github.io/spec/core/syntax/types.html#value-types>
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, PartialEq)]
pub enum WasmValue {
// Num types
/// A 32-bit integer.