Struct llvm_plugin_inkwell::types::StructType
source · [−]pub struct StructType<'ctx> { /* private fields */ }Expand description
A StructType is the type of a heterogeneous container of types.
Implementations
sourceimpl<'ctx> StructType<'ctx>
impl<'ctx> StructType<'ctx>
sourcepub fn get_field_type_at_index(self, index: u32) -> Option<BasicTypeEnum<'ctx>>
pub fn get_field_type_at_index(self, index: u32) -> Option<BasicTypeEnum<'ctx>>
Gets the type of a field belonging to this StructType.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.struct_type(&[f32_type.into()], false);
assert_eq!(struct_type.get_field_type_at_index(0).unwrap().into_float_type(), f32_type);sourcepub fn const_named_struct(
self,
values: &[BasicValueEnum<'ctx>]
) -> StructValue<'ctx>
pub fn const_named_struct(
self,
values: &[BasicValueEnum<'ctx>]
) -> StructValue<'ctx>
Creates a StructValue based on this StructType’s definition.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let f32_zero = f32_type.const_float(0.);
let struct_type = context.struct_type(&[f32_type.into()], false);
let struct_val = struct_type.const_named_struct(&[f32_zero.into()]);sourcepub fn const_zero(self) -> StructValue<'ctx>
pub fn const_zero(self) -> StructValue<'ctx>
Creates a constant zero value of this StructType.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.struct_type(&[f32_type.into(), f32_type.into()], false);
let struct_zero = struct_type.const_zero();sourcepub fn size_of(self) -> Option<IntValue<'ctx>>
pub fn size_of(self) -> Option<IntValue<'ctx>>
Gets the size of this StructType. Value may vary depending on the target architecture.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let f32_struct_type = context.struct_type(&[f32_type.into()], false);
let f32_struct_type_size = f32_struct_type.size_of();sourcepub fn get_alignment(self) -> IntValue<'ctx>
pub fn get_alignment(self) -> IntValue<'ctx>
Gets the alignment of this StructType. Value may vary depending on the target architecture.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.struct_type(&[f32_type.into(), f32_type.into()], false);
let struct_type_alignment = struct_type.get_alignment();sourcepub fn get_context(self) -> ContextRef<'ctx>
pub fn get_context(self) -> ContextRef<'ctx>
Gets a reference to the Context this StructType was created in.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.struct_type(&[f32_type.into(), f32_type.into()], false);
assert_eq!(*struct_type.get_context(), context);sourcepub fn get_name(&self) -> Option<&CStr>
pub fn get_name(&self) -> Option<&CStr>
Gets this StructType’s name.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.opaque_struct_type("opaque_struct");
assert_eq!(struct_type.get_name().unwrap().to_str().unwrap(), "opaque_struct");sourcepub fn ptr_type(self, address_space: AddressSpace) -> PointerType<'ctx>
pub fn ptr_type(self, address_space: AddressSpace) -> PointerType<'ctx>
Creates a PointerType with this StructType for its element type.
Example
use inkwell::AddressSpace;
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.struct_type(&[f32_type.into(), f32_type.into()], false);
let struct_ptr_type = struct_type.ptr_type(AddressSpace::Generic);
assert_eq!(struct_ptr_type.get_element_type().into_struct_type(), struct_type);sourcepub fn fn_type(
self,
param_types: &[BasicMetadataTypeEnum<'ctx>],
is_var_args: bool
) -> FunctionType<'ctx>
pub fn fn_type(
self,
param_types: &[BasicMetadataTypeEnum<'ctx>],
is_var_args: bool
) -> FunctionType<'ctx>
Creates a FunctionType with this StructType for its return type.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.struct_type(&[f32_type.into(), f32_type.into()], false);
let fn_type = struct_type.fn_type(&[], false);sourcepub fn array_type(self, size: u32) -> ArrayType<'ctx>
pub fn array_type(self, size: u32) -> ArrayType<'ctx>
Creates an ArrayType with this StructType for its element type.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.struct_type(&[f32_type.into(), f32_type.into()], false);
let struct_array_type = struct_type.array_type(3);
assert_eq!(struct_array_type.len(), 3);
assert_eq!(struct_array_type.get_element_type().into_struct_type(), struct_type);sourcepub fn is_packed(self) -> bool
pub fn is_packed(self) -> bool
Determines whether or not a StructType is packed.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.struct_type(&[f32_type.into(), f32_type.into()], false);
assert!(struct_type.is_packed());sourcepub fn is_opaque(self) -> bool
pub fn is_opaque(self) -> bool
Determines whether or not a StructType is opaque.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.opaque_struct_type("opaque_struct");
assert!(struct_type.is_opaque());sourcepub fn count_fields(self) -> u32
pub fn count_fields(self) -> u32
Counts the number of field types.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let i8_type = context.i8_type();
let struct_type = context.struct_type(&[f32_type.into(), i8_type.into()], false);
assert_eq!(struct_type.count_fields(), 2);sourcepub fn get_field_types(self) -> Vec<BasicTypeEnum<'ctx>>
pub fn get_field_types(self) -> Vec<BasicTypeEnum<'ctx>>
Gets this StructType’s field types.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let i8_type = context.i8_type();
let struct_type = context.struct_type(&[f32_type.into(), i8_type.into()], false);
assert_eq!(struct_type.get_field_types(), &[f32_type.into(), i8_type.into()]);sourcepub fn print_to_string(self) -> LLVMString
pub fn print_to_string(self) -> LLVMString
Print the definition of a StructType to LLVMString.
sourcepub fn get_undef(self) -> StructValue<'ctx>
pub fn get_undef(self) -> StructValue<'ctx>
Creates an undefined instance of a StructType.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let i8_type = context.i8_type();
let struct_type = context.struct_type(&[f32_type.into(), i8_type.into()], false);
let struct_type_undef = struct_type.get_undef();
assert!(struct_type_undef.is_undef());sourcepub fn set_body(self, field_types: &[BasicTypeEnum<'ctx>], packed: bool) -> bool
pub fn set_body(self, field_types: &[BasicTypeEnum<'ctx>], packed: bool) -> bool
Defines the body of an opaue StructType.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let opaque_struct_type = context.opaque_struct_type("opaque_struct");
opaque_struct_type.set_body(&[f32_type.into()], false);
assert!(!opaque_struct_type.is_opaque());sourcepub fn const_array(self, values: &[StructValue<'ctx>]) -> ArrayValue<'ctx>
pub fn const_array(self, values: &[StructValue<'ctx>]) -> ArrayValue<'ctx>
Creates a constant ArrayValue.
Example
use inkwell::context::Context;
let context = Context::create();
let f32_type = context.f32_type();
let struct_type = context.struct_type(&[f32_type.into(), f32_type.into()], false);
let struct_val = struct_type.const_named_struct(&[]);
let struct_array = struct_type.const_array(&[struct_val, struct_val]);
assert!(struct_array.is_const());Trait Implementations
sourceimpl<'ctx> AnyType<'ctx> for StructType<'ctx>
impl<'ctx> AnyType<'ctx> for StructType<'ctx>
sourcefn as_any_type_enum(&self) -> AnyTypeEnum<'ctx>
fn as_any_type_enum(&self) -> AnyTypeEnum<'ctx>
Returns an AnyTypeEnum that represents the current type.
sourcefn print_to_string(&self) -> LLVMString
fn print_to_string(&self) -> LLVMString
Prints the definition of a Type to a LLVMString.
sourceimpl<'ctx> BasicType<'ctx> for StructType<'ctx>
impl<'ctx> BasicType<'ctx> for StructType<'ctx>
sourcefn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx>
fn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx>
Returns a BasicTypeEnum that represents the current type.
sourcefn fn_type(
&self,
param_types: &[BasicMetadataTypeEnum<'ctx>],
is_var_args: bool
) -> FunctionType<'ctx>
fn fn_type(
&self,
param_types: &[BasicMetadataTypeEnum<'ctx>],
is_var_args: bool
) -> FunctionType<'ctx>
Create a FunctionType with this BasicType as its return type. Read more
sourcefn is_sized(&self) -> bool
fn is_sized(&self) -> bool
Determines whether or not this BasicType is sized or not.
For example, opaque structs are unsized. Read more
sourcefn size_of(&self) -> Option<IntValue<'ctx>>
fn size_of(&self) -> Option<IntValue<'ctx>>
Gets the size of this BasicType. Value may vary depending on the target architecture. Read more
sourcefn array_type(&self, size: u32) -> ArrayType<'ctx>
fn array_type(&self, size: u32) -> ArrayType<'ctx>
Create an ArrayType with this BasicType as its elements. Read more
sourcefn ptr_type(&self, address_space: AddressSpace) -> PointerType<'ctx>
fn ptr_type(&self, address_space: AddressSpace) -> PointerType<'ctx>
Create a PointerType that points to this BasicType. Read more
sourceimpl<'ctx> Clone for StructType<'ctx>
impl<'ctx> Clone for StructType<'ctx>
sourcefn clone(&self) -> StructType<'ctx>
fn clone(&self) -> StructType<'ctx>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<'ctx> Debug for StructType<'ctx>
impl<'ctx> Debug for StructType<'ctx>
sourceimpl Display for StructType<'_>
impl Display for StructType<'_>
sourceimpl<'ctx> From<StructType<'ctx>> for AnyTypeEnum<'ctx>
impl<'ctx> From<StructType<'ctx>> for AnyTypeEnum<'ctx>
sourcefn from(value: StructType<'_>) -> AnyTypeEnum<'_>
fn from(value: StructType<'_>) -> AnyTypeEnum<'_>
Converts to this type from the input type.
sourceimpl<'ctx> From<StructType<'ctx>> for BasicMetadataTypeEnum<'ctx>
impl<'ctx> From<StructType<'ctx>> for BasicMetadataTypeEnum<'ctx>
sourcefn from(value: StructType<'_>) -> BasicMetadataTypeEnum<'_>
fn from(value: StructType<'_>) -> BasicMetadataTypeEnum<'_>
Converts to this type from the input type.
sourceimpl<'ctx> From<StructType<'ctx>> for BasicTypeEnum<'ctx>
impl<'ctx> From<StructType<'ctx>> for BasicTypeEnum<'ctx>
sourcefn from(value: StructType<'_>) -> BasicTypeEnum<'_>
fn from(value: StructType<'_>) -> BasicTypeEnum<'_>
Converts to this type from the input type.
sourceimpl<'ctx> PartialEq<StructType<'ctx>> for StructType<'ctx>
impl<'ctx> PartialEq<StructType<'ctx>> for StructType<'ctx>
sourcefn eq(&self, other: &StructType<'ctx>) -> bool
fn eq(&self, other: &StructType<'ctx>) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourceimpl<'ctx> TryFrom<AnyTypeEnum<'ctx>> for StructType<'ctx>
impl<'ctx> TryFrom<AnyTypeEnum<'ctx>> for StructType<'ctx>
sourceimpl<'ctx> TryFrom<BasicMetadataTypeEnum<'ctx>> for StructType<'ctx>
impl<'ctx> TryFrom<BasicMetadataTypeEnum<'ctx>> for StructType<'ctx>
sourceimpl<'ctx> TryFrom<BasicTypeEnum<'ctx>> for StructType<'ctx>
impl<'ctx> TryFrom<BasicTypeEnum<'ctx>> for StructType<'ctx>
impl<'ctx> Copy for StructType<'ctx>
impl<'ctx> Eq for StructType<'ctx>
impl<'ctx> StructuralEq for StructType<'ctx>
impl<'ctx> StructuralPartialEq for StructType<'ctx>
Auto Trait Implementations
impl<'ctx> RefUnwindSafe for StructType<'ctx>
impl<'ctx> !Send for StructType<'ctx>
impl<'ctx> !Sync for StructType<'ctx>
impl<'ctx> Unpin for StructType<'ctx>
impl<'ctx> UnwindSafe for StructType<'ctx>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more