File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 144
144
)
145
145
)
146
146
147
+ ;; Multiple tables
148
+
149
+ (table $tab2 funcref (elem $tab-f1 ))
150
+ (table $tab3 funcref (elem $tab-f2 ))
151
+
152
+ (func $tab-f1 (result i32 ) (i32.const 0x133 ))
153
+ (func $tab-f2 (result i32 ) (i32.const 0x134 ))
154
+
155
+ (func (export " call-tab" ) (param $i i32 ) (result i32 )
156
+ (if (i32.eq (local.get $i ) (i32.const 0 ))
157
+ (then (return_call_indirect (type $out-i32 ) (i32.const 0 )))
158
+ )
159
+ (if (i32.eq (local.get $i ) (i32.const 1 ))
160
+ (then (return_call_indirect 1 (type $out-i32 ) (i32.const 0 )))
161
+ )
162
+ (if (i32.eq (local.get $i ) (i32.const 2 ))
163
+ (then (return_call_indirect $tab3 (type $out-i32 ) (i32.const 0 )))
164
+ )
165
+ (i32.const 0 )
166
+ )
167
+
147
168
;; Recursion
148
169
149
170
(func $fac (export " fac" ) (type $over-i64 )
223
244
(assert_trap (invoke " dispatch-structural" (i32.const 11 )) " indirect call type mismatch" )
224
245
(assert_trap (invoke " dispatch-structural" (i32.const 16 )) " indirect call type mismatch" )
225
246
247
+ (assert_return (invoke " call-tab" (i32.const 0 )) (i32.const 0x132 ))
248
+ (assert_return (invoke " call-tab" (i32.const 1 )) (i32.const 0x133 ))
249
+ (assert_return (invoke " call-tab" (i32.const 2 )) (i32.const 0x134 ))
250
+
226
251
(assert_return (invoke " fac" (i64.const 0 )) (i64.const 1 ))
227
252
(assert_return (invoke " fac" (i64.const 1 )) (i64.const 1 ))
228
253
(assert_return (invoke " fac" (i64.const 5 )) (i64.const 120 ))
You can’t perform that action at this time.
0 commit comments