Implement tables and call_indirect (#12)
* Implement tables and call_indirect * Restore comment about sig checking. * Widen callee index on 64bit platforms.
This commit is contained in:
committed by
Dan Gohman
parent
e7c8d23a42
commit
7b222190f5
50
filetests/call_indirect.wat
Normal file
50
filetests/call_indirect.wat
Normal file
@@ -0,0 +1,50 @@
|
||||
(module
|
||||
(type $indirect_sig (func (param i64) (result i64)))
|
||||
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
(get_local 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
|
||||
(func $plus_1 (param i64) (result i64)
|
||||
get_local 0
|
||||
i64.const 1
|
||||
i64.add
|
||||
)
|
||||
(func $minus_1 (param i64) (result i64)
|
||||
get_local 0
|
||||
i64.const 1
|
||||
i64.sub
|
||||
)
|
||||
|
||||
(func $main
|
||||
(call $call_indirect
|
||||
(i32.const 0)
|
||||
(i64.const 2)
|
||||
)
|
||||
(call $call_indirect
|
||||
(i32.const 1)
|
||||
(i64.const 0)
|
||||
)
|
||||
)
|
||||
|
||||
(func $call_indirect (param $func i32) (param $expected i64)
|
||||
(call $assert
|
||||
(i64.eq
|
||||
(call_indirect (type $indirect_sig)
|
||||
(i64.const 1)
|
||||
(get_local $func)
|
||||
)
|
||||
(get_local $expected)
|
||||
)
|
||||
)
|
||||
)
|
||||
(start $main)
|
||||
|
||||
(table 2 2 anyfunc)
|
||||
(elem (i32.const 0) $plus_1 $minus_1)
|
||||
)
|
||||
Reference in New Issue
Block a user