[−][src]Enum rustc_mir::interpret::Scalar

pub enum Scalar<Tag = ()> {
    Raw {
        data: u128,
        size: u8,
    },
    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

Raw

The raw bytes of a simple value.

Fields of Raw

data: u128

The first size bytes of data are the value. Do not try to read less or more bytes than that. The remaining bytes must be 0.

size: u8
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 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) -> Scalar<Tag>[src]

pub fn zst() -> Scalar<Tag>[src]

pub fn ptr_offset(
    self,
    i: Size,
    cx: &impl HasDataLayout
) -> Result<Scalar<Tag>, InterpErrorInfo<'tcx>>
[src]

pub fn ptr_wrapping_offset(
    self,
    i: Size,
    cx: &impl HasDataLayout
) -> Scalar<Tag>
[src]

pub fn ptr_signed_offset(
    self,
    i: i64,
    cx: &impl HasDataLayout
) -> Result<Scalar<Tag>, InterpErrorInfo<'tcx>>
[src]

pub fn ptr_wrapping_signed_offset(
    self,
    i: i64,
    cx: &impl HasDataLayout
) -> Scalar<Tag>
[src]

pub fn from_bool(b: bool) -> Scalar<Tag>[src]

pub fn from_char(c: char) -> Scalar<Tag>[src]

pub fn try_from_uint(i: impl Into<u128>, size: Size) -> Option<Scalar<Tag>>[src]

pub fn from_uint(i: impl Into<u128>, size: Size) -> Scalar<Tag>[src]

pub fn from_u8(i: u8) -> Scalar<Tag>[src]

pub fn from_u16(i: u16) -> Scalar<Tag>[src]

pub fn from_u32(i: u32) -> Scalar<Tag>[src]

pub fn from_u64(i: u64) -> Scalar<Tag>[src]

pub fn from_machine_usize(i: u64, cx: &impl HasDataLayout) -> Scalar<Tag>[src]

pub fn try_from_int(i: impl Into<i128>, size: Size) -> Option<Scalar<Tag>>[src]

pub fn from_int(i: impl Into<i128>, size: Size) -> Scalar<Tag>[src]

pub fn from_i8(i: i8) -> Scalar<Tag>[src]

pub fn from_i16(i: i16) -> Scalar<Tag>[src]

pub fn from_i32(i: i32) -> Scalar<Tag>[src]

pub fn from_i64(i: i64) -> Scalar<Tag>[src]

pub fn from_machine_isize(i: i64, cx: &impl HasDataLayout) -> Scalar<Tag>[src]

pub fn from_f32(f: IeeeFloat<SingleS>) -> Scalar<Tag>[src]

pub fn from_f64(f: IeeeFloat<DoubleS>) -> Scalar<Tag>[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 fn assert_bits(self, target_size: Size) -> u128[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) -> Result<bool, InterpErrorInfo<'tcx>>[src]

pub fn to_char(self) -> Result<char, InterpErrorInfo<'tcx>>[src]

pub fn to_u8(self) -> Result<u8, InterpErrorInfo<'static>>[src]

Converts the scalar to produce an u8. Fails if the scalar is a pointer.

pub fn to_u16(self) -> Result<u16, InterpErrorInfo<'static>>[src]

Converts the scalar to produce an u16. Fails if the scalar is a pointer.

pub fn to_u32(self) -> Result<u32, InterpErrorInfo<'static>>[src]

Converts the scalar to produce an u32. Fails if the scalar is a pointer.

pub fn to_u64(self) -> Result<u64, InterpErrorInfo<'static>>[src]

Converts the scalar to produce an u64. Fails if the scalar is a pointer.

pub fn to_machine_usize(
    self,
    cx: &impl HasDataLayout
) -> Result<u64, InterpErrorInfo<'static>>
[src]

pub fn to_i8(self) -> Result<i8, InterpErrorInfo<'static>>[src]

Converts the scalar to produce an i8. Fails if the scalar is a pointer.

pub fn to_i16(self) -> Result<i16, InterpErrorInfo<'static>>[src]

Converts the scalar to produce an i16. Fails if the scalar is a pointer.

pub fn to_i32(self) -> Result<i32, InterpErrorInfo<'static>>[src]

Converts the scalar to produce an i32. Fails if the scalar is a pointer.

pub fn to_i64(self) -> Result<i64, InterpErrorInfo<'static>>[src]

Converts the scalar to produce an i64. Fails if the scalar is a pointer.

pub fn to_machine_isize(
    self,
    cx: &impl HasDataLayout
) -> Result<i64, InterpErrorInfo<'static>>
[src]

pub fn to_f32(self) -> Result<IeeeFloat<SingleS>, InterpErrorInfo<'static>>[src]

pub fn to_f64(self) -> Result<IeeeFloat<DoubleS>, InterpErrorInfo<'static>>[src]

Trait Implementations

impl<Tag> Clone for Scalar<Tag> where
    Tag: Clone, 
[src]

impl<Tag> Copy for Scalar<Tag> where
    Tag: Copy, 
[src]

impl<Tag> Debug for Scalar<Tag> where
    Tag: Debug, 
[src]

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

impl<Tag> Eq for Scalar<Tag> where
    Tag: Eq, 
[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> From<Scalar<Tag>> for Immediate<Tag>[src]

impl<Tag> Hash for Scalar<Tag> where
    Tag: Hash, 
[src]

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

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

impl<Tag> PartialOrd<Scalar<Tag>> for Scalar<Tag> where
    Tag: PartialOrd<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<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> 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> 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]