Enum rustc_middle::mir::interpret::value::Scalar [−][src]
Expand description
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 16 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
Erase the tag from the scalar, if any.
Used by error reporting code to avoid having the error type depend on Tag.
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>pub fn to_bits_or_ptr(
self,
target_size: Size,
cx: &impl HasDataLayout
) -> Result<u128, Pointer<Tag>>
pub fn to_bits_or_ptr(
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.
This method is intentionally private! It is just a helper for other methods in this file.
Converts the scalar to produce an u8. Fails if the scalar is a pointer.
Converts the scalar to produce an u16. Fails if the scalar is a pointer.
Converts the scalar to produce an u32. Fails if the scalar is a pointer.
Converts the scalar to produce an u64. Fails if the scalar is a pointer.
Converts the scalar to produce an u128. Fails if the scalar is a pointer.
Converts the scalar to produce an i8. Fails if the scalar is a pointer.
Converts the scalar to produce an i16. Fails if the scalar is a pointer.
Converts the scalar to produce an i32. Fails if the scalar is a pointer.
Converts the scalar to produce an i64. Fails if the scalar is a pointer.
Converts the scalar to produce an i128. Fails if the scalar is a pointer.
Trait Implementations
impl<'__ctx, Tag> HashStable<StableHashingContext<'__ctx>> for Scalar<Tag> where
Tag: HashStable<StableHashingContext<'__ctx>>,
impl<'__ctx, Tag> HashStable<StableHashingContext<'__ctx>> for Scalar<Tag> where
Tag: HashStable<StableHashingContext<'__ctx>>, This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl<Tag> RefUnwindSafe for Scalar<Tag> where
Tag: RefUnwindSafe, impl<Tag> UnwindSafe for Scalar<Tag> where
Tag: UnwindSafe, Blanket Implementations
Mutably borrows from an owned value. Read more
Layout
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.