Struct sway_ir::value::Value

source ·
pub struct Value(pub Index);
Expand description

A wrapper around an ECS handle into the Context.

Tuple Fields§

§0: Index

Implementations§

source§

impl Value

source

pub fn new_argument(context: &mut Context, arg: BlockArgument) -> Value

Return a new argument Value.

source

pub fn new_configurable(context: &mut Context, constant: Constant) -> Value

Return a new constant Value.

source

pub fn new_constant(context: &mut Context, constant: Constant) -> Value

Return a new constant Value.

source

pub fn new_instruction(context: &mut Context, instruction: Instruction) -> Value

Return a new instruction Value.

source

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.

source

pub fn get_metadata(&self, context: &Context) -> Option<MetadataIndex>

Return this value’s metadata.

source

pub fn is_configurable(&self, context: &Context) -> bool

Return whether this is a constant value.

source

pub fn is_constant(&self, context: &Context) -> bool

Return whether this is a constant value.

source

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.

source

pub fn is_diverging(&self, context: &Context) -> bool

source

pub fn replace_instruction_values(
&self,
context: &mut Context,
replace_map: &FxHashMap<Value, Value>
)

If this value is an instruction and if any of its parameters is old_val then replace them with new_val.

source

pub fn replace(&self, context: &mut Context, other: ValueDatum)

Replace this value with another one, in-place.

source

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.

source

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.

source

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.

source

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.

source

pub fn get_argument_type_and_byref(
&self,
context: &Context
) -> Option<(Type, bool)>

Iff this value is an argument, return its type.

source

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.

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Value

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl DebugWithContext for Value

source§

fn fmt_with_context<'a, 'c>(
&'a self,
formatter: &mut Formatter<'_>,
context: &'c Context
) -> Result

source§

fn with_context<'a, 'c>(
&'a self,
context: &'c Context
) -> WithContext<'a, 'c, Self>

source§

impl Hash for Value

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where
H: Hasher,
Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Value> for Value

source§

fn eq(&self, other: &Value) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Value

source§

impl Eq for Value

source§

impl StructuralEq for Value

source§

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> Any for Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for Twhere
T: Any,

source§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert 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>) -> Rc<dyn Any + 'static>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for Twhere
T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync + 'static>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<T> StorageAsMut for T

§

fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,

§

fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,

§

impl<T> StorageAsRef for T

§

fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,

§

fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,

source§

impl<T> ToOwned for Twhere
T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,

§

fn vzip(self) -> V