Struct sway_ir::irtype::Type

source ·
pub struct Type(pub Index);

Tuple Fields§

§0: Index

Implementations§

source§

impl Type

source

pub fn get_type(context: &Context, t: &TypeContent) -> Option<Type>

Get Type if it already exists.

source

pub fn create_basic_types(context: &mut Context)

source

pub fn get_content<'a>(&self, context: &'a Context) -> &'a TypeContent

Get the content for this Type.

source

pub fn get_unit(context: &Context) -> Type

Get unit type

source

pub fn get_bool(context: &Context) -> Type

Get bool type

source

pub fn new_uint(context: &mut Context, width: u8) -> Type

New unsigned integer type

source

pub fn get_uint8(context: &Context) -> Type

New u8 type

source

pub fn get_uint32(context: &Context) -> Type

New u32 type

source

pub fn get_uint64(context: &Context) -> Type

New u64 type

source

pub fn get_uint(context: &Context, width: u8) -> Option<Type>

Get unsigned integer type

source

pub fn get_b256(context: &Context) -> Type

Get B256 type

source

pub fn new_string(context: &mut Context, len: u64) -> Type

Get string type

source

pub fn new_array(context: &mut Context, elm_ty: Type, len: u64) -> Type

Get array type

source

pub fn new_union(context: &mut Context, fields: Vec<Type>) -> Type

Get union type

source

pub fn new_struct(context: &mut Context, fields: Vec<Type>) -> Type

Get struct type

source

pub fn new_ptr(context: &mut Context, to_ty: Type) -> Type

New pointer type

source

pub fn get_slice(context: &mut Context) -> Type

Get slice type

source

pub fn as_string(&self, context: &Context) -> String

Return a string representation of type, used for printing.

source

pub fn eq(&self, context: &Context, other: &Type) -> bool

Compare a type to this one for equivalence. PartialEq does not take into account the special case for Unions below.

source

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

Is bool type

source

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

Is unit type

source

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

Is unsigned integer type

source

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

Is u8 type

source

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

Is u32 type

source

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

Is u64 type

source

pub fn is_uint_of(&self, context: &Context, width: u8) -> bool

Is unsigned integer type of specific width

source

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

Is B256 type

source

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

Is string type

source

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

Is array type

source

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

Is union type

source

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

Is struct type

source

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

Is aggregate type: struct, union or array.

source

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

Returns true if this is a slice type.

source

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

Returns true if this is a pointer type.

source

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

Get pointed to type iff self is a Pointer.

source

pub fn get_uint_width(&self, context: &Context) -> Option<u8>

Get width of an integer type.

source

pub fn get_indexed_type( &self, context: &Context, indices: &[u64] ) -> Option<Type>

What’s the type of the struct value indexed by indices.

source

pub fn get_field_type(&self, context: &Context, idx: u64) -> Option<Type>

source

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

Get the type of the array element, if applicable.

source

pub fn get_array_len(&self, context: &Context) -> Option<u64>

Get the length of the array , if applicable.

source

pub fn get_string_len(&self, context: &Context) -> Option<u64>

Get the length of a string

source

pub fn get_field_types(&self, context: &Context) -> Vec<Type>

Get the type of each field of a struct Type. Empty vector otherwise.

Trait Implementations§

source§

impl Clone for Type

source§

fn clone(&self) -> Type

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 Type

source§

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

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

impl DebugWithContext for Type

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 Type

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<Type> for Type

source§

fn eq(&self, other: &Type) -> 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 Type

source§

impl Eq for Type

source§

impl StructuralEq for Type

source§

impl StructuralPartialEq for Type

Auto Trait Implementations§

§

impl RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl UnwindSafe for Type

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