2017-12-21 10:14:53 +01:00
|
|
|
(module
|
|
|
|
(type $ii (func (param i32) (result i32)))
|
2018-09-17 01:48:35 +02:00
|
|
|
(type $v (func))
|
2018-06-28 01:44:32 +02:00
|
|
|
(memory $0 0)
|
2018-10-11 08:49:08 +02:00
|
|
|
(table 1 anyfunc)
|
|
|
|
(elem (i32.const 0) $null)
|
2017-12-21 10:14:53 +01:00
|
|
|
(export "memory" (memory $0))
|
2018-10-11 08:49:08 +02:00
|
|
|
(export "table" (table $0))
|
2018-07-18 23:49:32 +02:00
|
|
|
(export "fib" (func $recursive/fib))
|
2018-08-02 18:23:02 +02:00
|
|
|
(func $recursive/fib (; 0 ;) (; has Stack IR ;) (type $ii) (param $0 i32) (result i32)
|
2018-10-11 08:49:08 +02:00
|
|
|
(local $1 i32)
|
2017-12-21 10:14:53 +01:00
|
|
|
(if
|
|
|
|
(i32.le_s
|
|
|
|
(get_local $0)
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
(return
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
)
|
2018-10-11 08:49:08 +02:00
|
|
|
(set_local $1
|
2017-12-21 10:14:53 +01:00
|
|
|
(call $recursive/fib
|
|
|
|
(i32.sub
|
|
|
|
(get_local $0)
|
|
|
|
(i32.const 1)
|
|
|
|
)
|
|
|
|
)
|
2018-10-11 08:49:08 +02:00
|
|
|
)
|
|
|
|
(set_local $0
|
2017-12-21 10:14:53 +01:00
|
|
|
(call $recursive/fib
|
|
|
|
(i32.sub
|
|
|
|
(get_local $0)
|
|
|
|
(i32.const 2)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2018-10-11 08:49:08 +02:00
|
|
|
(i32.add
|
|
|
|
(get_local $1)
|
|
|
|
(get_local $0)
|
|
|
|
)
|
2017-12-21 10:14:53 +01:00
|
|
|
)
|
2018-09-17 01:48:35 +02:00
|
|
|
(func $null (; 1 ;) (; has Stack IR ;) (type $v)
|
|
|
|
(nop)
|
|
|
|
)
|
2017-12-21 10:14:53 +01:00
|
|
|
)
|