test2.wast 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. (module
  2. (type $ft (func))
  3. (type $st (struct))
  4. (type $at (array i8))
  5. (table $ta 10 anyref)
  6. (table $tf 10 funcref)
  7. (table $te 10 externref)
  8. (elem declare func $f)
  9. (func $f)
  10. (func (export "init") (param $x externref)
  11. (table.set $ta (i32.const 0) (ref.null any))
  12. (table.set $ta (i32.const 1) (ref.null struct))
  13. (table.set $ta (i32.const 2) (ref.null none))
  14. (table.set $ta (i32.const 3) (i31.new (i32.const 7)))
  15. (table.set $ta (i32.const 4) (struct.new_canon_default $st))
  16. (table.set $ta (i32.const 5) (array.new_canon_default $at (i32.const 0)))
  17. (table.set $ta (i32.const 6) (extern.internalize (local.get $x)))
  18. (table.set $ta (i32.const 7) (extern.internalize (ref.null extern)))
  19. (table.set $tf (i32.const 0) (ref.null nofunc))
  20. (table.set $tf (i32.const 1) (ref.null func))
  21. (table.set $tf (i32.const 2) (ref.func $f))
  22. (table.set $te (i32.const 0) (ref.null noextern))
  23. (table.set $te (i32.const 1) (ref.null extern))
  24. (table.set $te (i32.const 2) (local.get $x))
  25. (table.set $te (i32.const 3) (extern.externalize (i31.new (i32.const 8))))
  26. (table.set $te (i32.const 4) (extern.externalize (struct.new_canon_default $st)))
  27. (table.set $te (i32.const 5) (extern.externalize (ref.null any)))
  28. )
  29. (func (export "ref_test_null_data") (param $i i32) (result i32)
  30. (i32.add
  31. (ref.is_null (table.get $ta (local.get $i)))
  32. (ref.test null none (table.get $ta (local.get $i)))
  33. )
  34. )
  35. (func (export "ref_test_any") (param $i i32) (result i32)
  36. (i32.add
  37. (ref.test any (table.get $ta (local.get $i)))
  38. (ref.test null any (table.get $ta (local.get $i)))
  39. )
  40. )
  41. (func (export "ref_test_eq") (param $i i32) (result i32)
  42. (i32.add
  43. (ref.test eq (table.get $ta (local.get $i)))
  44. (ref.test null eq (table.get $ta (local.get $i)))
  45. )
  46. )
  47. (func (export "ref_test_i31") (param $i i32) (result i32)
  48. (i32.add
  49. (ref.test i31 (table.get $ta (local.get $i)))
  50. (ref.test null i31 (table.get $ta (local.get $i)))
  51. )
  52. )
  53. (func (export "ref_test_struct") (param $i i32) (result i32)
  54. (i32.add
  55. (ref.test struct (table.get $ta (local.get $i)))
  56. (ref.test null struct (table.get $ta (local.get $i)))
  57. )
  58. )
  59. (func (export "ref_test_array") (param $i i32) (result i32)
  60. (i32.add
  61. (ref.test array (table.get $ta (local.get $i)))
  62. (ref.test null array (table.get $ta (local.get $i)))
  63. )
  64. )
  65. (func (export "ref_test_null_func") (param $i i32) (result i32)
  66. (i32.add
  67. (ref.is_null (table.get $tf (local.get $i)))
  68. (ref.test null nofunc (table.get $tf (local.get $i)))
  69. )
  70. )
  71. (func (export "ref_test_func") (param $i i32) (result i32)
  72. (i32.add
  73. (ref.test func (table.get $tf (local.get $i)))
  74. (ref.test null func (table.get $tf (local.get $i)))
  75. )
  76. )
  77. (func (export "ref_test_null_extern") (param $i i32) (result i32)
  78. (i32.add
  79. (ref.is_null (table.get $te (local.get $i)))
  80. (ref.test null noextern (table.get $te (local.get $i)))
  81. )
  82. )
  83. (func (export "ref_test_extern") (param $i i32) (result i32)
  84. (i32.add
  85. (ref.test extern (table.get $te (local.get $i)))
  86. (ref.test null extern (table.get $te (local.get $i)))
  87. )
  88. )
  89. )