Trait inkwell::types::BasicType

source ·
pub unsafe trait BasicType<'ctx>: AnyType<'ctx> {
    // Provided methods
    fn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx> { ... }
    fn fn_type(
        &self,
        param_types: &[BasicMetadataTypeEnum<'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§

source

fn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx>

Returns a BasicTypeEnum that represents the current type.

source

fn fn_type( &self, param_types: &[BasicMetadataTypeEnum<'ctx>], is_var_args: bool, ) -> FunctionType<'ctx>

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

fn is_sized(&self) -> bool

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

fn size_of(&self) -> Option<IntValue<'ctx>>

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

fn array_type(&self, size: u32) -> ArrayType<'ctx>

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

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.

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::default();
assert_eq!(int_basic_type.ptr_type(addr_space), int.ptr_type(addr_space));

Implementors§

source§

impl<'ctx> BasicType<'ctx> for BasicTypeEnum<'ctx>

source§

impl<'ctx> BasicType<'ctx> for ArrayType<'ctx>

source§

impl<'ctx> BasicType<'ctx> for FloatType<'ctx>

source§

impl<'ctx> BasicType<'ctx> for IntType<'ctx>

source§

impl<'ctx> BasicType<'ctx> for PointerType<'ctx>

source§

impl<'ctx> BasicType<'ctx> for StructType<'ctx>

source§

impl<'ctx> BasicType<'ctx> for VectorType<'ctx>