From f99b3a90827406b48657d63d7c1f0188ddd68c8f Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 15 Jul 2026 15:20:00 +0200 Subject: feat: decouple validation from parsing Signed-off-by: Henry --- crates/types/src/instructions.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'crates/types') diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index c8ffe2c..c104ce0 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -11,6 +11,21 @@ pub struct MemoryArg { mem_addr: MemAddr, } +/// Stack lanes discarded and retained when branching to a control frame. +#[derive(Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "debug", derive(Debug))] +#[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] +pub struct DropKeep { + pub base: ValueCounts, + pub keep: ValueCounts, +} + +impl From<(ValueCounts, ValueCounts)> for DropKeep { + fn from((base, keep): (ValueCounts, ValueCounts)) -> Self { + Self { base, keep } + } +} + impl MemoryArg { #[inline] pub const fn new(offset: u64, mem_addr: MemAddr) -> Self { @@ -159,8 +174,6 @@ pub enum Instruction { // > Control Instructions (jump-oriented, lowered from structured control during parsing) // See Unreachable, - Nop, - MergeBarrier, Jump(u32), JumpIfZero32(u32), JumpIfNonZero32(u32), @@ -176,10 +189,7 @@ pub enum Instruction { JumpCmpLocalConst64 { target_ip: u32, local: LocalAddr, imm: i32, op: CmpOp }, JumpCmpLocalLocal32 { target_ip: u32, left: LocalAddr, right: LocalAddr, op: CmpOp }, JumpCmpLocalLocal64 { target_ip: u32, left: LocalAddr, right: LocalAddr, op: CmpOp }, - DropKeep { base32: u16, keep32: u8, base64: u16, keep64: u8, base128: u16, keep128: u8 }, - DropKeep32(u16, u16), - DropKeep64(u16, u16), - DropKeep128(u16, u16), + DropKeep(DropKeep), BranchTable(u32, u32, u32), // (default_landing_pad_ip, branch_table_start, target_count) Return, ReturnVoid, -- cgit v1.3.1