[−][src]Enum rustc_middle::mir::interpret::Scalar
A Scalar represents an immediate, primitive value existing outside of a
memory::Allocation. It is in many ways like a small chunk of a Allocation, up to 8 bytes in
size. Like a range of bytes in an Allocation, a Scalar can either represent the raw bytes
of a simple value or a pointer into another Allocation
Variants
Int(ScalarInt)The raw bytes of a simple value.
Ptr(Pointer<Tag>)A pointer into an Allocation. An Allocation in the memory module has a list of
relocations, but a Scalar is only large enough to contain one, so we just represent the
relocation and its associated offset together as a Pointer here.
Implementations
impl Scalar<()>[src]
pub fn with_tag<Tag>(self, new_tag: Tag) -> Scalar<Tag>[src]
Tag this scalar with new_tag if it is a pointer, leave it unchanged otherwise.
Used by MemPlace::replace_tag.
impl<'tcx, Tag> Scalar<Tag>[src]
pub const ZST: Self[src]
pub fn erase_tag(self) -> Scalar[src]
Erase the tag from the scalar, if any.
Used by error reporting code to avoid having the error type depend on Tag.
pub fn null_ptr(cx: &impl HasDataLayout) -> Self[src]
pub(in mir::interpret::value) fn ptr_op(
self,
dl: &TargetDataLayout,
f_int: impl FnOnce(u64) -> InterpResult<'tcx, u64>,
f_ptr: impl FnOnce(Pointer<Tag>) -> InterpResult<'tcx, Pointer<Tag>>
) -> InterpResult<'tcx, Self>[src]
self,
dl: &TargetDataLayout,
f_int: impl FnOnce(u64) -> InterpResult<'tcx, u64>,
f_ptr: impl FnOnce(Pointer<Tag>) -> InterpResult<'tcx, Pointer<Tag>>
) -> InterpResult<'tcx, Self>
pub fn ptr_offset(
self,
i: Size,
cx: &impl HasDataLayout
) -> InterpResult<'tcx, Self>[src]
self,
i: Size,
cx: &impl HasDataLayout
) -> InterpResult<'tcx, Self>
pub fn ptr_wrapping_offset(self, i: Size, cx: &impl HasDataLayout) -> Self[src]
pub fn ptr_signed_offset(
self,
i: i64,
cx: &impl HasDataLayout
) -> InterpResult<'tcx, Self>[src]
self,
i: i64,
cx: &impl HasDataLayout
) -> InterpResult<'tcx, Self>
pub fn ptr_wrapping_signed_offset(self, i: i64, cx: &impl HasDataLayout) -> Self[src]
pub fn from_bool(b: bool) -> Self[src]
pub fn from_char(c: char) -> Self[src]
pub fn try_from_uint(i: impl Into<u128>, size: Size) -> Option<Self>[src]
pub fn from_uint(i: impl Into<u128>, size: Size) -> Self[src]
pub fn from_u8(i: u8) -> Self[src]
pub fn from_u16(i: u16) -> Self[src]
pub fn from_u32(i: u32) -> Self[src]
pub fn from_u64(i: u64) -> Self[src]
pub fn from_machine_usize(i: u64, cx: &impl HasDataLayout) -> Self[src]
pub fn try_from_int(i: impl Into<i128>, size: Size) -> Option<Self>[src]
pub fn from_int(i: impl Into<i128>, size: Size) -> Self[src]
pub fn from_i8(i: i8) -> Self[src]
pub fn from_i16(i: i16) -> Self[src]
pub fn from_i32(i: i32) -> Self[src]
pub fn from_i64(i: i64) -> Self[src]
pub fn from_machine_isize(i: i64, cx: &impl HasDataLayout) -> Self[src]
pub fn from_f32(f: Single) -> Self[src]
pub fn from_f64(f: Double) -> Self[src]
pub fn to_bits_or_ptr(
self,
target_size: Size,
cx: &impl HasDataLayout
) -> Result<u128, Pointer<Tag>>[src]
self,
target_size: Size,
cx: &impl HasDataLayout
) -> Result<u128, Pointer<Tag>>
This is very rarely the method you want! You should dispatch on the type
and use force_bits/assert_bits/force_ptr/assert_ptr.
This method only exists for the benefit of low-level memory operations
as well as the implementation of the force_* methods.
pub(in mir::interpret::value) fn to_bits(
self,
target_size: Size
) -> InterpResult<'tcx, u128>[src]
self,
target_size: Size
) -> InterpResult<'tcx, u128>
This method is intentionally private! It is just a helper for other methods in this file.
pub fn assert_bits(self, target_size: Size) -> u128[src]
pub fn assert_int(self) -> ScalarInt[src]
pub fn assert_ptr(self) -> Pointer<Tag>[src]
pub fn is_bits(self) -> bool[src]
Do not call this method! Dispatch based on the type instead.
pub fn is_ptr(self) -> bool[src]
Do not call this method! Dispatch based on the type instead.
pub fn to_bool(self) -> InterpResult<'tcx, bool>[src]
pub fn to_char(self) -> InterpResult<'tcx, char>[src]
pub(in mir::interpret::value) fn to_unsigned_with_bit_width(
self,
bits: u64
) -> InterpResult<'static, u128>[src]
self,
bits: u64
) -> InterpResult<'static, u128>
pub fn to_u8(self) -> InterpResult<'static, u8>[src]
Converts the scalar to produce an u8. Fails if the scalar is a pointer.
pub fn to_u16(self) -> InterpResult<'static, u16>[src]
Converts the scalar to produce an u16. Fails if the scalar is a pointer.
pub fn to_u32(self) -> InterpResult<'static, u32>[src]
Converts the scalar to produce an u32. Fails if the scalar is a pointer.
pub fn to_u64(self) -> InterpResult<'static, u64>[src]
Converts the scalar to produce an u64. Fails if the scalar is a pointer.
pub fn to_u128(self) -> InterpResult<'static, u128>[src]
Converts the scalar to produce an u128. Fails if the scalar is a pointer.
pub fn to_machine_usize(
self,
cx: &impl HasDataLayout
) -> InterpResult<'static, u64>[src]
self,
cx: &impl HasDataLayout
) -> InterpResult<'static, u64>
pub(in mir::interpret::value) fn to_signed_with_bit_width(
self,
bits: u64
) -> InterpResult<'static, i128>[src]
self,
bits: u64
) -> InterpResult<'static, i128>
pub fn to_i8(self) -> InterpResult<'static, i8>[src]
Converts the scalar to produce an i8. Fails if the scalar is a pointer.
pub fn to_i16(self) -> InterpResult<'static, i16>[src]
Converts the scalar to produce an i16. Fails if the scalar is a pointer.
pub fn to_i32(self) -> InterpResult<'static, i32>[src]
Converts the scalar to produce an i32. Fails if the scalar is a pointer.
pub fn to_i64(self) -> InterpResult<'static, i64>[src]
Converts the scalar to produce an i64. Fails if the scalar is a pointer.
pub fn to_i128(self) -> InterpResult<'static, i128>[src]
Converts the scalar to produce an i128. Fails if the scalar is a pointer.
pub fn to_machine_isize(
self,
cx: &impl HasDataLayout
) -> InterpResult<'static, i64>[src]
self,
cx: &impl HasDataLayout
) -> InterpResult<'static, i64>
pub fn to_f32(self) -> InterpResult<'static, Single>[src]
pub fn to_f64(self) -> InterpResult<'static, Double>[src]
Trait Implementations
impl<Tag: Clone> Clone for Scalar<Tag>[src]
impl<Tag: Copy> Copy for Scalar<Tag>[src]
impl<Tag: Debug> Debug for Scalar<Tag>[src]
impl<'tcx, Tag, __D: TyDecoder<'tcx>> Decodable<__D> for Scalar<Tag> where
Tag: Decodable<__D>, [src]
Tag: Decodable<__D>,
impl<Tag: Debug> Display for Scalar<Tag>[src]
impl<'tcx, Tag, __E: TyEncoder<'tcx>> Encodable<__E> for Scalar<Tag> where
Tag: Encodable<__E>, [src]
Tag: Encodable<__E>,
impl<Tag: Eq> Eq for Scalar<Tag>[src]
impl<Tag> From<IeeeFloat<DoubleS>> for Scalar<Tag>[src]
impl<Tag> From<IeeeFloat<SingleS>> for Scalar<Tag>[src]
impl<Tag> From<Pointer<Tag>> for Scalar<Tag>[src]
impl<Tag> From<Scalar<Tag>> for ScalarMaybeUninit<Tag>[src]
impl<Tag: Hash> Hash for Scalar<Tag>[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<'__ctx, Tag> HashStable<StableHashingContext<'__ctx>> for Scalar<Tag> where
Tag: HashStable<StableHashingContext<'__ctx>>, [src]
Tag: HashStable<StableHashingContext<'__ctx>>,
pub fn hash_stable(
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)[src]
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)
impl<Tag: Ord> Ord for Scalar<Tag>[src]
pub fn cmp(&self, other: &Scalar<Tag>) -> Ordering[src]
#[must_use]pub fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self[src]
impl<Tag: PartialEq> PartialEq<Scalar<Tag>> for Scalar<Tag>[src]
pub fn eq(&self, other: &Scalar<Tag>) -> bool[src]
pub fn ne(&self, other: &Scalar<Tag>) -> bool[src]
impl<Tag: PartialOrd> PartialOrd<Scalar<Tag>> for Scalar<Tag>[src]
pub fn partial_cmp(&self, other: &Scalar<Tag>) -> Option<Ordering>[src]
pub fn lt(&self, other: &Scalar<Tag>) -> bool[src]
pub fn le(&self, other: &Scalar<Tag>) -> bool[src]
pub fn gt(&self, other: &Scalar<Tag>) -> bool[src]
pub fn ge(&self, other: &Scalar<Tag>) -> bool[src]
impl<Tag> StructuralEq for Scalar<Tag>[src]
impl<Tag> StructuralPartialEq for Scalar<Tag>[src]
Auto Trait Implementations
impl<Tag> RefUnwindSafe for Scalar<Tag> where
Tag: RefUnwindSafe,
Tag: RefUnwindSafe,
impl<Tag> Send for Scalar<Tag> where
Tag: Send,
Tag: Send,
impl<Tag> Sync for Scalar<Tag> where
Tag: Sync,
Tag: Sync,
impl<Tag> Unpin for Scalar<Tag> where
Tag: Unpin,
Tag: Unpin,
impl<Tag> UnwindSafe for Scalar<Tag> where
Tag: UnwindSafe,
Tag: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
T: Copy, [src]
T: Copy,
pub fn allocate_on(Self, &'a Arena<'tcx>) -> &'a mut T[src]
pub fn allocate_from_iter(
&'a Arena<'tcx>,
impl IntoIterator<Item = T>
) -> &'a mut [T][src]
&'a Arena<'tcx>,
impl IntoIterator<Item = T>
) -> &'a mut [T]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> MaybeResult<T> for T[src]
type Error = !
pub fn from(Result<T, <T as MaybeResult<T>>::Error>) -> T[src]
pub fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.