pub struct Value(pub Index);
Tuple Fields§
§0: Index
Implementations§
source§impl Value
impl Value
sourcepub fn new_argument(context: &mut Context<'_>, arg: BlockArgument) -> Value
pub fn new_argument(context: &mut Context<'_>, arg: BlockArgument) -> Value
Return a new argument Value
.
sourcepub fn new_configurable(context: &mut Context<'_>, constant: Constant) -> Value
pub fn new_configurable(context: &mut Context<'_>, constant: Constant) -> Value
Return a new constant Value
.
sourcepub fn new_constant(context: &mut Context<'_>, constant: Constant) -> Value
pub fn new_constant(context: &mut Context<'_>, constant: Constant) -> Value
Return a new constant Value
.
sourcepub fn new_instruction(
context: &mut Context<'_>,
instruction: Instruction
) -> Value
pub fn new_instruction( context: &mut Context<'_>, instruction: Instruction ) -> Value
Return a new instruction Value
.
sourcepub fn add_metadatum(
self,
context: &mut Context<'_>,
md_idx: Option<MetadataIndex>
) -> Self
pub fn add_metadatum( self, context: &mut Context<'_>, md_idx: Option<MetadataIndex> ) -> Self
Add some metadata to this value.
As a convenience the md_idx
argument is an Option
, in which case this function is a
no-op.
If there is no existing metadata then the new metadata are added alone. Otherwise the new metadatum are added to the list of metadata.
sourcepub fn get_metadata(&self, context: &Context<'_>) -> Option<MetadataIndex>
pub fn get_metadata(&self, context: &Context<'_>) -> Option<MetadataIndex>
Return this value’s metadata.
sourcepub fn is_configurable(&self, context: &Context<'_>) -> bool
pub fn is_configurable(&self, context: &Context<'_>) -> bool
Return whether this is a constant value.
sourcepub fn is_constant(&self, context: &Context<'_>) -> bool
pub fn is_constant(&self, context: &Context<'_>) -> bool
Return whether this is a constant value.
sourcepub fn is_terminator(&self, context: &Context<'_>) -> bool
pub fn is_terminator(&self, context: &Context<'_>) -> bool
Return whether this value is an instruction, and specifically a ‘terminator’.
A terminator is always the last instruction in a block (and may not appear anywhere else) and is either a branch or return.
pub fn is_diverging(&self, context: &Context<'_>) -> bool
sourcepub fn replace_instruction_value(
&self,
context: &mut Context<'_>,
old_val: Value,
new_val: Value
)
pub fn replace_instruction_value( &self, context: &mut Context<'_>, old_val: Value, new_val: Value )
If this value is an instruction and if any of its parameters is old_val
then replace them
with new_val
.
pub fn replace_instruction_values( &self, context: &mut Context<'_>, replace_map: &FxHashMap<Value, Value> )
sourcepub fn replace(&self, context: &mut Context<'_>, other: ValueDatum)
pub fn replace(&self, context: &mut Context<'_>, other: ValueDatum)
Replace this value with another one, in-place.
sourcepub fn get_instruction<'a>(
&self,
context: &'a Context<'_>
) -> Option<&'a Instruction>
pub fn get_instruction<'a>( &self, context: &'a Context<'_> ) -> Option<&'a Instruction>
Get a reference to this value as an instruction, iff it is one.
sourcepub fn get_instruction_mut<'a>(
&self,
context: &'a mut Context<'_>
) -> Option<&'a mut Instruction>
pub fn get_instruction_mut<'a>( &self, context: &'a mut Context<'_> ) -> Option<&'a mut Instruction>
Get a mutable reference to this value as an instruction, iff it is one.
sourcepub fn get_configurable<'a>(
&self,
context: &'a Context<'_>
) -> Option<&'a Constant>
pub fn get_configurable<'a>( &self, context: &'a Context<'_> ) -> Option<&'a Constant>
Get a reference to this value as a constant, iff it is one.
sourcepub fn get_constant<'a>(&self, context: &'a Context<'_>) -> Option<&'a Constant>
pub fn get_constant<'a>(&self, context: &'a Context<'_>) -> Option<&'a Constant>
Get a reference to this value as a constant, iff it is one.
sourcepub fn get_argument<'a>(
&self,
context: &'a Context<'_>
) -> Option<&'a BlockArgument>
pub fn get_argument<'a>( &self, context: &'a Context<'_> ) -> Option<&'a BlockArgument>
Get a reference to this value as an argument, iff it is one.
sourcepub fn get_constant_or_configurable<'a>(
&self,
context: &'a Context<'_>
) -> Option<&'a Constant>
pub fn get_constant_or_configurable<'a>( &self, context: &'a Context<'_> ) -> Option<&'a Constant>
Get a reference to this value as a constant or as a configurable, iff it is one of the two.
sourcepub fn get_type(&self, context: &Context<'_>) -> Option<Type>
pub fn get_type(&self, context: &Context<'_>) -> Option<Type>
Get the type for this value, if found.
Arguments and constants always have a type, but only some instructions do.
sourcepub fn match_ptr_type(&self, context: &Context<'_>) -> Option<Type>
pub fn match_ptr_type(&self, context: &Context<'_>) -> Option<Type>
Get the pointer inner type for this value, iff it is a pointer.
Trait Implementations§
source§impl DebugWithContext for Value
impl DebugWithContext for Value
fn fmt_with_context<'a, 'c>( &'a self, formatter: &mut Formatter<'_>, context: &'c Context<'_> ) -> Result
fn with_context<'a, 'c, 'eng>( &'a self, context: &'c Context<'eng> ) -> WithContext<'a, 'c, 'eng, Self>
source§impl PartialEq<Value> for Value
impl PartialEq<Value> for Value
impl Copy for Value
impl Eq for Value
impl StructuralEq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.