pub struct ArrayValue<'ctx> { /* private fields */ }Expand description
An ArrayValue is a block of contiguous constants or variables.
Implementations§
Source§impl<'ctx> ArrayValue<'ctx>
impl<'ctx> ArrayValue<'ctx>
Sourcepub unsafe fn new(value: LLVMValueRef) -> Self
pub unsafe fn new(value: LLVMValueRef) -> Self
Sourcepub unsafe fn new_const_array<T: AsTypeRef, V: AsValueRef>(
ty: &T,
values: &[V],
) -> Self
pub unsafe fn new_const_array<T: AsTypeRef, V: AsValueRef>( ty: &T, values: &[V], ) -> Self
Creates a new constant ArrayValue with the given type and values.
§Safety
values must be of the same type as ty.
Sourcepub unsafe fn new_raw_const_array(
ty: LLVMTypeRef,
values: &[LLVMValueRef],
) -> Self
pub unsafe fn new_raw_const_array( ty: LLVMTypeRef, values: &[LLVMValueRef], ) -> Self
Creates a new constant ArrayValue with the given type and values.
§Safety
values must be of the same type as ty.
Sourcepub fn get_name(&self) -> &CStr
pub fn get_name(&self) -> &CStr
Get name of the ArrayValue. If the value is a constant, this will
return an empty string.
Sourcepub fn print_to_stderr(self)
pub fn print_to_stderr(self)
Prints this ArrayValue to standard error.
Sourcepub fn as_instruction(self) -> Option<InstructionValue<'ctx>>
pub fn as_instruction(self) -> Option<InstructionValue<'ctx>>
Attempt to convert this ArrayValue to an InstructionValue, if possible.
Sourcepub fn replace_all_uses_with(self, other: ArrayValue<'ctx>)
pub fn replace_all_uses_with(self, other: ArrayValue<'ctx>)
Replaces all uses of this value with another value of the same type. If used incorrectly this may result in invalid IR.
Sourcepub fn is_const(self) -> bool
pub fn is_const(self) -> bool
Determines whether or not an ArrayValue is a constant.
§Example
use inkwell::context::Context;
let context = Context::create();
let i64_type = context.i64_type();
let i64_val = i64_type.const_int(23, false);
let array_val = i64_type.const_array(&[i64_val]);
assert!(array_val.is_const());Sourcepub fn is_const_string(self) -> bool
pub fn is_const_string(self) -> bool
Determines whether or not an ArrayValue represents a constant array of i8s.
§Example
use inkwell::context::Context;
let context = Context::create();
let string = context.const_string(b"my_string", false);
assert!(string.is_const_string());Sourcepub fn as_const_string(&self) -> Option<&[u8]>
pub fn as_const_string(&self) -> Option<&[u8]>
Obtain the string from the ArrayValue if the value points to a constant string.
§Example
use inkwell::context::Context;
use std::ffi::CStr;
let context = Context::create();
let string = context.const_string(b"hello!", false);
let result = b"hello!".as_slice();
assert_eq!(string.as_const_string(), Some(result));Sourcepub fn get_string_constant(&self) -> Option<&CStr>
👎Deprecated: llvm strings can contain internal NULs, and this function truncates such values, use as_const_string instead
pub fn get_string_constant(&self) -> Option<&CStr>
llvm strings can contain internal NULs, and this function truncates such values, use as_const_string instead
Obtain the string from the ArrayValue if the value points to a constant string.
§Example
use inkwell::context::Context;
use std::ffi::CStr;
let context = Context::create();
let string = context.const_string(b"hello!", true);
let result = CStr::from_bytes_with_nul(b"hello!\0").unwrap();
assert_eq!(string.get_string_constant(), Some(result));Trait Implementations§
Source§impl<'ctx> AggregateValue<'ctx> for ArrayValue<'ctx>
impl<'ctx> AggregateValue<'ctx> for ArrayValue<'ctx>
Source§fn as_aggregate_value_enum(&self) -> AggregateValueEnum<'ctx>
fn as_aggregate_value_enum(&self) -> AggregateValueEnum<'ctx>
AggregateValue.Source§impl<'ctx> AnyValue<'ctx> for ArrayValue<'ctx>
impl<'ctx> AnyValue<'ctx> for ArrayValue<'ctx>
Source§fn as_any_value_enum(&self) -> AnyValueEnum<'ctx>
fn as_any_value_enum(&self) -> AnyValueEnum<'ctx>
AnyValue.Source§fn print_to_string(&self) -> LLVMString
fn print_to_string(&self) -> LLVMString
LLVMStringSource§impl AsValueRef for ArrayValue<'_>
impl AsValueRef for ArrayValue<'_>
fn as_value_ref(&self) -> LLVMValueRef
Source§impl<'ctx> BasicValue<'ctx> for ArrayValue<'ctx>
impl<'ctx> BasicValue<'ctx> for ArrayValue<'ctx>
Source§fn as_basic_value_enum(&self) -> BasicValueEnum<'ctx>
fn as_basic_value_enum(&self) -> BasicValueEnum<'ctx>
BasicValue.Source§fn as_instruction_value(&self) -> Option<InstructionValue<'ctx>>
fn as_instruction_value(&self) -> Option<InstructionValue<'ctx>>
BasicValues are the byproduct of an instruction
and so are convertible into an InstructionValuefn get_first_use(&self) -> Option<BasicValueUse<'ctx>>
Source§impl<'ctx> Clone for ArrayValue<'ctx>
impl<'ctx> Clone for ArrayValue<'ctx>
Source§fn clone(&self) -> ArrayValue<'ctx>
fn clone(&self) -> ArrayValue<'ctx>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ArrayValue<'_>
impl Debug for ArrayValue<'_>
Source§impl Display for ArrayValue<'_>
impl Display for ArrayValue<'_>
Source§impl<'ctx> From<ArrayValue<'ctx>> for AggregateValueEnum<'ctx>
impl<'ctx> From<ArrayValue<'ctx>> for AggregateValueEnum<'ctx>
Source§fn from(value: ArrayValue<'_>) -> AggregateValueEnum<'_>
fn from(value: ArrayValue<'_>) -> AggregateValueEnum<'_>
Source§impl<'ctx> From<ArrayValue<'ctx>> for AnyValueEnum<'ctx>
impl<'ctx> From<ArrayValue<'ctx>> for AnyValueEnum<'ctx>
Source§fn from(value: ArrayValue<'_>) -> AnyValueEnum<'_>
fn from(value: ArrayValue<'_>) -> AnyValueEnum<'_>
Source§impl<'ctx> From<ArrayValue<'ctx>> for BasicMetadataValueEnum<'ctx>
impl<'ctx> From<ArrayValue<'ctx>> for BasicMetadataValueEnum<'ctx>
Source§fn from(value: ArrayValue<'_>) -> BasicMetadataValueEnum<'_>
fn from(value: ArrayValue<'_>) -> BasicMetadataValueEnum<'_>
Source§impl<'ctx> From<ArrayValue<'ctx>> for BasicValueEnum<'ctx>
impl<'ctx> From<ArrayValue<'ctx>> for BasicValueEnum<'ctx>
Source§fn from(value: ArrayValue<'_>) -> BasicValueEnum<'_>
fn from(value: ArrayValue<'_>) -> BasicValueEnum<'_>
Source§impl<'ctx> Hash for ArrayValue<'ctx>
impl<'ctx> Hash for ArrayValue<'ctx>
Source§impl<'ctx> PartialEq<AggregateValueEnum<'ctx>> for ArrayValue<'ctx>
impl<'ctx> PartialEq<AggregateValueEnum<'ctx>> for ArrayValue<'ctx>
Source§impl<'ctx> PartialEq<AnyValueEnum<'ctx>> for ArrayValue<'ctx>
impl<'ctx> PartialEq<AnyValueEnum<'ctx>> for ArrayValue<'ctx>
Source§impl<'ctx> PartialEq<ArrayValue<'ctx>> for AggregateValueEnum<'ctx>
impl<'ctx> PartialEq<ArrayValue<'ctx>> for AggregateValueEnum<'ctx>
Source§impl<'ctx> PartialEq<ArrayValue<'ctx>> for AnyValueEnum<'ctx>
impl<'ctx> PartialEq<ArrayValue<'ctx>> for AnyValueEnum<'ctx>
Source§impl<'ctx> PartialEq<ArrayValue<'ctx>> for BasicMetadataValueEnum<'ctx>
impl<'ctx> PartialEq<ArrayValue<'ctx>> for BasicMetadataValueEnum<'ctx>
Source§impl<'ctx> PartialEq<ArrayValue<'ctx>> for BasicValueEnum<'ctx>
impl<'ctx> PartialEq<ArrayValue<'ctx>> for BasicValueEnum<'ctx>
Source§impl<'ctx> PartialEq<BasicMetadataValueEnum<'ctx>> for ArrayValue<'ctx>
impl<'ctx> PartialEq<BasicMetadataValueEnum<'ctx>> for ArrayValue<'ctx>
Source§fn eq(&self, other: &BasicMetadataValueEnum<'ctx>) -> bool
fn eq(&self, other: &BasicMetadataValueEnum<'ctx>) -> bool
self and other values to be equal, and is used by ==.