This commit is contained in:
parent
790bb15408
commit
8449854cac
|
@ -1236,10 +1236,11 @@ macro_rules! impl_dyn_shl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_binary_op_trait! {
|
impl<LhsWidth: Size, RhsWidth: Size> Shl<Expr<UIntType<RhsWidth>>> for Expr<$ty<LhsWidth>> {
|
||||||
#[generics(LhsWidth: Size, RhsWidth: Size)]
|
type Output = Expr<$ty>;
|
||||||
fn Shl::shl(lhs: $ty<LhsWidth>, rhs: UIntType<RhsWidth>) -> $ty {
|
|
||||||
$name::new(Expr::as_dyn_int(lhs), Expr::as_dyn_int(rhs)).to_expr()
|
fn shl(self, rhs: Expr<UIntType<RhsWidth>>) -> Self::Output {
|
||||||
|
$name::new(Expr::as_dyn_int(self), Expr::as_dyn_int(rhs)).to_expr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1308,10 +1309,11 @@ macro_rules! impl_dyn_shr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_binary_op_trait! {
|
impl<LhsWidth: Size, RhsWidth: Size> Shr<Expr<UIntType<RhsWidth>>> for Expr<$ty<LhsWidth>> {
|
||||||
#[generics(LhsWidth: Size, RhsWidth: Size)]
|
type Output = Expr<$ty<LhsWidth>>;
|
||||||
fn Shr::shr(lhs: $ty<LhsWidth>, rhs: UIntType<RhsWidth>) -> $ty<LhsWidth> {
|
|
||||||
$name::new(lhs, Expr::as_dyn_int(rhs)).to_expr()
|
fn shr(self, rhs: Expr<UIntType<RhsWidth>>) -> Self::Output {
|
||||||
|
$name::new(self, Expr::as_dyn_int(rhs)).to_expr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,7 @@ use std::{
|
||||||
borrow::{BorrowMut, Cow},
|
borrow::{BorrowMut, Cow},
|
||||||
fmt,
|
fmt,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
|
num::NonZero,
|
||||||
ops::{Bound, Index, Not, Range, RangeBounds, RangeInclusive},
|
ops::{Bound, Index, Not, Range, RangeBounds, RangeInclusive},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
@ -468,7 +469,11 @@ impl SInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_prim_int {
|
macro_rules! impl_prim_int {
|
||||||
($prim_int:ident, $ty:ty) => {
|
(
|
||||||
|
$(#[$meta:meta])*
|
||||||
|
$prim_int:ident, $ty:ty
|
||||||
|
) => {
|
||||||
|
$(#[$meta])*
|
||||||
impl ToExpr for $prim_int {
|
impl ToExpr for $prim_int {
|
||||||
type Type = $ty;
|
type Type = $ty;
|
||||||
|
|
||||||
|
@ -479,6 +484,17 @@ macro_rules! impl_prim_int {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$(#[$meta])*
|
||||||
|
impl ToExpr for NonZero<$prim_int> {
|
||||||
|
type Type = $ty;
|
||||||
|
|
||||||
|
fn to_expr(&self) -> Expr<Self::Type> {
|
||||||
|
<$ty>::le_bytes_to_expr_wrapping(
|
||||||
|
&self.get().to_le_bytes(),
|
||||||
|
<$ty as BoolOrIntType>::Width::VALUE,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,6 +509,16 @@ impl_prim_int!(i32, SInt<32>);
|
||||||
impl_prim_int!(i64, SInt<64>);
|
impl_prim_int!(i64, SInt<64>);
|
||||||
impl_prim_int!(i128, SInt<128>);
|
impl_prim_int!(i128, SInt<128>);
|
||||||
|
|
||||||
|
impl_prim_int!(
|
||||||
|
/// for portability reasons, [`usize`] always translates to [`UInt<64>`]
|
||||||
|
usize, UInt<64>
|
||||||
|
);
|
||||||
|
|
||||||
|
impl_prim_int!(
|
||||||
|
/// for portability reasons, [`isize`] always translates to [`SInt<64>`]
|
||||||
|
isize, SInt<64>
|
||||||
|
);
|
||||||
|
|
||||||
pub trait BoolOrIntType: Type + sealed::BoolOrIntTypeSealed {
|
pub trait BoolOrIntType: Type + sealed::BoolOrIntTypeSealed {
|
||||||
type Width: Size;
|
type Width: Size;
|
||||||
type Signed: GenericConstBool;
|
type Signed: GenericConstBool;
|
||||||
|
|
Loading…
Reference in a new issue