summaryrefslogtreecommitdiff
path: root/crates/types/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/types/src')
-rw-r--r--crates/types/src/instructions.rs6
-rw-r--r--crates/types/src/lib.rs7
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]>,
}