about summary refs log tree commit diff
path: root/boot/tests/lower/while_loop.cskt
blob: 38f860944335278919df0035bc62f9f0c7537c2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
while loops are 1:1 with the intermediate representation's
single loop kind.
increment/decrement statements lower to an expression statement
wrapping the dedicated inc/dec ir node.

<<<

main = fun () {
    var i int = 0
    while i < 10 {
        i++
    }
}

>>>

(unit
	(types
		(type 0 int primitive)
		(type 1 uint primitive)
		(type 2 bool primitive)
		(type 3 string primitive)
		(type 4 float primitive)
		(type 5 byte primitive)
		(type 6 ascii primitive)
		(type 7 void primitive))
	(functions
		(function 0 main main (returns (ref void)) (block
			(declaration i (ref int) (initializer (expr 0)))
			(loop (condition (expr (binary < (expr (name i)) (expr 10)))) (block
				(expression-stmt (expr (postfix-++ (expr (name i)))))
			))
		)))
	(emission_order 0 1 2 3 4 5 6 7))