Struct cranelift_codegen::ir::constant::ConstantPool
source · [−]pub struct ConstantPool { /* private fields */ }Expand description
Maintains the mapping between a constant handle (i.e. Constant) and
its constant data (i.e. ConstantData).
Implementations
sourceimpl ConstantPool
impl ConstantPool
sourcepub fn insert(&mut self, constant_value: ConstantData) -> Constant
pub fn insert(&mut self, constant_value: ConstantData) -> Constant
Insert constant data into the pool, returning a handle for later referencing; when constant data is inserted that is a duplicate of previous constant data, the existing handle will be returned.
sourcepub fn get(&self, constant_handle: Constant) -> &ConstantData
pub fn get(&self, constant_handle: Constant) -> &ConstantData
Retrieve the constant data given a handle.
sourcepub fn set(&mut self, constant_handle: Constant, constant_value: ConstantData)
pub fn set(&mut self, constant_handle: Constant, constant_value: ConstantData)
Link a constant handle to its value. This does not de-duplicate data but does avoid
replacing any existing constant values. use set to tie a specific const42 to its value;
use insert to add a value and return the next available const entity.
sourcepub fn set_offset(
&mut self,
constant_handle: Constant,
constant_offset: ConstantOffset
)
pub fn set_offset(
&mut self,
constant_handle: Constant,
constant_offset: ConstantOffset
)
Assign an offset to a given constant, where the offset is the number of bytes from the beginning of the function to the beginning of the constant data inside the pool.
sourcepub fn get_offset(&self, constant_handle: Constant) -> ConstantOffset
pub fn get_offset(&self, constant_handle: Constant) -> ConstantOffset
Retrieve the offset of a given constant, where the offset is the number of bytes from the beginning of the function to the beginning of the constant data inside the pool.
sourcepub fn iter(&self) -> impl Iterator<Item = (&Constant, &ConstantData)>
pub fn iter(&self) -> impl Iterator<Item = (&Constant, &ConstantData)>
Iterate over the constants in insertion order.
sourcepub fn entries_mut(&mut self) -> impl Iterator<Item = &mut ConstantPoolEntry>
pub fn entries_mut(&mut self) -> impl Iterator<Item = &mut ConstantPoolEntry>
Iterate over mutable entries in the constant pool in insertion order.
Trait Implementations
sourceimpl Clone for ConstantPool
impl Clone for ConstantPool
sourcefn clone(&self) -> ConstantPool
fn clone(&self) -> ConstantPool
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl RefUnwindSafe for ConstantPool
impl Send for ConstantPool
impl Sync for ConstantPool
impl Unpin for ConstantPool
impl UnwindSafe for ConstantPool
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more