From a579aca308d0bb3021f8089329dee4071d8d31c4 Mon Sep 17 00:00:00 2001 From: Enrico Zandomeni Borba Date: Wed, 10 Apr 2024 09:37:23 -0400 Subject: [PATCH] op_word --- src/ops.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ops.rs b/src/ops.rs index 2b9ccb93..302c3ce5 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -126,6 +126,10 @@ impl Op { Self::ShrS => T::shr(b, a), } } + + fn op_word(self, a: u64, b: u64) -> u64 { + self.op(T::from_word(a), T::from_word(b)).to_word() + } } /// A numeric operator. @@ -153,19 +157,19 @@ impl TypedOp { #[inline] pub fn op(self, a: u64, b: u64) -> u64 { - const U60: i64 = 0xFFF_FFFF_FFFF_FFFF; + const U60: u64 = 0xFFF_FFFF_FFFF_FFFF; match self.ty { - Ty::I8 => self.op.op(i8::from_word(a), i8::from_word(b)).to_word(), - Ty::I16 => self.op.op(i16::from_word(a), i16::from_word(b)).to_word(), - Ty::I32 => self.op.op(i32::from_word(a), i32::from_word(b)).to_word(), + Ty::I8 => self.op.op_word::(a, b), + Ty::I16 => self.op.op_word::(a, b), + Ty::I32 => self.op.op_word::(a, b), - Ty::U8 => self.op.op(u8::from_word(a), u8::from_word(b)).to_word(), - Ty::U16 => self.op.op(u16::from_word(a), u16::from_word(b)).to_word(), - Ty::U32 => self.op.op(u32::from_word(a), u32::from_word(b)).to_word(), - Ty::U60 => self.op.op(u64::from_word(a), u64::from_word(b)).to_word() & U60, + Ty::U8 => self.op.op_word::(a, b), + Ty::U16 => self.op.op_word::(a, b), + Ty::U32 => self.op.op_word::(a, b), + Ty::U60 => self.op.op_word::(a, b) & U60, - Ty::F32 => self.op.op(OrderedFloat::::from_word(a), OrderedFloat::::from_word(b)).to_word(), + Ty::F32 => self.op.op_word::>(a, b), } } }