test4.wast 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (module
  2. (type $ft (func))
  3. (type $st (struct))
  4. (type $at (array i8))
  5. (table 10 anyref)
  6. (elem declare func $f)
  7. (func $f)
  8. (func (export "init") (param $x externref)
  9. (table.set (i32.const 0) (ref.null any))
  10. (table.set (i32.const 1) (i31.new (i32.const 7)))
  11. (table.set (i32.const 2) (struct.new_canon_default $st))
  12. (table.set (i32.const 3) (array.new_canon_default $at (i32.const 0)))
  13. (table.set (i32.const 4) (extern.internalize (local.get $x)))
  14. (table.set (i32.const 5) (ref.null i31))
  15. (table.set (i32.const 6) (ref.null struct))
  16. (table.set (i32.const 7) (ref.null none))
  17. )
  18. (func (export "ref_cast_non_null") (param $i i32)
  19. (drop (ref.as_non_null (table.get (local.get $i))))
  20. (drop (ref.cast null any (table.get (local.get $i))))
  21. )
  22. (func (export "ref_cast_null") (param $i i32)
  23. (drop (ref.cast null any (table.get (local.get $i))))
  24. (drop (ref.cast null struct (table.get (local.get $i))))
  25. (drop (ref.cast null array (table.get (local.get $i))))
  26. (drop (ref.cast null i31 (table.get (local.get $i))))
  27. (drop (ref.cast null none (table.get (local.get $i))))
  28. )
  29. (func (export "ref_cast_i31") (param $i i32)
  30. (drop (ref.cast i31 (table.get (local.get $i))))
  31. (drop (ref.cast null i31 (table.get (local.get $i))))
  32. )
  33. (func (export "ref_cast_struct") (param $i i32)
  34. (drop (ref.cast struct (table.get (local.get $i))))
  35. (drop (ref.cast null struct (table.get (local.get $i))))
  36. )
  37. (func (export "ref_cast_array") (param $i i32)
  38. (drop (ref.cast array (table.get (local.get $i))))
  39. (drop (ref.cast null array (table.get (local.get $i))))
  40. )
  41. )