summaryrefslogtreecommitdiff
path: root/test/reference-types.wast.from-wast
diff options
context:
space:
mode:
Diffstat (limited to 'test/reference-types.wast.from-wast')
-rw-r--r--test/reference-types.wast.from-wast509
1 files changed, 509 insertions, 0 deletions
diff --git a/test/reference-types.wast.from-wast b/test/reference-types.wast.from-wast
new file mode 100644
index 000000000..598e38e70
--- /dev/null
+++ b/test/reference-types.wast.from-wast
@@ -0,0 +1,509 @@
+(module
+ (type $anyref_=>_none (func (param anyref)))
+ (type $none_=>_anyref (func (result anyref)))
+ (type $funcref_=>_none (func (param funcref)))
+ (type $nullref_=>_none (func (param nullref)))
+ (type $exnref_=>_none (func (param exnref)))
+ (type $none_=>_funcref (func (result funcref)))
+ (type $none_=>_exnref (func (result exnref)))
+ (type $none_=>_none (func))
+ (type $none_=>_nullref (func (result nullref)))
+ (type $anyref_=>_funcref (func (param anyref) (result funcref)))
+ (import "env" "import_global" (global $import_global anyref))
+ (import "env" "import_func" (func $import_func (param anyref) (result funcref)))
+ (table $0 4 4 funcref)
+ (elem (i32.const 0) $take_anyref $take_funcref $take_exnref $take_nullref)
+ (global $global_anyref (mut anyref) (ref.null))
+ (global $global_funcref (mut funcref) (ref.null))
+ (global $global_exnref (mut exnref) (ref.null))
+ (global $global_nullref (mut nullref) (ref.null))
+ (global $global_anyref2 (mut anyref) (ref.func $foo))
+ (global $global_funcref2 (mut funcref) (ref.func $foo))
+ (export "export_func" (func $import_func))
+ (export "export_global" (global $import_global))
+ (func $take_anyref (; 1 ;) (param $0 anyref)
+ (nop)
+ )
+ (func $take_funcref (; 2 ;) (param $0 funcref)
+ (nop)
+ )
+ (func $take_exnref (; 3 ;) (param $0 exnref)
+ (nop)
+ )
+ (func $take_nullref (; 4 ;) (param $0 nullref)
+ (nop)
+ )
+ (func $foo (; 5 ;)
+ (nop)
+ )
+ (func $test (; 6 ;)
+ (local $local_anyref anyref)
+ (local $local_funcref funcref)
+ (local $local_exnref exnref)
+ (local $local_nullref nullref)
+ (local.set $local_anyref
+ (local.get $local_anyref)
+ )
+ (local.set $local_anyref
+ (local.get $local_funcref)
+ )
+ (local.set $local_anyref
+ (local.get $local_exnref)
+ )
+ (local.set $local_anyref
+ (local.get $local_nullref)
+ )
+ (local.set $local_anyref
+ (ref.null)
+ )
+ (local.set $local_anyref
+ (ref.func $foo)
+ )
+ (local.set $local_funcref
+ (local.get $local_funcref)
+ )
+ (local.set $local_funcref
+ (ref.null)
+ )
+ (local.set $local_funcref
+ (ref.func $foo)
+ )
+ (local.set $local_exnref
+ (local.get $local_exnref)
+ )
+ (local.set $local_exnref
+ (ref.null)
+ )
+ (local.set $local_nullref
+ (local.get $local_nullref)
+ )
+ (local.set $local_nullref
+ (ref.null)
+ )
+ (global.set $global_anyref
+ (global.get $global_anyref)
+ )
+ (global.set $global_anyref
+ (global.get $global_funcref)
+ )
+ (global.set $global_anyref
+ (global.get $global_exnref)
+ )
+ (global.set $global_anyref
+ (global.get $global_nullref)
+ )
+ (global.set $global_anyref
+ (ref.null)
+ )
+ (global.set $global_anyref
+ (ref.func $foo)
+ )
+ (global.set $global_funcref
+ (global.get $global_funcref)
+ )
+ (global.set $global_funcref
+ (ref.null)
+ )
+ (global.set $global_funcref
+ (ref.func $foo)
+ )
+ (global.set $global_exnref
+ (global.get $global_exnref)
+ )
+ (global.set $global_exnref
+ (ref.null)
+ )
+ (global.set $global_nullref
+ (global.get $global_nullref)
+ )
+ (global.set $global_nullref
+ (ref.null)
+ )
+ (call $take_anyref
+ (local.get $local_anyref)
+ )
+ (call $take_anyref
+ (local.get $local_funcref)
+ )
+ (call $take_anyref
+ (local.get $local_exnref)
+ )
+ (call $take_anyref
+ (ref.null)
+ )
+ (call_indirect (type $anyref_=>_none)
+ (local.get $local_anyref)
+ (i32.const 0)
+ )
+ (call_indirect (type $anyref_=>_none)
+ (local.get $local_funcref)
+ (i32.const 0)
+ )
+ (call_indirect (type $anyref_=>_none)
+ (local.get $local_exnref)
+ (i32.const 0)
+ )
+ (call_indirect (type $anyref_=>_none)
+ (ref.null)
+ (i32.const 0)
+ )
+ (call_indirect (type $funcref_=>_none)
+ (local.get $local_funcref)
+ (i32.const 1)
+ )
+ (call_indirect (type $funcref_=>_none)
+ (ref.null)
+ (i32.const 1)
+ )
+ (call_indirect (type $exnref_=>_none)
+ (local.get $local_exnref)
+ (i32.const 2)
+ )
+ (call_indirect (type $exnref_=>_none)
+ (ref.null)
+ (i32.const 2)
+ )
+ (call_indirect (type $nullref_=>_none)
+ (local.get $local_nullref)
+ (i32.const 3)
+ )
+ (call_indirect (type $nullref_=>_none)
+ (ref.null)
+ (i32.const 3)
+ )
+ (drop
+ (block $block (result anyref)
+ (br_if $block
+ (local.get $local_anyref)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $block0 (result anyref)
+ (br_if $block0
+ (local.get $local_funcref)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $block1 (result anyref)
+ (br_if $block1
+ (local.get $local_exnref)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $block2 (result anyref)
+ (br_if $block2
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $block3 (result funcref)
+ (br_if $block3
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $block4 (result exnref)
+ (br_if $block4
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $block5 (result nullref)
+ (br_if $block5
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (loop $loop-in (result anyref)
+ (local.get $local_anyref)
+ )
+ )
+ (drop
+ (loop $loop-in6 (result anyref)
+ (local.get $local_funcref)
+ )
+ )
+ (drop
+ (loop $loop-in7 (result anyref)
+ (local.get $local_exnref)
+ )
+ )
+ (drop
+ (loop $loop-in8 (result anyref)
+ (ref.null)
+ )
+ )
+ (drop
+ (loop $loop-in9 (result funcref)
+ (local.get $local_funcref)
+ )
+ )
+ (drop
+ (loop $loop-in10 (result funcref)
+ (ref.null)
+ )
+ )
+ (drop
+ (loop $loop-in11 (result exnref)
+ (local.get $local_exnref)
+ )
+ )
+ (drop
+ (loop $loop-in12 (result exnref)
+ (ref.null)
+ )
+ )
+ (drop
+ (loop $loop-in13 (result nullref)
+ (ref.null)
+ )
+ )
+ (drop
+ (if (result anyref)
+ (i32.const 1)
+ (local.get $local_anyref)
+ (local.get $local_exnref)
+ )
+ )
+ (drop
+ (if (result anyref)
+ (i32.const 1)
+ (ref.func $foo)
+ (ref.null)
+ )
+ )
+ (drop
+ (if (result funcref)
+ (i32.const 1)
+ (ref.func $foo)
+ (ref.null)
+ )
+ )
+ (drop
+ (if (result exnref)
+ (i32.const 1)
+ (local.get $local_exnref)
+ (ref.null)
+ )
+ )
+ (drop
+ (if (result nullref)
+ (i32.const 1)
+ (local.get $local_nullref)
+ (ref.null)
+ )
+ )
+ (drop
+ (try (result anyref)
+ (local.get $local_anyref)
+ (catch
+ (exnref.pop)
+ )
+ )
+ )
+ (drop
+ (try (result anyref)
+ (ref.func $foo)
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ (ref.null)
+ )
+ )
+ )
+ (drop
+ (try (result funcref)
+ (ref.func $foo)
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ (ref.null)
+ )
+ )
+ )
+ (drop
+ (try (result exnref)
+ (ref.null)
+ (catch
+ (exnref.pop)
+ )
+ )
+ )
+ (drop
+ (try (result nullref)
+ (ref.null)
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ (ref.null)
+ )
+ )
+ )
+ (drop
+ (select (result anyref)
+ (local.get $local_anyref)
+ (ref.func $foo)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result anyref)
+ (local.get $local_exnref)
+ (local.get $local_anyref)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result anyref)
+ (local.get $local_anyref)
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result anyref)
+ (ref.null)
+ (ref.func $foo)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result funcref)
+ (ref.func $foo)
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result exnref)
+ (ref.null)
+ (local.get $local_exnref)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result nullref)
+ (ref.null)
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select
+ (i32.const 0)
+ (i32.const 2)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (ref.is_null
+ (local.get $local_anyref)
+ )
+ )
+ (drop
+ (ref.is_null
+ (local.get $local_exnref)
+ )
+ )
+ (drop
+ (ref.is_null
+ (ref.func $foo)
+ )
+ )
+ (drop
+ (ref.is_null
+ (ref.null)
+ )
+ )
+ )
+ (func $return_anyref (; 7 ;) (result anyref)
+ (local $local_anyref anyref)
+ (local.get $local_anyref)
+ )
+ (func $return_anyref2 (; 8 ;) (result anyref)
+ (ref.func $foo)
+ )
+ (func $return_anyref3 (; 9 ;) (result anyref)
+ (local $local_exnref exnref)
+ (local.get $local_exnref)
+ )
+ (func $return_anyref4 (; 10 ;) (result anyref)
+ (ref.null)
+ )
+ (func $return_funcref (; 11 ;) (result funcref)
+ (ref.func $foo)
+ )
+ (func $return_funcref2 (; 12 ;) (result funcref)
+ (ref.null)
+ )
+ (func $return_exnref (; 13 ;) (result exnref)
+ (local $local_exnref exnref)
+ (local.get $local_exnref)
+ )
+ (func $return_exnref2 (; 14 ;) (result exnref)
+ (ref.null)
+ )
+ (func $return_nullref (; 15 ;) (result nullref)
+ (local $local_nullref nullref)
+ (local.get $local_nullref)
+ )
+ (func $return_anyref_returns (; 16 ;) (result anyref)
+ (local $local_anyref anyref)
+ (local $local_exnref exnref)
+ (return
+ (local.get $local_anyref)
+ )
+ (return
+ (local.get $local_exnref)
+ )
+ (return
+ (ref.func $foo)
+ )
+ (return
+ (ref.null)
+ )
+ )
+ (func $return_funcref_returns (; 17 ;) (result funcref)
+ (return
+ (ref.func $foo)
+ )
+ (return
+ (ref.null)
+ )
+ )
+ (func $return_exnref_returns (; 18 ;) (result exnref)
+ (local $local_exnref exnref)
+ (return
+ (local.get $local_exnref)
+ )
+ (return
+ (ref.null)
+ )
+ )
+ (func $return_nullref_returns (; 19 ;) (result nullref)
+ (local $local_nullref nullref)
+ (return
+ (local.get $local_nullref)
+ )
+ (return
+ (ref.null)
+ )
+ )
+)