Debian Codegraph @

internal/integration_test/spectest/extended-const/testdata/elem.wast

raw
1 ;; Extended contant expressions
2
3 (module
4 (table 10 funcref)
5 (func (result i32) (i32.const 42))
6 (func (export "call_in_table") (param i32) (result i32)
7 (call_indirect (type 0) (local.get 0)))
8 (elem (table 0) (offset (i32.add (i32.const 1) (i32.const 2))) funcref (ref.func 0))
9 )
10
11 (assert_return (invoke "call_in_table" (i32.const 3)) (i32.const 42))
12 (assert_trap (invoke "call_in_table" (i32.const 0)) "uninitialized element")
13
14 (module
15 (table 10 funcref)
16 (func (result i32) (i32.const 42))
17 (func (export "call_in_table") (param i32) (result i32)
18 (call_indirect (type 0) (local.get 0)))
19 (elem (table 0) (offset (i32.sub (i32.const 2) (i32.const 1))) funcref (ref.func 0))
20 )
21
22 (assert_return (invoke "call_in_table" (i32.const 1)) (i32.const 42))
23 (assert_trap (invoke "call_in_table" (i32.const 0)) "uninitialized element")
24
25 (module
26 (table 10 funcref)
27 (func (result i32) (i32.const 42))
28 (func (export "call_in_table") (param i32) (result i32)
29 (call_indirect (type 0) (local.get 0)))
30 (elem (table 0) (offset (i32.mul (i32.const 2) (i32.const 2))) funcref (ref.func 0))
31 )
32
33 (assert_return (invoke "call_in_table" (i32.const 4)) (i32.const 42))
34 (assert_trap (invoke "call_in_table" (i32.const 0)) "uninitialized element")
35
36 ;; Combining add, sub, mul and global.get
37
38 (module
39 (global (import "spectest" "global_i32") i32)
40 (table 10 funcref)
41 (func (result i32) (i32.const 42))
42 (func (export "call_in_table") (param i32) (result i32)
43 (call_indirect (type 0) (local.get 0)))
44 (elem (table 0)
45 (offset
46 (i32.mul
47 (i32.const 2)
48 (i32.add
49 (i32.sub (global.get 0) (i32.const 665))
50 (i32.const 2))))
51 funcref
52 (ref.func 0))
53 )
54
55 (assert_return (invoke "call_in_table" (i32.const 6)) (i32.const 42))
56 (assert_trap (invoke "call_in_table" (i32.const 0)) "uninitialized element")