blob: 0a892b9fc933296596e74a4cc97d6c32a2750421 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
;;; TOOL: run-interp
(module
;; basic br test
(func (export "br0") (result i32)
(local i32 i32)
block $exit
i32.const 1
if
br 1 ;; if branches introduce blocks
end
i32.const 1
local.set 0 ;; not executed
end
i32.const 1
local.set 1
local.get 0
i32.const 0
i32.eq
local.get 1
i32.const 1
i32.eq
i32.add
return)
;; test br-ing with a depth > 0
(func (export "br1") (result i32)
(local i32 i32 i32)
block $outer
block $inner
i32.const 1
if
br 2
end ;; if branches introduce blocks
i32.const 1
local.set 0 ;; not executed
end
i32.const 1
local.set 1 ;; not executed
end
i32.const 1
local.set 2
local.get 0
i32.const 0
i32.eq
local.get 1
i32.const 0
i32.eq
i32.add
local.get 2
i32.const 1
i32.eq
i32.add
return)
;; test br-ing to a label
(func (export "br2") (result i32)
block $exit
block
i32.const 1
if
br $exit
end
i32.const 1
return ;; not executed
end
end
i32.const 2
return)
;; test br-ing in a loop with an exit and continue continuation
(func (export "br3") (result i32)
(local i32 i32)
block $exit
loop $cont
local.get 0
i32.const 1
i32.add
local.set 0
local.get 0
i32.const 5
i32.ge_s
if
br $exit
end
local.get 0
i32.const 4
i32.eq
if
(br $cont)
end
local.get 0
local.set 1
br $cont
end
end
local.get 1
return)
)
(;; STDOUT ;;;
br0() => i32:2
br1() => i32:3
br2() => i32:2
br3() => i32:3
;;; STDOUT ;;)
|