blob: 658f20c231e6e37c1879491d3346276d6d062ad3 (
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
(module
(type $t0 (struct))
(type $t1 (struct_subtype (field i32) $t0))
(type $t1' (struct_subtype (field i32) $t1))
(type $t2 (struct_subtype (field i32) (field i32) $t1))
(type $t2' (struct_subtype (field i32) (field i32) $t2))
(type $t3 (struct_subtype (field i32) (field i32) $t2))
(global $tab.0 (mut (ref null data)) (ref.null data))
(global $tab.1 (mut (ref null data)) (ref.null data))
(global $tab.2 (mut (ref null data)) (ref.null data))
(global $tab.3 (mut (ref null data)) (ref.null data))
(global $tab.4 (mut (ref null data)) (ref.null data))
(global $tab.10 (mut (ref null data)) (ref.null data))
(global $tab.11 (mut (ref null data)) (ref.null data))
(global $tab.12 (mut (ref null data)) (ref.null data))
(func $init
(global.set $tab.0 (struct.new_default $t0))
(global.set $tab.10 (struct.new_default $t0))
(global.set $tab.1 (struct.new_default $t1))
(global.set $tab.11 (struct.new_default $t1'))
(global.set $tab.2 (struct.new_default $t2))
(global.set $tab.12 (struct.new_default $t2'))
(global.set $tab.3 (struct.new_default $t3))
(global.set $tab.4 (struct.new_default $t3))
)
(func (export "test-sub")
(call $init)
(drop (ref.cast null $t0 (ref.null data)))
(drop (ref.cast null $t0 (global.get $tab.0)))
(drop (ref.cast null $t0 (global.get $tab.1)))
(drop (ref.cast null $t0 (global.get $tab.2)))
(drop (ref.cast null $t0 (global.get $tab.3)))
(drop (ref.cast null $t0 (global.get $tab.4)))
(drop (ref.cast null $t0 (ref.null data)))
(drop (ref.cast null $t1 (global.get $tab.1)))
(drop (ref.cast null $t1 (global.get $tab.2)))
(drop (ref.cast null $t0 (ref.null data)))
(drop (ref.cast null $t2 (global.get $tab.2)))
(drop (ref.cast null $t0 (ref.null data)))
(drop (ref.cast null $t3 (global.get $tab.3)))
(drop (ref.cast null $t0 (ref.null data)))
)
(func (export "test-canon")
(call $init)
(drop (ref.cast null $t0 (global.get $tab.10)))
(drop (ref.cast null $t0 (global.get $tab.11)))
(drop (ref.cast null $t0 (global.get $tab.12)))
(drop (ref.cast null $t1 (global.get $tab.11)))
(drop (ref.cast null $t1 (global.get $tab.12)))
(drop (ref.cast null $t2 (global.get $tab.12)))
)
(func (export "test-ref-test-t0") (result i32)
(ref.test $t0 (struct.new $t0))
)
(func (export "test-ref-test-struct") (result i32)
(ref.test struct (struct.new $t0))
)
(func (export "test-ref-test-any") (result i32)
(ref.test any (struct.new $t0))
)
(func (export "test-ref-cast-struct")
(drop
(ref.cast struct (struct.new $t0))
)
)
(func (export "test-br-on-cast-struct") (result i32)
(drop
(block $l (result (ref struct))
(drop
(br_on_cast $l struct (struct.new $t0))
)
(return (i32.const 0))
)
)
(i32.const 1)
)
(func (export "test-br-on-cast-fail-struct") (result i32)
(drop
(block $l (result (ref struct))
(drop
(br_on_cast_fail $l struct (struct.new $t0))
)
(return (i32.const 0))
)
)
(i32.const 1)
)
)
(invoke "test-sub")
(invoke "test-canon")
(assert_return (invoke "test-ref-test-t0") (i32.const 1))
(assert_return (invoke "test-ref-test-struct") (i32.const 1))
(assert_return (invoke "test-ref-test-any") (i32.const 1))
(assert_return (invoke "test-ref-cast-struct"))
(assert_return (invoke "test-br-on-cast-struct") (i32.const 1))
(assert_return (invoke "test-br-on-cast-fail-struct") (i32.const 0))
(assert_invalid
(module
(type $t0 (struct))
(func (export "test-ref-test-extern") (result i32)
(ref.test extern (struct.new $t0))
)
)
"common supertype"
)
|