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>
👎Deprecated: Starting from version 15.0, LLVM doesn’t differentiate between pointer types. Use Context::ptr_type instead.
pub fn ptr_type(self, address_space: AddressSpace) -> PointerType<'ctx>
Starting from version 15.0, LLVM doesn’t differentiate between pointer types. Use Context::ptr_type instead.
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(feature = "typed-pointers")]
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<BasicMetadataTypeEnum<'ctx>>
pub fn get_param_types(self) -> Vec<BasicMetadataTypeEnum<'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>
AnyTypeEnum that represents the current type.Source§fn print_to_string(&self) -> LLVMString
fn print_to_string(&self) -> LLVMString
LLVMString.Source§impl AsTypeRef for FunctionType<'_>
impl AsTypeRef for FunctionType<'_>
Source§fn as_type_ref(&self) -> LLVMTypeRef
fn as_type_ref(&self) -> LLVMTypeRef
Source§impl<'ctx> Clone for FunctionType<'ctx>
impl<'ctx> Clone for FunctionType<'ctx>
Source§fn clone(&self) -> FunctionType<'ctx>
fn clone(&self) -> FunctionType<'ctx>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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<'_>
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
self and other values to be equal, and is used by ==.