-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy paththrow_ref08.wast
33 lines (27 loc) · 927 Bytes
/
throw_ref08.wast
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
(module
(tag $e0)
(tag $e1)
(tag $e2)
(func (export "throw_ref-multi") (param i32) (result i32)
(local $exn1 exnref)
(block $h1 (result exnref)
(if (i32.eq (local.get 0) (i32.const 0))
(then (try_table (catch_all_ref $h1) (throw $e0))))
(if (i32.eq (local.get 0) (i32.const 1))
(then (try_table (catch_all_ref $h1) (throw $e1))))
(if (i32.eq (local.get 0) (i32.const 2))
(then (try_table (catch_all_ref $h1) (throw $e2))))
(ref.null exn)
)
local.set 1
(if (ref.is_null (local.get 1))
(then (return (i32.const 57)))
(else (throw_ref (local.get 1)))
)
(i32.const -99)
)
)
(assert_exception (invoke "throw_ref-multi" (i32.const 0)))
(assert_exception (invoke "throw_ref-multi" (i32.const 1)))
(assert_exception (invoke "throw_ref-multi" (i32.const 2)))
(assert_return (invoke "throw_ref-multi" (i32.const 3)) (i32.const 57))