diff options
Diffstat (limited to 'crates/types')
| -rw-r--r-- | crates/types/Cargo.toml | 2 | ||||
| -rw-r--r-- | crates/types/src/instructions.rs | 6 | ||||
| -rw-r--r-- | crates/types/src/lib.rs | 7 |
3 files changed, 8 insertions, 7 deletions
diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index fa2fc6e..e34c474 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -4,7 +4,7 @@ version="0.0.0" edition="2021" [dependencies] -tracing={version="0.1.38", default-features=false} # logging +log="0.4.20" rkyv={version="0.7", optional=true, default-features=false} [features] diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index 993b260..dca99fe 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -1,5 +1,4 @@ use super::{FuncAddr, GlobalAddr, LabelAddr, LocalAddr, TableAddr, TypeAddr, ValType}; -use alloc::{format, vec::Vec}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum BlockArgs { @@ -9,7 +8,7 @@ pub enum BlockArgs { } /// Represents a memory immediate in a WebAssembly memory instruction. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct MemArg { pub align: u8, pub offset: u64, @@ -18,6 +17,7 @@ pub struct MemArg { /// A WebAssembly Instruction /// See https://webassembly.github.io/spec/core/binary/instructions.html /// Currently includes all instructions from the MVP (1.0) spec +#[derive(Debug, Clone, Copy, PartialEq)] pub enum Instruction { // Control Instructions // See https://webassembly.github.io/spec/core/binary/instructions.html#control-instructions @@ -30,7 +30,7 @@ pub enum Instruction { End, Br(LabelAddr), BrIf(LabelAddr), - BrTable(Vec<LabelAddr>, LabelAddr), // not to spec, instead of a vector of labels, we have a label and a count + BrTable(u32), // not to spec, has to be followed by multiple Br instructions with labels Return, Call(FuncAddr), CallIndirect(TypeAddr, TableAddr), diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index e793b26..af5cf1a 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -7,9 +7,9 @@ pub struct TinyWasmModule { pub version: Option<u16>, pub start_func: Option<u32>, - pub types: Option<Box<[FuncType]>>, - pub funcs: Option<Box<[Function]>>, - pub exports: Option<Box<[Export]>>, + pub types: Box<[FuncType]>, + pub funcs: Box<[Function]>, + pub exports: Box<[Export]>, // pub tables: Option<TableType>, // pub memories: Option<MemoryType>, // pub globals: Option<GlobalType>, @@ -98,6 +98,7 @@ pub struct FuncType { /// A WebAssembly Function pub struct Function { + pub ty: TypeAddr, pub locals: Box<[ValType]>, pub body: Box<[Instruction]>, } |
