Struct cranelift_wasm::wasmparser::RefType

source ·
pub struct RefType(/* private fields */);
Expand description

A reference type.

The reference types proposal first introduced externref and funcref.

The function references proposal introduced typed function references.

The GC proposal introduces heap types: any, eq, i31, struct, array, nofunc, noextern, none.

Implementations§

source§

impl RefType

source

pub const FUNCREF: RefType = _

A nullable untyped function reference aka (ref null func) aka funcref aka anyfunc.

source

pub const EXTERNREF: RefType = _

A nullable reference to an extern object aka (ref null extern) aka externref.

source

pub const ANYREF: RefType = _

A nullable reference to any object aka (ref null any) aka anyref.

source

pub const NULLREF: RefType = _

A nullable reference to no object aka (ref null none) aka nullref.

source

pub const NULLEXTERNREF: RefType = _

A nullable reference to a noextern object aka (ref null noextern) aka nullexternref.

source

pub const NULLFUNCREF: RefType = _

A nullable reference to a nofunc object aka (ref null nofunc) aka nullfuncref.

source

pub const EQREF: RefType = _

A nullable reference to an eq object aka (ref null eq) aka eqref.

source

pub const STRUCTREF: RefType = _

A nullable reference to a struct aka (ref null struct) aka structref.

source

pub const ARRAYREF: RefType = _

A nullable reference to an array aka (ref null array) aka arrayref.

source

pub const I31REF: RefType = _

A nullable reference to an i31 object aka (ref null i31) aka i31ref.

source

pub const EXNREF: RefType = _

A nullable reference to an exception object aka (ref null exn) aka exnref.

source

pub const FUNC: RefType = _

A non-nullable untyped function reference aka (ref func).

source

pub const EXTERN: RefType = _

A non-nullable reference to an extern object aka (ref extern).

source

pub const ANY: RefType = _

A non-nullable reference to any object aka (ref any).

source

pub const NONE: RefType = _

A non-nullable reference to no object aka (ref none).

source

pub const NOEXTERN: RefType = _

A non-nullable reference to a noextern object aka (ref noextern).

source

pub const NOFUNC: RefType = _

A non-nullable reference to a nofunc object aka (ref nofunc).

source

pub const EQ: RefType = _

A non-nullable reference to an eq object aka (ref eq).

source

pub const STRUCT: RefType = _

A non-nullable reference to a struct aka (ref struct).

source

pub const ARRAY: RefType = _

A non-nullable reference to an array aka (ref array).

source

pub const I31: RefType = _

A non-nullable reference to an i31 object aka (ref i31).

source

pub const EXN: RefType = _

A non-nullable reference to an exn object aka (ref exn).

source

pub fn concrete(nullable: bool, index: PackedIndex) -> RefType

Create a reference to a concrete Wasm-defined type at the given index.

Returns None when the type index is beyond this crate’s implementation limits and therefore is not representable.

source

pub fn new(nullable: bool, heap_type: HeapType) -> Option<RefType>

Create a new RefType.

Returns None when the heap type’s type index (if any) is beyond this crate’s implementation limits and therfore is not representable.

source

pub fn difference(a: RefType, b: RefType) -> RefType

Compute the type difference between the two given ref types.

source

pub const fn is_concrete_type_ref(&self) -> bool

Is this a reference to an concrete type?

source

pub fn type_index(&self) -> Option<PackedIndex>

If this is a reference to a concrete Wasm-defined type, get its type index.

source

pub const fn is_func_ref(&self) -> bool

Is this the abstract untyped function reference type aka (ref null func) aka funcref aka anyfunc?

source

pub const fn is_extern_ref(&self) -> bool

Is this the abstract external reference type aka (ref null extern) aka externref?

source

pub const fn is_array_ref(&self) -> bool

Is this the abstract untyped array refrence type aka (ref null array) aka arrayref?

source

pub const fn is_struct_ref(&self) -> bool

Is this the abstract untyped struct reference type aka (ref null struct) aka structref?

source

pub const fn is_nullable(&self) -> bool

Is this ref type nullable?

source

pub const fn as_non_null(&self) -> RefType

Get the non-nullable version of this ref type.

source

pub const fn nullable(&self) -> RefType

Get the nullable version of this ref type.

source

pub fn heap_type(&self) -> HeapType

Get the heap type that this is a reference to.

Trait Implementations§

source§

impl Clone for RefType

source§

fn clone(&self) -> RefType

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 RefType

source§

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

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

impl Display for RefType

source§

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

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

impl From<RefType> for ValType

source§

fn from(ty: RefType) -> ValType

Converts to this type from the input type.
source§

impl<'a> FromReader<'a> for RefType

source§

fn from_reader( reader: &mut BinaryReader<'a> ) -> Result<RefType, BinaryReaderError>

Attempts to read Self from the provided binary reader, returning an error if it is unable to do so.
source§

impl Hash for RefType

source§

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

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

source§

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

source§

impl Eq for RefType

source§

impl StructuralPartialEq for RefType

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

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

source§

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

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

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

source§

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

Compare self to key and return true if they are equal.
source§

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

source§

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

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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> ToOwned for T
where 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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.