diff options
| author | Henry Gressmann <mail@henrygressmann.de> | 2023-12-02 23:50:14 +0100 |
|---|---|---|
| committer | Henry Gressmann <mail@henrygressmann.de> | 2023-12-02 23:50:14 +0100 |
| commit | 7f72605405443482add128cb66b7d09e6bb59de9 (patch) | |
| tree | e59314708468f1aed11fd218868d9fc18f480d3a /crates/types/src | |
| parent | 07a0404aff79a8598392cfa0eed8aea96122adf5 (diff) | |
feat: finish parser module, switch from tracing to log
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/types/src')
| -rw-r--r-- | crates/types/src/instructions.rs | 6 | ||||
| -rw-r--r-- | crates/types/src/lib.rs | 7 |
2 files changed, 7 insertions, 6 deletions
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]>, } |
