From d08750034a582b7ef338432a360c62a2969f6aa0 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Sat, 9 Dec 2023 14:56:03 +0100 Subject: chore: improve documentation Signed-off-by: Henry Gressmann --- crates/types/Cargo.toml | 3 ++- crates/types/README.md | 1 + crates/types/src/instructions.rs | 12 +++++++----- crates/types/src/lib.rs | 19 +++++++++++++------ 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 crates/types/README.md (limited to 'crates/types') diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index 082723f..e91a4f1 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -1,7 +1,8 @@ [package] name="tinywasm-types" -version="0.0.0" +version="0.0.1" edition="2021" +readme="../../README.md" [dependencies] log={version="0.4", optional=true} diff --git a/crates/types/README.md b/crates/types/README.md new file mode 100644 index 0000000..93b6f4b --- /dev/null +++ b/crates/types/README.md @@ -0,0 +1 @@ +# `tinywasm_types` diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index 005da36..6db5e6b 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -18,17 +18,19 @@ type BrTableDefault = u32; type BrTableLen = usize; /// A WebAssembly Instruction -/// See https://webassembly.github.io/spec/core/binary/instructions.html +/// /// These are our own internal bytecode instructions so they may not match the spec exactly. /// Wasm Bytecode can map to multiple of these instructions. /// For example, `br_table` stores the jump lables in the following `br_label` instructions to keep this enum small. +/// +/// See #[derive(Debug, Clone, Copy, PartialEq)] pub enum Instruction { // Custom Instructions BrLabel(LabelAddr), // Control Instructions - // See https://webassembly.github.io/spec/core/binary/instructions.html#control-instructions + // See Unreachable, Nop, Block(BlockArgs), @@ -44,12 +46,12 @@ pub enum Instruction { CallIndirect(TypeAddr, TableAddr), // Parametric Instructions - // See https://webassembly.github.io/spec/core/binary/instructions.html#parametric-instructions + // See Drop, Select, // Variable Instructions - // See https://webassembly.github.io/spec/core/binary/instructions.html#variable-instructions + // See LocalGet(LocalAddr), LocalSet(LocalAddr), LocalTee(LocalAddr), @@ -90,7 +92,7 @@ pub enum Instruction { F64Const(f64), // Numeric Instructions - // See https://webassembly.github.io/spec/core/binary/instructions.html#numeric-instructions + // See I32Eqz, I32Eq, I32Ne, diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index 90c4f10..b79c72a 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -34,7 +34,8 @@ pub struct TinyWasmModule { } /// A WebAssembly value. -/// See https://webassembly.github.io/spec/core/syntax/types.html#value-types +/// +/// See #[derive(Clone, PartialEq, Copy)] pub enum WasmValue { // Num types @@ -182,7 +183,8 @@ pub enum ValType { } /// A WebAssembly External Kind. -/// See https://webassembly.github.io/spec/core/syntax/types.html#external-types +/// +/// See #[derive(Debug, Clone, PartialEq)] pub enum ExternalKind { Func, @@ -192,8 +194,10 @@ pub enum ExternalKind { } /// A WebAssembly Address. +/// /// These are indexes into the respective stores. -/// See https://webassembly.github.io/spec/core/exec/runtime.html#addresses +/// +/// See pub type Addr = u32; pub type FuncAddr = Addr; pub type TableAddr = Addr; @@ -209,7 +213,8 @@ pub type LabelAddr = Addr; pub type ModuleInstanceAddr = Addr; /// A WebAssembly Export Instance. -/// https://webassembly.github.io/spec/core/exec/runtime.html#export-instances +/// +/// See #[derive(Debug)] pub struct ExportInst { pub name: String, @@ -217,7 +222,8 @@ pub struct ExportInst { } /// A WebAssembly External Value. -/// https://webassembly.github.io/spec/core/exec/runtime.html#external-values +/// +/// See #[derive(Debug)] pub enum ExternVal { Func(FuncAddr), @@ -227,7 +233,8 @@ pub enum ExternVal { } /// The type of a WebAssembly Function. -/// See https://webassembly.github.io/spec/core/syntax/types.html#function-types +/// +/// See #[derive(Debug, Clone, PartialEq)] pub struct FuncType { pub params: Box<[ValType]>, -- cgit v1.3.1