Skip to content
← Back

src/ir/for_iteration.ghul

1
namespace IR is
2
use Values.Value
3
4
/// A `for` loop's iterator held in a local: what the loop iterates and
5
/// the calls it makes on the iterator. A target that can walk the
6
/// iterated value's storage directly uses it to lower the loop without
7
/// an iterator; a target that cannot ignores it.
8
class FOR_ITERATION is
9
/// The value iterated, which `get_iterator` is called on.
10
receiver: Value
11
12
/// The call that makes the iterator.
13
get_iterator: Value
14
15
/// The call that moves the iterator on, answering whether there is
16
/// an element.
17
move_next: Value? public
18
19
/// The call that reads the element the iterator is at.
20
current: Value? public
21
22
init(receiver: Value, get_iterator: Value) is
23
self.receiver = receiver
24
self.get_iterator = get_iterator
25
si
26
si
27
si