pub struct FunctionType<'ctx> { /* private fields */ }
Expand description

A FunctionType is the type of a function variable.

Implementations§

Create FunctionType from LLVMTypeRef

Safety

Undefined behavior, if referenced type isn’t function type

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(not(feature = "llvm15-0"))]
assert_eq!(fn_ptr_type.get_element_type().into_function_type(), fn_type);

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());

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);

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);

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());

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);

Print the definition of a FunctionType to LLVMString.

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§

Returns an AnyTypeEnum that represents the current type.
Prints the definition of a Type to a LLVMString.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.