| 1 |
(module |
| 2 |
(type $ft (;0;) (func)) |
| 3 |
(type $st (;1;) (struct)) |
| 4 |
(type $at (;2;) (array i8)) |
| 5 |
(type (;3;) (func (param externref))) |
| 6 |
(type (;4;) (func (param i32))) |
| 7 |
(table (;0;) 10 anyref) |
| 8 |
(export "init" (func 1)) |
| 9 |
(export "ref_cast_non_null" (func 2)) |
| 10 |
(export "ref_cast_null" (func 3)) |
| 11 |
(export "ref_cast_i31" (func 4)) |
| 12 |
(export "ref_cast_struct" (func 5)) |
| 13 |
(export "ref_cast_array" (func 6)) |
| 14 |
(elem (;0;) declare func $f) |
| 15 |
(func $f (;0;) (type $ft)) |
| 16 |
(func (;1;) (type 3) (param $x externref) |
| 17 |
i32.const 0 |
| 18 |
;; [i32] |
| 19 |
ref.null any |
| 20 |
;; [i32 anyref] |
| 21 |
table.set 0 |
| 22 |
;; [] |
| 23 |
i32.const 1 |
| 24 |
;; [i32] |
| 25 |
i32.const 7 |
| 26 |
;; [i32 i32] |
| 27 |
ref.i31 |
| 28 |
;; [i32 (ref i31)] |
| 29 |
table.set 0 |
| 30 |
;; [] |
| 31 |
i32.const 2 |
| 32 |
;; [i32] |
| 33 |
struct.new_default $st |
| 34 |
;; [i32 (ref (id 1))] |
| 35 |
table.set 0 |
| 36 |
;; [] |
| 37 |
i32.const 3 |
| 38 |
;; [i32] |
| 39 |
i32.const 0 |
| 40 |
;; [i32 i32] |
| 41 |
array.new_default $at |
| 42 |
;; [i32 (ref (id 2))] |
| 43 |
table.set 0 |
| 44 |
;; [] |
| 45 |
i32.const 4 |
| 46 |
;; [i32] |
| 47 |
local.get $x |
| 48 |
;; [i32 externref] |
| 49 |
any.convert_extern |
| 50 |
;; [i32 anyref] |
| 51 |
table.set 0 |
| 52 |
;; [] |
| 53 |
i32.const 5 |
| 54 |
;; [i32] |
| 55 |
ref.null i31 |
| 56 |
;; [i32 i31ref] |
| 57 |
table.set 0 |
| 58 |
;; [] |
| 59 |
i32.const 6 |
| 60 |
;; [i32] |
| 61 |
ref.null struct |
| 62 |
;; [i32 structref] |
| 63 |
table.set 0 |
| 64 |
;; [] |
| 65 |
i32.const 7 |
| 66 |
;; [i32] |
| 67 |
ref.null none |
| 68 |
;; [i32 nullref] |
| 69 |
table.set 0 |
| 70 |
;; [] |
| 71 |
) |
| 72 |
(func (;2;) (type 4) (param $i i32) |
| 73 |
local.get $i |
| 74 |
;; [i32] |
| 75 |
table.get 0 |
| 76 |
;; [anyref] |
| 77 |
ref.as_non_null |
| 78 |
;; [(ref any)] |
| 79 |
drop |
| 80 |
;; [] |
| 81 |
local.get $i |
| 82 |
;; [i32] |
| 83 |
table.get 0 |
| 84 |
;; [anyref] |
| 85 |
ref.cast anyref |
| 86 |
;; [anyref] |
| 87 |
drop |
| 88 |
;; [] |
| 89 |
) |
| 90 |
(func (;3;) (type 4) (param $i i32) |
| 91 |
local.get $i |
| 92 |
;; [i32] |
| 93 |
table.get 0 |
| 94 |
;; [anyref] |
| 95 |
ref.cast anyref |
| 96 |
;; [anyref] |
| 97 |
drop |
| 98 |
;; [] |
| 99 |
local.get $i |
| 100 |
;; [i32] |
| 101 |
table.get 0 |
| 102 |
;; [anyref] |
| 103 |
ref.cast structref |
| 104 |
;; [structref] |
| 105 |
drop |
| 106 |
;; [] |
| 107 |
local.get $i |
| 108 |
;; [i32] |
| 109 |
table.get 0 |
| 110 |
;; [anyref] |
| 111 |
ref.cast arrayref |
| 112 |
;; [arrayref] |
| 113 |
drop |
| 114 |
;; [] |
| 115 |
local.get $i |
| 116 |
;; [i32] |
| 117 |
table.get 0 |
| 118 |
;; [anyref] |
| 119 |
ref.cast i31ref |
| 120 |
;; [i31ref] |
| 121 |
drop |
| 122 |
;; [] |
| 123 |
local.get $i |
| 124 |
;; [i32] |
| 125 |
table.get 0 |
| 126 |
;; [anyref] |
| 127 |
ref.cast nullref |
| 128 |
;; [nullref] |
| 129 |
drop |
| 130 |
;; [] |
| 131 |
) |
| 132 |
(func (;4;) (type 4) (param $i i32) |
| 133 |
local.get $i |
| 134 |
;; [i32] |
| 135 |
table.get 0 |
| 136 |
;; [anyref] |
| 137 |
ref.cast (ref i31) |
| 138 |
;; [(ref i31)] |
| 139 |
drop |
| 140 |
;; [] |
| 141 |
local.get $i |
| 142 |
;; [i32] |
| 143 |
table.get 0 |
| 144 |
;; [anyref] |
| 145 |
ref.cast i31ref |
| 146 |
;; [i31ref] |
| 147 |
drop |
| 148 |
;; [] |
| 149 |
) |
| 150 |
(func (;5;) (type 4) (param $i i32) |
| 151 |
local.get $i |
| 152 |
;; [i32] |
| 153 |
table.get 0 |
| 154 |
;; [anyref] |
| 155 |
ref.cast (ref struct) |
| 156 |
;; [(ref struct)] |
| 157 |
drop |
| 158 |
;; [] |
| 159 |
local.get $i |
| 160 |
;; [i32] |
| 161 |
table.get 0 |
| 162 |
;; [anyref] |
| 163 |
ref.cast structref |
| 164 |
;; [structref] |
| 165 |
drop |
| 166 |
;; [] |
| 167 |
) |
| 168 |
(func (;6;) (type 4) (param $i i32) |
| 169 |
local.get $i |
| 170 |
;; [i32] |
| 171 |
table.get 0 |
| 172 |
;; [anyref] |
| 173 |
ref.cast (ref array) |
| 174 |
;; [(ref array)] |
| 175 |
drop |
| 176 |
;; [] |
| 177 |
local.get $i |
| 178 |
;; [i32] |
| 179 |
table.get 0 |
| 180 |
;; [anyref] |
| 181 |
ref.cast arrayref |
| 182 |
;; [arrayref] |
| 183 |
drop |
| 184 |
;; [] |
| 185 |
) |
| 186 |
) |