wasmer/examples/fib.wat
2019-09-15 17:57:40 +08:00

21 lines
521 B
Plaintext

(module
(func $main (result i32)
(call $fib (i32.const 40))
)
(func $fib (param $n i32) (result i32)
(if (i32.eq (get_local $n) (i32.const 0))
(then (return (i32.const 1)))
)
(if (i32.eq (get_local $n) (i32.const 1))
(then (return (i32.const 1)))
)
(i32.add
(call $fib (i32.sub (get_local $n) (i32.const 1)))
(call $fib (i32.sub (get_local $n) (i32.const 2)))
)
)
(export "main" (func $main))
)