diff options
| author | Henry <mail@henrygressmann.de> | 2026-04-05 20:49:40 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-04-05 20:49:40 +0200 |
| commit | 7d4dfd8ec65c78eb8154d89aa77dd71ac65015f6 (patch) | |
| tree | 7db6f65b35553a9994a3790e885721bdcbddf1ca /crates/types | |
| parent | 66c9f7ab06dd67ac6e62321dd33943de7f9f9e57 (diff) | |
chore: cleanup
Diffstat (limited to 'crates/types')
| -rw-r--r-- | crates/types/src/instructions.rs | 4 | ||||
| -rw-r--r-- | crates/types/src/lib.rs | 36 |
2 files changed, 10 insertions, 30 deletions
diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index 78b52b8..0cbcad7 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -1,4 +1,4 @@ -use super::{FuncAddr, GlobalAddr, LocalAddr, TableAddr, TypeAddr, ValType, ValueCountsSmall}; +use super::{FuncAddr, GlobalAddr, LocalAddr, TableAddr, TypeAddr, ValType, ValueCounts}; use crate::{ConstIdx, DataAddr, ElemAddr, ExternAddr, MemAddr}; /// Represents a memory immediate in a WebAssembly memory instruction. @@ -92,7 +92,7 @@ pub enum Instruction { Drop64, Select64, Drop128, Select128, DropRef, SelectRef, - SelectMulti(ValueCountsSmall), + SelectMulti(ValueCounts), // > Variable Instructions // See <https://webassembly.github.io/spec/core/binary/instructions.html#variable-instructions> diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index a56dc9f..e9d2729 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -208,16 +208,6 @@ pub struct FuncType { #[cfg_attr(feature = "debug", derive(Debug))] #[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] pub struct ValueCounts { - pub c32: u32, - pub c64: u32, - pub c128: u32, - pub cref: u32, -} - -#[derive(Default, Clone, Copy, PartialEq, Eq)] -#[cfg_attr(feature = "debug", derive(Debug))] -#[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] -pub struct ValueCountsSmall { pub c32: u16, pub c64: u16, pub c128: u16, @@ -240,30 +230,14 @@ impl<'a, T: IntoIterator<Item = &'a ValType>> From<T> for ValueCounts { } } -impl<'a, T: IntoIterator<Item = &'a ValType>> From<T> for ValueCountsSmall { - #[inline] - fn from(types: T) -> Self { - let mut counts = Self::default(); - for ty in types { - match ty { - ValType::I32 | ValType::F32 => counts.c32 += 1, - ValType::I64 | ValType::F64 => counts.c64 += 1, - ValType::V128 => counts.c128 += 1, - ValType::RefExtern | ValType::RefFunc => counts.cref += 1, - } - } - counts - } -} - #[derive(Clone, PartialEq, Default)] #[cfg_attr(feature = "debug", derive(Debug))] #[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] pub struct WasmFunction { pub instructions: ArcSlice<Instruction>, pub data: WasmFunctionData, - pub locals: ValueCountsSmall, - pub params: ValueCountsSmall, + pub locals: ValueCounts, + pub params: ValueCounts, pub ty: FuncType, } @@ -298,6 +272,12 @@ impl<T> Deref for ArcSlice<T> { } } +impl<T> FromIterator<T> for ArcSlice<T> { + fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self { + Self(Arc::from_iter(iter)) + } +} + #[cfg(feature = "archive")] impl<T: serde::Serialize> serde::Serialize for ArcSlice<T> { fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { |
