provide a way to replace the tag in a Scalar/MemPlace
This commit is contained in:
parent
d2c19e0bcc
commit
005df5fe03
2 changed files with 28 additions and 0 deletions
|
|
@ -138,6 +138,14 @@ impl<'tcx, Tag> Scalar<Tag> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_tag(self, new_tag: Tag) -> Self {
|
||||
match self {
|
||||
Scalar::Ptr(ptr) => Scalar::Ptr(Pointer { tag: new_tag, ..ptr }),
|
||||
Scalar::Bits { bits, size } => Scalar::Bits { bits, size },
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn ptr_null(cx: &impl HasDataLayout) -> Self {
|
||||
Scalar::Bits {
|
||||
|
|
|
|||
|
|
@ -115,6 +115,16 @@ impl<Tag> MemPlace<Tag> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_tag(self, new_tag: Tag) -> Self
|
||||
{
|
||||
MemPlace {
|
||||
ptr: self.ptr.with_tag(new_tag),
|
||||
align: self.align,
|
||||
meta: self.meta,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn from_scalar_ptr(ptr: Scalar<Tag>, align: Align) -> Self {
|
||||
MemPlace {
|
||||
|
|
@ -187,6 +197,16 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_tag(self, new_tag: Tag) -> Self
|
||||
{
|
||||
MPlaceTy {
|
||||
mplace: self.mplace.with_tag(new_tag),
|
||||
layout: self.layout,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn offset(
|
||||
self,
|
||||
offset: Size,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue