Struct Types

Source
pub struct Types { /* private fields */ }
Expand description

Holds a reference to all of the Types used in the Module, and facilitates lookups so you can get a TypeRef to the Type you want.

Implementations§

Source§

impl Types

Source

pub fn type_of<T: Typed + ?Sized>(&self, t: &T) -> TypeRef

Get the type of anything that is Typed

Source

pub fn void(&self) -> TypeRef

Get the void type

Source

pub fn int(&self, bits: u32) -> TypeRef

Get the integer type of the specified size (in bits)

Source

pub fn bool(&self) -> TypeRef

Get the boolean type (i1)

Source

pub fn i8(&self) -> TypeRef

Get the 8-bit integer type

Source

pub fn i16(&self) -> TypeRef

Get the 16-bit integer type

Source

pub fn i32(&self) -> TypeRef

Get the 32-bit integer type

Source

pub fn i64(&self) -> TypeRef

Get the 64-bit integer type

Source

pub fn pointer_to(&self, pointee_type: TypeRef) -> TypeRef

Get a pointer type in the default address space (0)

Source

pub fn pointer_in_addr_space( &self, pointee_type: TypeRef, addr_space: AddrSpace, ) -> TypeRef

Get a pointer type in the specified address space

Source

pub fn fp(&self, fpt: FPType) -> TypeRef

Get a floating-point type

Source

pub fn single(&self) -> TypeRef

Get the single-precision floating-point type

Source

pub fn double(&self) -> TypeRef

Get the double-precision floating-point type

Source

pub fn func_type( &self, result_type: TypeRef, param_types: Vec<TypeRef>, is_var_arg: bool, ) -> TypeRef

Get a function type

Source

pub fn vector_of(&self, element_type: TypeRef, num_elements: usize) -> TypeRef

Source

pub fn array_of(&self, element_type: TypeRef, num_elements: usize) -> TypeRef

Get an array type

Source

pub fn struct_of(&self, element_types: Vec<TypeRef>, is_packed: bool) -> TypeRef

Get a struct type

Source

pub fn named_struct(&self, name: &str) -> TypeRef

Get the TypeRef for the struct with the given name.

Note that this gives a NamedStructType. To get the actual definition of a named struct (the NamedStructDef), use named_struct_def().

Source

pub fn named_struct_def(&self, name: &str) -> Option<&NamedStructDef>

Get the NamedStructDef for the struct with the given name, or None if there is no struct by that name.

Note that this gives a NamedStructDef. To get the NamedStructType for a name, use named_struct().

Source

pub fn all_struct_names(&self) -> impl Iterator<Item = &String>

Get the names of all the named structs

Source

pub fn add_named_struct_def(&mut self, name: String, def: NamedStructDef)

Add the given NamedStructDef as the definition of the struct with the given name.

Panics if that name already had a definition.

Source

pub fn remove_named_struct_def(&mut self, name: &str) -> bool

Remove the definition of the struct with the given name.

Returns true if the definition was removed, or false if no definition existed.

Source

pub fn x86_mmx(&self) -> TypeRef

Get the X86_MMX type

Source

pub fn metadata_type(&self) -> TypeRef

Get the metadata type

Source

pub fn label_type(&self) -> TypeRef

Get the label type

Source

pub fn token_type(&self) -> TypeRef

Get the token type

Source

pub fn get_for_type(&self, ty: &Type) -> TypeRef

Get a TypeRef for the given Type

Source§

impl Types

Source

pub fn blank_for_testing() -> Self

Get a blank Types containing essentially no types. This function is intended only for use in testing; it’s probably not useful otherwise.

Trait Implementations§

Source§

impl Clone for Types

Source§

fn clone(&self) -> Types

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Types

§

impl RefUnwindSafe for Types

§

impl Send for Types

§

impl Sync for Types

§

impl Unpin for Types

§

impl UnwindSafe for Types

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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>,

Source§

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.