pipeline_script/llvm/value/
int.rs1use crate::context::Context;
2use crate::llvm::value::bool::BoolValue;
3use crate::llvm::value::LLVMValue;
4use llvm_sys::core::LLVMIsUndef;
5use llvm_sys::prelude::LLVMValueRef;
6
7#[derive(Debug, Clone)]
8pub struct Int32Value {
9 reference: LLVMValueRef,
10}
11
12impl Int32Value {
13 pub fn get_reference(&self) -> LLVMValueRef {
14 self.reference
15 }
16 pub fn new(reference: LLVMValueRef) -> Self {
17 Self { reference }
18 }
19 pub fn eq(&self, ctx: &Context, other: &Int32Value) -> BoolValue {
20 let builder = ctx.get_builder();
21 builder.build_eq(self.reference, other.reference)
22 }
23 pub fn is_undef(&self) -> bool {
24 unsafe { LLVMIsUndef(self.reference) == 1 }
25 }
26}
27
28impl From<Int32Value> for LLVMValue {
29 fn from(value: Int32Value) -> Self {
30 LLVMValue::Int32(value)
31 }
32}
33
34#[derive(Clone, Debug)]
37pub struct Int8Value {
38 reference: LLVMValueRef,
39}
40impl Int8Value {
41 pub fn get_reference(&self) -> LLVMValueRef {
42 self.reference
43 }
44 pub fn new(reference: LLVMValueRef) -> Self {
45 Self { reference }
46 }
47 pub fn is_undef(&self) -> bool {
48 unsafe { LLVMIsUndef(self.reference) == 1 }
49 }
50}
51
52impl From<Int8Value> for LLVMValue {
53 fn from(value: Int8Value) -> Self {
54 LLVMValue::Int8(value)
55 }
56}
57
58#[derive(Clone, Debug)]
62pub struct Int16Value {
63 reference: LLVMValueRef,
64}
65
66impl Int16Value {
67 pub fn get_reference(&self) -> LLVMValueRef {
68 self.reference
69 }
70 pub fn new(reference: LLVMValueRef) -> Self {
71 Self { reference }
72 }
73 pub fn is_undef(&self) -> bool {
74 unsafe { LLVMIsUndef(self.reference) == 1 }
75 }
76}
77
78impl From<Int16Value> for LLVMValue {
79 fn from(value: Int16Value) -> Self {
80 LLVMValue::Int16(value)
81 }
82}
83
84#[derive(Clone, Debug)]
88pub struct Int64Value {
89 reference: LLVMValueRef,
90}
91
92impl Int64Value {
93 pub fn get_reference(&self) -> LLVMValueRef {
94 self.reference
95 }
96 pub fn new(reference: LLVMValueRef) -> Self {
97 Self { reference }
98 }
99 pub fn is_undef(&self) -> bool {
100 unsafe { LLVMIsUndef(self.reference) == 1 }
101 }
102}
103
104impl From<Int64Value> for LLVMValue {
105 fn from(value: Int64Value) -> Self {
106 LLVMValue::Int64(value)
107 }
108}