wasmer/examples/call_indirect.wast
2018-10-23 11:49:38 +02:00

31 lines
728 B
Plaintext

(module
(type $multiply_signature (func (param i32 i32) (result i32)))
(table 1 1 anyfunc)
(elem (i32.const 0) $multiply)
(memory $0 1)
(export "memory" (memory $0))
(export "dispatch" (func $dispatch))
(export "multiply" (func $multiply))
(export "main" (func $main))
(func $dispatch (; 0 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(call_indirect (type $multiply_signature)
(get_local $1)
(get_local $2)
(get_local $0)
)
)
(func $multiply (; 1 ;) (type $multiply_signature) (param $0 i32) (param $1 i32) (result i32)
(i32.mul
(get_local $1)
(get_local $0)
)
)
(func $main (; 2 ;) (result i32)
(call $dispatch
(i32.const 0)
(i32.const 20)
(i32.const 30)
)
)
)