blob: 101136df2f39b8ac22cf09a2617e327b09b685f4 (
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
|
(module
(event $e0 (attr 0) (param i32))
(event $e1 (attr 0) (param anyref))
(func $exnref_test (param $0 exnref) (result exnref)
(local.get $0)
)
(func $foo)
(func $bar)
(func $eh_test (local $exn exnref)
(try
(throw $e0 (i32.const 0))
(catch
;; Multi-value is not available yet, so block can't take a value from
;; stack. So this uses locals for now.
(local.set $exn (exnref.pop))
(drop
(block $l0 (result i32)
(rethrow
(br_on_exn $l0 $e0 (local.get $exn))
)
)
)
)
)
;; Try with a block label
(try $l1
(br $l1)
(catch
(br $l1)
)
)
;; Empty try body
(try
(catch
(drop (exnref.pop))
)
)
;; Multiple instructions within try and catch bodies
(try
(block
(call $foo)
(call $bar)
)
(catch
(drop (exnref.pop))
(call $foo)
(call $bar)
)
)
)
;; Test subtype relationship
(func $subtype_test
(try
(catch
(drop (exnref.pop))
(drop
(block $l0 (result i32)
(rethrow
(br_on_exn $l0 $e0 (ref.null))
)
)
)
)
)
(throw $e1 (ref.null))
)
)
|