2017-12-21 10:14:53 +01:00
|
|
|
(module
|
|
|
|
(type $ii (func (param i32) (result i32)))
|
2018-05-14 16:55:55 +02:00
|
|
|
(global $HEAP_BASE i32 (i32.const 8))
|
2018-06-28 01:44:32 +02:00
|
|
|
(memory $0 0)
|
2017-12-21 10:14:53 +01:00
|
|
|
(export "memory" (memory $0))
|
2018-07-18 23:49:32 +02:00
|
|
|
(export "fib" (func $recursive/fib))
|
2017-12-21 10:14:53 +01:00
|
|
|
(func $recursive/fib (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
|
|
|
(if
|
|
|
|
(i32.le_s
|
|
|
|
(get_local $0)
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
(return
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
)
|
2018-06-22 15:26:59 +02:00
|
|
|
(i32.add
|
|
|
|
(call $recursive/fib
|
|
|
|
(i32.sub
|
|
|
|
(get_local $0)
|
|
|
|
(i32.const 1)
|
2017-12-21 10:14:53 +01:00
|
|
|
)
|
2018-06-22 15:26:59 +02:00
|
|
|
)
|
|
|
|
(call $recursive/fib
|
|
|
|
(i32.sub
|
|
|
|
(get_local $0)
|
|
|
|
(i32.const 2)
|
2017-12-21 10:14:53 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|