Struct inkwell::types::FunctionType
source · pub struct FunctionType<'ctx> { /* private fields */ }
Expand description
A FunctionType
is the type of a function variable.
Implementations§
source§impl<'ctx> FunctionType<'ctx>
impl<'ctx> FunctionType<'ctx>
sourcepub unsafe fn new(fn_type: LLVMTypeRef) -> Self
pub unsafe fn new(fn_type: LLVMTypeRef) -> Self
Create FunctionType
from LLVMTypeRef
§Safety
Undefined behavior, if referenced type isn’t function type
sourcepub fn ptr_type(self, address_space: AddressSpace) -> PointerType<'ctx>
pub fn ptr_type(self, address_space: AddressSpace) -> PointerType<'ctx>
Creates a PointerType
with this FunctionType
for its element type.
§Example
use inkwell::context::Context;
use inkwell::AddressSpace;
let context = Context::create();
let f32_type = context.f32_type();
let fn_type = f32_type.fn_type(&[], false);
let fn_ptr_type = fn_type.ptr_type(AddressSpace::default());
#[cfg(any(
feature = "llvm4-0",
feature = "llvm5-0",
feature = "llvm6-0",
feature = "llvm7-0",
feature = "llvm8-0",
feature = "llvm9-0",
feature = "llvm10-0",
feature = "llvm11-0",
feature = "llvm12-0",
feature = "llvm13-0",
feature = "llvm14-0"
))]
assert_eq!(fn_ptr_type.get_element_type().into_function_type(), fn_type);
sourcepub fn is_var_arg(self) -> bool
pub fn is_var_arg(self) -> bool
Determines whether or not a FunctionType
is a variadic function.
§Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let fn_type = f32_type.fn_type(&[], true);
assert!(fn_type.is_var_arg());
sourcepub fn get_param_types(self) -> Vec<BasicTypeEnum<'ctx>>
pub fn get_param_types(self) -> Vec<BasicTypeEnum<'ctx>>
Gets param types this FunctionType
has.
§Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let fn_type = f32_type.fn_type(&[f32_type.into()], true);
let param_types = fn_type.get_param_types();
assert_eq!(param_types.len(), 1);
assert_eq!(param_types[0].into_float_type(), f32_type);
sourcepub fn count_param_types(self) -> u32
pub fn count_param_types(self) -> u32
Counts the number of param types this FunctionType
has.
§Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let fn_type = f32_type.fn_type(&[f32_type.into()], true);
assert_eq!(fn_type.count_param_types(), 1);
sourcepub fn is_sized(self) -> bool
pub fn is_sized(self) -> bool
Gets whether or not this FunctionType
is sized or not. This is likely
always false and may be removed in the future.
§Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let fn_type = f32_type.fn_type(&[], true);
assert!(!fn_type.is_sized());
sourcepub fn get_context(self) -> ContextRef<'ctx>
pub fn get_context(self) -> ContextRef<'ctx>
Gets a reference to the Context
this FunctionType
was created in.
§Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let fn_type = f32_type.fn_type(&[], true);
assert_eq!(fn_type.get_context(), context);
sourcepub fn print_to_string(self) -> LLVMString
pub fn print_to_string(self) -> LLVMString
Print the definition of a FunctionType
to LLVMString
.
sourcepub fn get_return_type(self) -> Option<BasicTypeEnum<'ctx>>
pub fn get_return_type(self) -> Option<BasicTypeEnum<'ctx>>
Gets the return type of this FunctionType
.
§Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let fn_type = f32_type.fn_type(&[], true);
assert_eq!(fn_type.get_return_type().unwrap().into_float_type(), f32_type);
Trait Implementations§
source§impl<'ctx> AnyType<'ctx> for FunctionType<'ctx>
impl<'ctx> AnyType<'ctx> for FunctionType<'ctx>
source§fn as_any_type_enum(&self) -> AnyTypeEnum<'ctx>
fn as_any_type_enum(&self) -> AnyTypeEnum<'ctx>
Returns an
AnyTypeEnum
that represents the current type.source§fn print_to_string(&self) -> LLVMString
fn print_to_string(&self) -> LLVMString
Prints the definition of a Type to a
LLVMString
.source§impl AsTypeRef for FunctionType<'_>
impl AsTypeRef for FunctionType<'_>
source§fn as_type_ref(&self) -> LLVMTypeRef
fn as_type_ref(&self) -> LLVMTypeRef
Returns the internal LLVM reference behind the type
source§impl<'ctx> Clone for FunctionType<'ctx>
impl<'ctx> Clone for FunctionType<'ctx>
source§fn clone(&self) -> FunctionType<'ctx>
fn clone(&self) -> FunctionType<'ctx>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FunctionType<'_>
impl Debug for FunctionType<'_>
source§impl Display for FunctionType<'_>
impl Display for FunctionType<'_>
source§impl<'ctx> From<FunctionType<'ctx>> for AnyTypeEnum<'ctx>
impl<'ctx> From<FunctionType<'ctx>> for AnyTypeEnum<'ctx>
source§fn from(value: FunctionType<'_>) -> AnyTypeEnum<'_>
fn from(value: FunctionType<'_>) -> AnyTypeEnum<'_>
Converts to this type from the input type.
source§impl<'ctx> PartialEq for FunctionType<'ctx>
impl<'ctx> PartialEq for FunctionType<'ctx>
source§fn eq(&self, other: &FunctionType<'ctx>) -> bool
fn eq(&self, other: &FunctionType<'ctx>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<'ctx> TryFrom<AnyTypeEnum<'ctx>> for FunctionType<'ctx>
impl<'ctx> TryFrom<AnyTypeEnum<'ctx>> for FunctionType<'ctx>
impl<'ctx> Copy for FunctionType<'ctx>
impl<'ctx> Eq for FunctionType<'ctx>
impl<'ctx> StructuralPartialEq for FunctionType<'ctx>
Auto Trait Implementations§
impl<'ctx> RefUnwindSafe for FunctionType<'ctx>
impl<'ctx> !Send for FunctionType<'ctx>
impl<'ctx> !Sync for FunctionType<'ctx>
impl<'ctx> Unpin for FunctionType<'ctx>
impl<'ctx> UnwindSafe for FunctionType<'ctx>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more