Type

Struct Type 

Source
pub struct Type<'a>(/* private fields */);
Expand description

LLVMType wrapper

Implementations§

Source§

impl<'a> Type<'a>

Source

pub fn from_inner(ptr: *mut LLVMType) -> Result<Type<'a>, Error>

Wrap an LLVMType pointer

Source

pub fn of<T: LLVMType<'a>>(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Allows for conversion between Rust/LLVM types

Source

pub fn by_name( ctx: &'a Context<'_>, name: impl AsRef<str>, ) -> Result<Type<'a>, Error>

Get type by name

Source

pub fn int_width(self) -> usize

Get width of integer type

Source

pub fn context(self) -> Result<Context<'a>, Error>

Get associated context

Source

pub fn int(ctx: &Context<'a>, bits: usize) -> Result<Type<'a>, Error>

Create int type

Source

pub fn i64(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create i64 type

Source

pub fn i32(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create i32 type

Source

pub fn i16(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create i16 type

Source

pub fn i8(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create i8 type

Source

pub fn i1(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create i1 type

Source

pub fn is(self, kind: TypeKind) -> bool

Returns true if the types kind matches kind

Source

pub fn void(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create void type

Source

pub fn label(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create label type

Source

pub fn token(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create token type

Source

pub fn metadata(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create metadata type

Source

pub fn x86_mmx(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create x86MMX type

Source

pub fn half(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create half/float16 type

Source

pub fn float(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create float type

Source

pub fn double(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create double type

Source

pub fn fp128(ctx: &Context<'a>) -> Result<Type<'a>, Error>

Create FP128 type

Source

pub fn element_type(self) -> Result<Type<'a>, Error>

Get type of element

Source

pub fn to_func_type(self) -> Result<FuncType<'a>, Error>

Convert to function type

Source

pub fn to_struct_type(self) -> Result<StructType<'a>, Error>

Convert to struct type

Source

pub fn pointer(self, address_space: Option<usize>) -> Result<Type<'a>, Error>

Make pointer type

Source

pub fn vector(self, count: usize) -> Result<Type<'a>, Error>

Make vector type

Source

pub fn array(self, count: usize) -> Result<Type<'a>, Error>

Make array type

Source

pub fn kind(self) -> TypeKind

Get type kind

Source

pub fn is_sized(self) -> bool

Returns true if a type is sized

Source

pub fn array_len(self) -> usize

Get array length

Source

pub fn vector_len(self) -> usize

Get vector length

Source

pub fn pointer_address_space(self) -> usize

Get pointer address space

Source

pub fn align_of(self) -> Result<Value<'a>, Error>

Get alignment of type

Source

pub fn size_of(self) -> Result<Value<'a>, Error>

Get size of type

Trait Implementations§

Source§

impl<'a> AsRef<Type<'a>> for FuncType<'a>

Source§

fn as_ref(&self) -> &Type<'a>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> AsRef<Type<'a>> for StructType<'a>

Source§

fn as_ref(&self) -> &Type<'a>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> AsRef<Type<'a>> for Type<'a>

Source§

fn as_ref(&self) -> &Type<'a>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> Clone for Type<'a>

Source§

fn clone(&self) -> Type<'a>

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
Source§

impl<'a> Display for Type<'a>

Source§

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

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

impl<'a> From<FuncType<'a>> for Type<'a>

Source§

fn from(x: FuncType<'a>) -> Type<'a>

Converts to this type from the input type.
Source§

impl<'a> From<StructType<'a>> for Type<'a>

Source§

fn from(x: StructType<'a>) -> Type<'a>

Converts to this type from the input type.
Source§

impl<'a> LLVM<LLVMType> for Type<'a>

Source§

fn llvm(&self) -> *mut LLVMType

Return a LLVM pointer
Source§

impl<'a> Copy for Type<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Type<'a>

§

impl<'a> RefUnwindSafe for Type<'a>

§

impl<'a> !Send for Type<'a>

§

impl<'a> !Sync for Type<'a>

§

impl<'a> Unpin for Type<'a>

§

impl<'a> UnwindSafe for Type<'a>

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

Source§

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

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.