[−][src]Enum rustc_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
The raw bytes of a simple value.
Fields of Raw
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]
self,
i: Size,
cx: &impl HasDataLayout
) -> Result<Scalar<Tag>, InterpErrorInfo<'tcx>>
pub fn ptr_wrapping_offset(
self,
i: Size,
cx: &impl HasDataLayout
) -> Scalar<Tag>[src]
self,
i: Size,
cx: &impl HasDataLayout
) -> Scalar<Tag>
pub fn ptr_signed_offset(
self,
i: i64,
cx: &impl HasDataLayout
) -> Result<Scalar<Tag>, InterpErrorInfo<'tcx>>[src]
self,
i: i64,
cx: &impl HasDataLayout
) -> Result<Scalar<Tag>, InterpErrorInfo<'tcx>>
pub fn ptr_wrapping_signed_offset(
self,
i: i64,
cx: &impl HasDataLayout
) -> Scalar<Tag>[src]
self,
i: i64,
cx: &impl HasDataLayout
) -> Scalar<Tag>
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]
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 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]
self,
cx: &impl HasDataLayout
) -> Result<u64, InterpErrorInfo<'static>>
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]
self,
cx: &impl HasDataLayout
) -> Result<i64, InterpErrorInfo<'static>>
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]
Tag: Clone,
impl<Tag> Copy for Scalar<Tag> where
Tag: Copy, [src]
Tag: Copy,
impl<Tag> Debug for Scalar<Tag> where
Tag: Debug, [src]
Tag: Debug,
impl<Tag> Display for Scalar<Tag> where
Tag: Debug, [src]
Tag: Debug,
impl<Tag> Eq for Scalar<Tag> where
Tag: Eq, [src]
Tag: Eq,
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]
fn from(s: Scalar<Tag>) -> ScalarMaybeUninit<Tag>[src]
impl<Tag> From<Scalar<Tag>> for Immediate<Tag>[src]
impl<Tag> Hash for Scalar<Tag> where
Tag: Hash, [src]
Tag: Hash,
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher, [src]
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<Tag> Ord for Scalar<Tag> where
Tag: Ord, [src]
Tag: Ord,
fn cmp(&self, other: &Scalar<Tag>) -> Ordering[src]
#[must_use]fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self[src]
impl<Tag> PartialEq<Scalar<Tag>> for Scalar<Tag> where
Tag: PartialEq<Tag>, [src]
Tag: PartialEq<Tag>,
impl<Tag> PartialOrd<Scalar<Tag>> for Scalar<Tag> where
Tag: PartialOrd<Tag>, [src]
Tag: PartialOrd<Tag>,
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<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
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.
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.