Skip to content
← Back

src/ir/values/post_increment.ghul

1
namespace IR.Values is
2
use Semantic.Types.Type
3
4
// Reads an int local and post-increments it: leaves the pre-increment
5
// value on the stack and writes back value + 1. Used by fused `index()`
6
// stages to produce each element's index while advancing the running
7
// counter - the pre-increment value feeds straight into the
8
// INDEXED_VALUE constructor.
9
class POST_INCREMENT: Value is
10
counter: IR.LOCAL
11
12
type: Type
13
14
init(counter: IR.LOCAL, type: Type) is
15
super.init()
16
17
self.counter = counter
18
self.type = type
19
si
20
21
accept(visitor: Visitor) is
22
visitor.visit(self)
23
si
24
25
to_string() -> string => "post_increment:({counter})"
26
si
27
si