Skip to content
← Back

src/ir/values/array_element_address.ghul

1
namespace IR.Values is
2
use Semantic.Types.Type
3
4
// The address of `array[index]`, for a `ref` to an array element: a
5
// write through it lands in the array, where reading the element and
6
// taking the address of the copy would lose it.
7
class ARRAY_ELEMENT_ADDRESS: Value is
8
array: Value
9
index: Value
10
element_type: Type
11
12
type: Type
13
has_address: bool => true
14
15
init(array: Value, index: Value, element_type: Type, type: Type) is
16
super.init()
17
18
self.array = array
19
self.index = index
20
self.element_type = element_type
21
self.type = type
22
si
23
24
accept(visitor: Visitor) is
25
visitor.visit(self)
26
si
27
28
accept_address(visitor: Visitor) is
29
visitor.visit_address(self)
30
si
31
32
to_string() -> string => "array-element-address:({array}[{index}])"
33
si
34
si