[−][src]Enum rustc_middle::mir::interpret::value::Scalar

pub enum Scalar<Tag = ()> {
    Int(ScalarInt),
    Ptr(Pointer<Tag>),
}

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]

pub fn ptr_offset(
    self,
    i: Size,
    cx: &impl HasDataLayout
) -> InterpResult<'tcx, Self>
[src]

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]

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]

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]

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]

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]

pub(in mir::interpret::value) fn to_signed_with_bit_width(
    self,
    bits: u64
) -> InterpResult<'static, i128>
[src]

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]

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]

impl<Tag: Debug> Display for Scalar<Tag>[src]

impl<'tcx, Tag, __E: TyEncoder<'tcx>> Encodable<__E> for Scalar<Tag> where
    Tag: Encodable<__E>, 
[src]

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]

impl<'__ctx, Tag> HashStable<StableHashingContext<'__ctx>> for Scalar<Tag> where
    Tag: HashStable<StableHashingContext<'__ctx>>, 
[src]

impl<Tag: Ord> Ord for Scalar<Tag>[src]

impl<Tag: PartialEq> PartialEq<Scalar<Tag>> for Scalar<Tag>[src]

impl<Tag: PartialOrd> PartialOrd<Scalar<Tag>> for Scalar<Tag>[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, 

impl<Tag> Send for Scalar<Tag> where
    Tag: Send, 

impl<Tag> Sync for Scalar<Tag> where
    Tag: Sync, 

impl<Tag> Unpin for Scalar<Tag> where
    Tag: Unpin, 

impl<Tag> UnwindSafe for Scalar<Tag> where
    Tag: UnwindSafe, 

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
    T: Copy, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeResult<T> for T[src]

type Error = !

impl<T> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]