add ImmTy::try_from_(u)int methods
This commit is contained in:
parent
0bce91ff0b
commit
90686ded25
1 changed files with 11 additions and 2 deletions
|
|
@ -218,14 +218,23 @@ impl<'tcx, Tag: Copy> ImmTy<'tcx, Tag> {
|
|||
ImmTy { imm: val.into(), layout }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn try_from_uint(i: impl Into<u128>, layout: TyLayout<'tcx>) -> InterpResult<'tcx, Self> {
|
||||
Ok(Self::from_scalar(Scalar::try_from_uint(i, layout.size)?, layout))
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_uint(i: impl Into<u128>, layout: TyLayout<'tcx>) -> Self {
|
||||
Self::from_scalar(Scalar::from_uint(i, layout.size), layout)
|
||||
Self::try_from_uint(i, layout).unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn try_from_int(i: impl Into<i128>, layout: TyLayout<'tcx>) -> InterpResult<'tcx, Self> {
|
||||
Ok(Self::from_scalar(Scalar::try_from_int(i, layout.size)?, layout))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_int(i: impl Into<i128>, layout: TyLayout<'tcx>) -> Self {
|
||||
Self::from_scalar(Scalar::from_int(i, layout.size), layout)
|
||||
Self::try_from_int(i, layout).unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue