Struct inkwell::types::FunctionType[][src]

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

A FunctionType is the type of a function variable.

Implementations

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

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

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

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. 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.