@@ -9,6 +9,7 @@ use crate::types::ArrayType;
9
9
use crate :: values:: traits:: AsValueRef ;
10
10
use crate :: values:: { Value , InstructionValue , MetadataValue } ;
11
11
12
+ /// An `ArrayValue` is a block of contiguous constants or variables.
12
13
#[ derive( PartialEq , Eq , Clone , Copy , Hash ) ]
13
14
pub struct ArrayValue {
14
15
array_value : Value
@@ -23,50 +24,65 @@ impl ArrayValue {
23
24
}
24
25
}
25
26
27
+ /// Gets the string name of an `ArrayValue`. If the value is a constant, this will
28
+ /// return an empty string.
26
29
pub fn get_name ( & self ) -> & CStr {
27
30
self . array_value . get_name ( )
28
31
}
29
32
33
+ /// Sets the name of an `ArrayValue`. If the value is a constant, this is a noop.
30
34
pub fn set_name ( & self , name : & str ) {
31
35
self . array_value . set_name ( name) ;
32
36
}
33
37
38
+ /// Gets the type of this `ArrayValue`.
34
39
pub fn get_type ( & self ) -> ArrayType {
35
40
ArrayType :: new ( self . array_value . get_type ( ) )
36
41
}
37
42
43
+ /// Determines whether or not this value is null.
38
44
pub fn is_null ( & self ) -> bool {
39
45
self . array_value . is_null ( )
40
46
}
41
47
48
+ /// Determines whether or not this value is undefined.
42
49
pub fn is_undef ( & self ) -> bool {
43
50
self . array_value . is_undef ( )
44
51
}
45
52
53
+ /// Prints this `ArrayValue` to a string.
46
54
pub fn print_to_string ( & self ) -> LLVMString {
47
55
self . array_value . print_to_string ( )
48
56
}
49
57
58
+ /// Prints this `ArrayValue` to standard error.
50
59
pub fn print_to_stderr ( & self ) {
51
60
self . array_value . print_to_stderr ( )
52
61
}
53
62
63
+ /// Attempt to convert this `ArrayValue` to an `InstructionValue`, if possible.
54
64
pub fn as_instruction ( & self ) -> Option < InstructionValue > {
55
65
self . array_value . as_instruction ( )
56
66
}
57
67
68
+ /// Determines whether or not this `ArrayValue` has any associated metadata.
58
69
pub fn has_metadata ( & self ) -> bool {
59
70
self . array_value . has_metadata ( )
60
71
}
61
72
73
+ /// Gets the `MetadataValue` associated with this `ArrayValue` at a specific
74
+ /// `kind_id`.
62
75
pub fn get_metadata ( & self , kind_id : u32 ) -> Option < MetadataValue > {
63
76
self . array_value . get_metadata ( kind_id)
64
77
}
65
78
79
+ /// Assigns a `MetadataValue` to this `ArrayValue` at a specific `kind_id`.
66
80
pub fn set_metadata ( & self , metadata : MetadataValue , kind_id : u32 ) {
67
81
self . array_value . set_metadata ( metadata, kind_id)
68
82
}
69
83
84
+ /// Replaces all uses of this value with another value of the same type.
85
+ /// If used incorrectly this may result in invalid IR.
70
86
pub fn replace_all_uses_with ( & self , other : ArrayValue ) {
71
87
self . array_value . replace_all_uses_with ( other. as_value_ref ( ) )
72
88
}
0 commit comments