blob: 5a930bbcd5cbb79a793d5008442a73d26ba65ff0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
;;; TOOL: run-interp
(module
(type $v_i (func (result i32)))
(func $zero (type $v_i)
i32.const 0)
(func $one (type $v_i)
i32.const 1)
(func $nullary (param i32) (result i32)
local.get 0
call_indirect (type $v_i))
(type $ii_i (func (param i32 i32) (result i32)))
(func $add (type $ii_i)
local.get 0
local.get 1
i32.add)
(func $sub (type $ii_i)
local.get 0
local.get 1
i32.sub)
(func $binary (param i32 i32 i32) (result i32)
local.get 0
local.get 1
local.get 2
call_indirect (type $ii_i))
(table funcref (elem $zero $one $add $sub))
(func (export "test_zero") (result i32)
i32.const 0
call $nullary)
(func (export "test_one") (result i32)
i32.const 1
call $nullary)
(func (export "test_add") (result i32)
i32.const 10
i32.const 4
i32.const 2
call $binary)
(func (export "test_sub") (result i32)
i32.const 10
i32.const 4
i32.const 3
call $binary)
(func (export "trap_oob") (result i32)
i32.const 10
i32.const 4
i32.const 4
call $binary)
(func (export "trap_sig_mismatch") (result i32)
i32.const 10
i32.const 4
i32.const 0
call $binary))
(;; STDOUT ;;;
test_zero() => i32:0
test_one() => i32:1
test_add() => i32:14
test_sub() => i32:6
trap_oob() => error: undefined table index
trap_sig_mismatch() => error: indirect call signature mismatch
;;; STDOUT ;;)
|