Trait inkwell::types::BasicType[][src]

pub trait BasicType<'ctx>: AnyType<'ctx> {
    fn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx> { ... }
fn fn_type(
        &self,
        param_types: &[BasicTypeEnum<'ctx>],
        is_var_args: bool
    ) -> FunctionType<'ctx> { ... }
fn is_sized(&self) -> bool { ... }
fn size_of(&self) -> Option<IntValue<'ctx>> { ... }
fn array_type(&self, size: u32) -> ArrayType<'ctx> { ... }
fn ptr_type(&self, address_space: AddressSpace) -> PointerType<'ctx> { ... } }
Expand description

Represents a basic LLVM type, that may be used in functions and struct definitions.

Provided methods

Returns a BasicTypeEnum that represents the current type.

Create a FunctionType with this BasicType as its return type.

Example:

use inkwell::context::Context;
use inkwell::types::BasicType;

let context = Context::create();
let int = context.i32_type();
let int_basic_type = int.as_basic_type_enum();
assert_eq!(int_basic_type.fn_type(&[], false), int.fn_type(&[], false));

Determines whether or not this BasicType is sized or not. For example, opaque structs are unsized.

Example

use inkwell::context::Context;
use inkwell::types::BasicType;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(40);

assert!(f32_vec_type.is_sized());

Gets the size of this BasicType. Value may vary depending on the target architecture.

Example

use inkwell::context::Context;
use inkwell::types::BasicType;

let context = Context::create();
let f32_type = context.f32_type();
let f32_basic_type = f32_type.as_basic_type_enum();
let f32_type_size = f32_basic_type.size_of();

Create an ArrayType with this BasicType as its elements.

Example:

use inkwell::context::Context;
use inkwell::types::BasicType;

let context = Context::create();
let int = context.i32_type();
let int_basic_type = int.as_basic_type_enum();
assert_eq!(int_basic_type.array_type(32), int.array_type(32));

Create a PointerType that points to this BasicType.

Example:

use inkwell::context::Context;
use inkwell::types::BasicType;
use inkwell::AddressSpace;

let context = Context::create();
let int = context.i32_type();
let int_basic_type = int.as_basic_type_enum();
let addr_space = AddressSpace::Generic;
assert_eq!(int_basic_type.ptr_type(addr_space), int.ptr_type(addr_space));

Implementors